aboutsummaryrefslogtreecommitdiffstats
path: root/markdown/inlinepatterns.py
diff options
context:
space:
mode:
authorfacelessuser <faceless.shop@gmail.com>2014-11-17 18:36:43 -0700
committerfacelessuser <faceless.shop@gmail.com>2014-11-17 18:36:43 -0700
commit609faad76b80ff10da0e471183ad0cede3221571 (patch)
tree453b010faeff88f8c9f94175b70352a1e8e71876 /markdown/inlinepatterns.py
parentf0357b28ef1723929146eabe6571d7c436c90c34 (diff)
downloadmarkdown-609faad76b80ff10da0e471183ad0cede3221571.tar.gz
markdown-609faad76b80ff10da0e471183ad0cede3221571.tar.bz2
markdown-609faad76b80ff10da0e471183ad0cede3221571.zip
Issue #365 Bold/Italic nesting fix
The logic for the current regex for strong/em and em/strong was sound, but the way it was implemented caused some unintended side effects. Whether it is a quirk with regex in general or just with Python’s re engine, I am not sure. Put basically `(\*|_){3}` causes issues with nested bold/italic. So, allowing the group to be defined, and then using the group number to specify the remaining sequential chars is a better way that works more reliably `(\*|_)\2{2}. Test from issue #365 was also added to check for this case in the future.
Diffstat (limited to 'markdown/inlinepatterns.py')
-rw-r--r--markdown/inlinepatterns.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/markdown/inlinepatterns.py b/markdown/inlinepatterns.py
index b63bc8c..c9d82fd 100644
--- a/markdown/inlinepatterns.py
+++ b/markdown/inlinepatterns.py
@@ -101,8 +101,8 @@ BACKTICK_RE = r'(?<!\\)(`+)(.+?)(?<!`)\2(?!`)' # `e=f()` or ``e=f("`")``
ESCAPE_RE = r'\\(.)' # \<
EMPHASIS_RE = r'(\*)([^\*]+)\2' # *emphasis*
STRONG_RE = r'(\*{2}|_{2})(.+?)\2' # **strong**
-EM_STRONG_RE = r'(\*|_){3}(.+?)\2(.*?)\2{2}' # ***strongem*** or ***em*strong**
-STRONG_EM_RE = r'(\*|_){3}(.+?)\2{2}(.*?)\2' # ***strong**em*
+EM_STRONG_RE = r'(\*|_)\2{2}(.+?)\2(.*?)\2{2}' # ***strongem*** or ***em*strong**
+STRONG_EM_RE = r'(\*|_)\2{2}(.+?)\2{2}(.*?)\2' # ***strong**em*
SMART_EMPHASIS_RE = r'(?<!\w)(_)(?!_)(.+?)(?<!_)\2(?!\w)' # _smart_emphasis_
EMPHASIS_2_RE = r'(_)(.+?)\2' # _emphasis_
LINK_RE = NOIMG + BRK + \