def fix_latex_file(latex_file):
documentclass_re = re.compile("(\\\\documentclass\[)(1[012]pt,?)(.+)")
- newcommandx_re = re.compile("^(\\\\newcommandx)(.+)")
tmp = mkstemp()
changed = 0
for line in open(latex_file, 'r').readlines():
match = documentclass_re.match(line)
- if match != None:
- changed = 1
- tmp.write("%s%s\n" % (match.group(1), match.group(3)))
- continue
-
- match = newcommandx_re.match(line)
if match == None:
tmp.write(line)
continue
changed = 1
- tmp.write("\\providecommandx%s\n" % match.group(2))
+ tmp.write("%s%s\n" % (match.group(1), match.group(3)))
if changed:
copyfileobj(tmp, open(latex_file,"wb"), 1)