diff options
Diffstat (limited to 'dviware/dvisvgm/doc/tweak-dblatex-tex.py')
-rw-r--r-- | dviware/dvisvgm/doc/tweak-dblatex-tex.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/dviware/dvisvgm/doc/tweak-dblatex-tex.py b/dviware/dvisvgm/doc/tweak-dblatex-tex.py new file mode 100644 index 0000000000..3f34d94e65 --- /dev/null +++ b/dviware/dvisvgm/doc/tweak-dblatex-tex.py @@ -0,0 +1,18 @@ +import re +import os + +def main (latex_file, stdout): + latex_file_old = latex_file+"-old" + os.rename(latex_file, latex_file_old) + os.remove(os.path.splitext(latex_file)[0]+".pdf") + with open(latex_file, "w") as outfile: + with open(latex_file_old) as infile: + lines = infile.readlines() + for line in lines: + if re.match(r'(.*\\def)|(.*\\href)', line) == None: + line = re.sub(r'([a-zA-Z0-9]+)/', r'\1\slash{}', line) + line = re.sub(r'-{}-{}', r'\=/\=/', line) + line = re.sub(r'([^a-zA-Z0-9])-{}', r'\1\=/', line) + print >>outfile, line.rstrip() + os.remove(latex_file_old) + return 0 |