summaryrefslogtreecommitdiff
path: root/markdown/inlinepatterns.py
diff options
context:
space:
mode:
authorWaylan Limberg <waylan.limberg@icloud.com>2022-11-14 14:26:27 -0500
committerWaylan Limberg <waylan.limberg@icloud.com>2022-11-15 11:55:37 -0500
commit939a2fe70580c8e6b7e10af82ebdd6c8c72e019a (patch)
treece92d886eac0f519ba8418d93071167f44a5605b /markdown/inlinepatterns.py
parente97ffebc9d22f6dc84087caaf11978d4548c617c (diff)
downloadpython-markdown-939a2fe70580c8e6b7e10af82ebdd6c8c72e019a.tar.gz
Improve standalone * and _ parsing.
The `NOT_STRONG_RE` regex matchs 1, 2, or 3 * or _ which are surrounded by white space to prevent them from being parsed as tokens. However, the surrounding white space should not be consumed by the regex, which is why lookhead and lookbehind assertions are used. As `^` cannot be matched in a lookbehind assertion, it is left outside the assertion, but as it is zero length, that should not matter. Tests added and/or updated to cover various edge cases. Fixes #1300.
Diffstat (limited to 'markdown/inlinepatterns.py')
-rw-r--r--markdown/inlinepatterns.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/markdown/inlinepatterns.py b/markdown/inlinepatterns.py
index eb313bd..0bd129c 100644
--- a/markdown/inlinepatterns.py
+++ b/markdown/inlinepatterns.py
@@ -154,7 +154,7 @@ REFERENCE_RE = LINK_RE
IMAGE_REFERENCE_RE = IMAGE_LINK_RE
# stand-alone * or _
-NOT_STRONG_RE = r'((^|\s)(\*|_)(\s|$))'
+NOT_STRONG_RE = r'((^|(?<=\s))(\*{1,3}|_{1,3})(?=\s|$))'
# <http://www.123.com>
AUTOLINK_RE = r'<((?:[Ff]|[Hh][Tt])[Tt][Pp][Ss]?://[^<>]*)>'