python 2 does not allow to declare a string as raw byte so we double
the backslashes and remove the r preffix
python 3 accepts rb"..." meaning a byte string that is raw. In this context
raw means that the backslash does not has any special meaning and thus it
is not escaped. This is usefull together with regular expressions where the
backslashes are special.
In the worst possible case, like this one, we must use 4 backslashes to represent
one in the regular expression...
def fix_latex_file(latex_file, pdf_output):
- def_re = re.compile(rb"(\\newcommandx|\\global\\long\\def)(\\[a-zA-Z]+)")
+ # python 2 does not allow to declare a string as raw byte so we double
+ # the backslashes and remove the r preffix
+ def_re = re.compile(rb"(\\\\newcommandx|\\\\global\\\\long\\\\def)(\\\\[a-zA-Z]+)")
tmp = mkstemp()