Skip to content

Instantly share code, notes, and snippets.

@ansmirnov
Created January 13, 2016 13:25
Show Gist options
  • Save ansmirnov/5df53108b976a1694cef to your computer and use it in GitHub Desktop.
Save ansmirnov/5df53108b976a1694cef to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# prepare_tex.py
import sys
import re
def cat(fn):
return open(fn, 'rt').read().replace('\\', '====')
def prepare_tex(fn):
r = cat(fn)
for s in re.findall(r'====input{([-a-zA-Z._0-9/]*)}', r):
cs = prepare_tex(s)
r = re.sub(r'====input{' + s + '}', cs, r)
return r
print prepare_tex(sys.argv[1]).replace('====', '\\')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment