aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--markdown/inlinepatterns.py8
-rw-r--r--tests/misc/em_strong_complex.html14
-rw-r--r--tests/misc/em_strong_complex.txt27
3 files changed, 47 insertions, 2 deletions
diff --git a/markdown/inlinepatterns.py b/markdown/inlinepatterns.py
index e990418..b63bc8c 100644
--- a/markdown/inlinepatterns.py
+++ b/markdown/inlinepatterns.py
@@ -75,7 +75,8 @@ def build_inlinepatterns(md_instance, **kwargs):
inlinePatterns["html"] = HtmlPattern(HTML_RE, md_instance)
inlinePatterns["entity"] = HtmlPattern(ENTITY_RE, md_instance)
inlinePatterns["not_strong"] = SimpleTextPattern(NOT_STRONG_RE)
- inlinePatterns["strong_em"] = DoubleTagPattern(STRONG_EM_RE, 'strong,em')
+ inlinePatterns["em_strong"] = DoubleTagPattern(EM_STRONG_RE, 'strong,em')
+ inlinePatterns["strong_em"] = DoubleTagPattern(STRONG_EM_RE, 'em,strong')
inlinePatterns["strong"] = SimpleTagPattern(STRONG_RE, 'strong')
inlinePatterns["emphasis"] = SimpleTagPattern(EMPHASIS_RE, 'em')
if md_instance.smart_emphasis:
@@ -100,7 +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**
-STRONG_EM_RE = r'(\*{3}|_{3})(.+?)\2' # ***strong***
+EM_STRONG_RE = r'(\*|_){3}(.+?)\2(.*?)\2{2}' # ***strongem*** or ***em*strong**
+STRONG_EM_RE = r'(\*|_){3}(.+?)\2{2}(.*?)\2' # ***strong**em*
SMART_EMPHASIS_RE = r'(?<!\w)(_)(?!_)(.+?)(?<!_)\2(?!\w)' # _smart_emphasis_
EMPHASIS_2_RE = r'(_)(.+?)\2' # _emphasis_
LINK_RE = NOIMG + BRK + \
@@ -276,6 +278,8 @@ class DoubleTagPattern(SimpleTagPattern):
el1 = util.etree.Element(tag1)
el2 = util.etree.SubElement(el1, tag2)
el2.text = m.group(3)
+ if len(m.groups())==5:
+ el2.tail = m.group(4)
return el1
diff --git a/tests/misc/em_strong_complex.html b/tests/misc/em_strong_complex.html
new file mode 100644
index 0000000..3befa70
--- /dev/null
+++ b/tests/misc/em_strong_complex.html
@@ -0,0 +1,14 @@
+<p><em><strong>test test</strong> test test</em></p>
+<p><strong><em>test test</em> test test</strong></p>
+<p><strong><em>test</em></strong></p>
+<p><strong>test</strong>_</p>
+<p><strong><em>test</em> test</strong>_</p>
+<p><strong><em>test</em> test</strong></p>
+<p><em>test_test test_test</em></p>
+<p><em><strong>test test</strong> test test</em></p>
+<p><strong><em>test test</em> test test</strong></p>
+<p>*<em>test</em></p>
+<p><strong><em>test</em></strong></p>
+<p><strong>test</strong>*</p>
+<p><strong><em>test</em> test</strong></p>
+<p><em>test</em>test test<em>test</em></p> \ No newline at end of file
diff --git a/tests/misc/em_strong_complex.txt b/tests/misc/em_strong_complex.txt
new file mode 100644
index 0000000..66f4ff1
--- /dev/null
+++ b/tests/misc/em_strong_complex.txt
@@ -0,0 +1,27 @@
+___test test__ test test_
+
+___test test_ test test__
+
+___test___
+
+__test___
+
+___test_ test___
+
+___test_ test__
+
+_test_test test_test_
+
+***test test** test test*
+
+***test test* test test**
+
+**test*
+
+***test***
+
+**test***
+
+***test* test**
+
+*test*test test*test* \ No newline at end of file