From 8358bb3c569026d9775859bcdbd2611fc9499420 Mon Sep 17 00:00:00 2001
From: Waylan Limberg
Date: Thu, 25 Sep 2014 16:07:07 -0400
Subject: Better nested STRONG EM support.
Fixes #253. Thanks to @facelessuser for the tests. Although I removed
a bunch of weird ones (even some that passed) from his PR (#342). For
the most part, there is no definitive way for those to be parsed. So
there is no point of testing for them. In most of those situations,
authors should be mixing underscores and astericks so it is clear
what is intended.
---
markdown/inlinepatterns.py | 8 ++++++--
tests/misc/em_strong_complex.html | 14 ++++++++++++++
tests/misc/em_strong_complex.txt | 27 +++++++++++++++++++++++++++
3 files changed, 47 insertions(+), 2 deletions(-)
create mode 100644 tests/misc/em_strong_complex.html
create mode 100644 tests/misc/em_strong_complex.txt
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'(?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
+testtest testtest
\ 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
--
cgit v1.2.3