manual: Updated escape character regex

Updated the text_escape function to regex escape characters in the
generators escape set. This is for the case when a generators
special character set collides with regex's special character
set.
This commit is contained in:
Adam Felizzi
2018-04-27 14:57:25 +10:00
parent fcff7ee2c4
commit 336b73735f

View File

@@ -57,7 +57,7 @@ class Generator(object):
"""
Return a string with latex special characters escaped
"""
escape_regex = re.compile('|'.join(self.ESCAPE_PATTERNS.keys()))
escape_regex = re.compile(re.escape('|'.join(self.ESCAPE_PATTERNS.keys())))
return escape_regex.sub(lambda p: self.ESCAPE_PATTERNS[p.group()], string)
def get_text(self, soup, escape=True):