From 609faad76b80ff10da0e471183ad0cede3221571 Mon Sep 17 00:00:00 2001 From: facelessuser Date: Mon, 17 Nov 2014 18:36:43 -0700 Subject: Issue #365 Bold/Italic nesting fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- markdown/inlinepatterns.py | 4 ++-- tests/misc/nested-patterns.html | 4 +++- tests/misc/nested-patterns.txt | 4 ++++ 3 files changed, 9 insertions(+), 3 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'(?link link link

-

I am italic and bold I am just bold

\ No newline at end of file +

I am italic and bold I am just bold

+

Example bold italic on the same line bold italic.

+

Example bold italic on the same line bold italic.

\ No newline at end of file diff --git a/tests/misc/nested-patterns.txt b/tests/misc/nested-patterns.txt index e347ccf..9032cf1 100644 --- a/tests/misc/nested-patterns.txt +++ b/tests/misc/nested-patterns.txt @@ -7,3 +7,7 @@ __[*link*](http://example.com)__ [***link***](http://example.com) ***I am ___italic_ and__ bold* I am `just` bold** + +Example __*bold italic*__ on the same line __*bold italic*__. + +Example **_bold italic_** on the same line **_bold italic_**. -- cgit v1.2.3