diff options
author | facelessuser <faceless.shop@gmail.com> | 2017-12-20 17:54:23 -0700 |
---|---|---|
committer | facelessuser <faceless.shop@gmail.com> | 2017-12-20 17:54:23 -0700 |
commit | e6fd29f3b49be58c94d8627e3aaa5b97b009c053 (patch) | |
tree | afe7f7cfa9c56c156674a02623f93539abca8db0 /markdown/extensions/smarty.py | |
parent | 1edbb9dcb998966e43e02f5e345fe3d08c0307dc (diff) | |
download | python-markdown-regex-fixes.tar.gz |
Make sure regex patterns are raw stringsregex-fixes
Python 3.6 is starting to reject invalid escapes. Regular expression patterns should be raw strings to avoid having regex escapes being mistaken for invalid string escapes. Ref #611.
Diffstat (limited to 'markdown/extensions/smarty.py')
-rw-r--r-- | markdown/extensions/smarty.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/markdown/extensions/smarty.py b/markdown/extensions/smarty.py index 5031bc4..c2af7cd 100644 --- a/markdown/extensions/smarty.py +++ b/markdown/extensions/smarty.py @@ -91,16 +91,16 @@ from ..treeprocessors import InlineProcessor # Constants for quote education. punctClass = r"""[!"#\$\%'()*+,-.\/:;<=>?\@\[\\\]\^_`{|}~]""" endOfWordClass = r"[\s.,;:!?)]" -closeClass = "[^\ \t\r\n\[\{\(\-\u0002\u0003]" +closeClass = r"[^\ \t\r\n\[\{\(\-\u0002\u0003]" openingQuotesBase = ( - '(\s' # a whitespace char - '| ' # or a non-breaking space entity - '|--' # or dashes - '|–|—' # or unicode - '|&[mn]dash;' # or named dash entities - '|–|—' # or decimal entities - ')' + r'(\s' # a whitespace char + r'| ' # or a non-breaking space entity + r'|--' # or dashes + r'|–|—' # or unicode + r'|&[mn]dash;' # or named dash entities + r'|–|—' # or decimal entities + r')' ) substitutions = { @@ -144,8 +144,8 @@ closingSingleQuotesRegex = r"(?<=%s)'(?!\s|s\b|\d)" % closeClass closingSingleQuotesRegex2 = r"(?<=%s)'(\s|s\b)" % closeClass # All remaining quotes should be opening ones -remainingSingleQuotesRegex = "'" -remainingDoubleQuotesRegex = '"' +remainingSingleQuotesRegex = r"'" +remainingDoubleQuotesRegex = r'"' HTML_STRICT_RE = HTML_RE + r'(?!\>)' |