You could use regular expressions to make the necessary replacements as follows:
import re
test = """
.org-link {
/* org-link */
color: #b58900;
font-weight: bold;
text-decoration: underline;
}
"""
def fix(org_link):
new_color = re.sub(r'(.*?color\s*?:\s*?)(.*?)(;)', r'\1#777\3', org_link.group(0), flags=re.S)
return re.sub(r'(.*?)(\s+?text-decoration: underline;)(.*?)', r'\1\3', new_color, flags=re.S)
print re.sub(r'(org-link\s+\{.*\})', fix, test, flags=re.S)
This would convert the text as follows:
.org-link {
/* org-link */
color:#777;
font-weight: bold;
}
It works by first identifying suitable org-link blocks and then first replacing the color and then removing any text-decoration entries.
The script could then be extended to carry this out on all of the HTML files in a given folder as follows:
import re
import glob
def fix(org_link):
new_color = re.sub(r'(.*?color\s*?:\s*?)(.*?)(;)', r'\1#777\3', org_link.group(0), flags=re.S)
return re.sub(r'(.*?)(\s+?text-decoration: underline;)(.*?)', r'\1\3', new_color, flags=re.S)
for html_file in glob.glob('*.html'):
print html_file
with open(html_file) as f_input:
html = re.sub(r'(org-link\s+\{.*\})', fix, f_input.read(), flags=re.S)
with open(html_file, 'w') as f_output:
f_output.write(html)
Tested using Python 2.7.9
text-decorationcss attribute in the file?