Show More
@@ -19,6 +19,11 b' import re' | |||||
19 | # Globals and constants |
|
19 | # Globals and constants | |
20 | #----------------------------------------------------------------------------- |
|
20 | #----------------------------------------------------------------------------- | |
21 |
|
21 | |||
|
22 | LATEX_RE_SUBS = ( | |||
|
23 | (re.compile('\033\[[0-9;]+m'), ''), # handle console escapes | |||
|
24 | (re.compile(r'\.\.\.+'), r'\\ldots'), | |||
|
25 | ) | |||
|
26 | ||||
22 | # Latex substitutions for escaping latex. |
|
27 | # Latex substitutions for escaping latex. | |
23 | # see: http://stackoverflow.com/questions/16259923/how-can-i-escape-latex-special-characters-inside-django-templates |
|
28 | # see: http://stackoverflow.com/questions/16259923/how-can-i-escape-latex-special-characters-inside-django-templates | |
24 |
|
29 | |||
@@ -52,8 +57,11 b' def escape_latex(text):' | |||||
52 | text : str |
|
57 | text : str | |
53 | Text containing characters that may conflict with Latex |
|
58 | Text containing characters that may conflict with Latex | |
54 | """ |
|
59 | """ | |
|
60 | text = ''.join([LATEX_SUBS.get(c, c) for c in text]) | |||
|
61 | for pattern, replacement in LATEX_RE_SUBS: | |||
|
62 | text = pattern.sub(replacement, text) | |||
55 |
|
63 | |||
56 | return ''.join([LATEX_SUBS.get(c, c) for c in text]) |
|
64 | return text | |
57 |
|
65 | |||
58 |
|
66 | |||
59 | def strip_math_space(text): |
|
67 | def strip_math_space(text): |
General Comments 0
You need to be logged in to leave comments.
Login now