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/toc.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/toc.py')
-rw-r--r-- | markdown/extensions/toc.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/markdown/extensions/toc.py b/markdown/extensions/toc.py index 2c4a4b5..b222cb4 100644 --- a/markdown/extensions/toc.py +++ b/markdown/extensions/toc.py @@ -25,8 +25,8 @@ import unicodedata def slugify(value, separator): """ Slugify a string, to make it URL friendly. """ value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore') - value = re.sub('[^\w\s-]', '', value.decode('ascii')).strip().lower() - return re.sub('[%s\s]+' % separator, separator, value) + value = re.sub(r'[^\w\s-]', '', value.decode('ascii')).strip().lower() + return re.sub(r'[%s\s]+' % separator, separator, value) IDCOUNT_RE = re.compile(r'^(.*)_([0-9]+)$') |