blob: 68a649e55974e531d336064f73a0edeee9ee83c6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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(line.rstrip(), file=outfile)
os.remove(latex_file_old)
return 0
|