aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--markdown/inlinepatterns.py2
-rw-r--r--tests/misc/smart_em.html5
-rw-r--r--tests/misc/smart_em.txt9
3 files changed, 15 insertions, 1 deletions
diff --git a/markdown/inlinepatterns.py b/markdown/inlinepatterns.py
index 331bead..917a9d3 100644
--- a/markdown/inlinepatterns.py
+++ b/markdown/inlinepatterns.py
@@ -69,7 +69,7 @@ STRONG_RE = r'(\*{2}|_{2})(.+?)\2' # **strong**
STRONG_EM_RE = r'(\*{3}|_{3})(.+?)\2' # ***strong***
if markdown.SMART_EMPHASIS:
- EMPHASIS_2_RE = r'(?<!\S)(_)(\S.+?)\2' # _emphasis_
+ EMPHASIS_2_RE = r'(?<!\w)(_)(\S.+?)\2(?!\w)' # _emphasis_
else:
EMPHASIS_2_RE = r'(_)(.+?)\2' # _emphasis_
diff --git a/tests/misc/smart_em.html b/tests/misc/smart_em.html
new file mode 100644
index 0000000..5683b25
--- /dev/null
+++ b/tests/misc/smart_em.html
@@ -0,0 +1,5 @@
+<p><em>emphasis</em></p>
+<p>this_is_not_emphasis</p>
+<p>[<em>punctuation with emphasis</em>]</p>
+<p>[<em>punctuation_with_emphasis</em>]</p>
+<p>[punctuation_without_emphasis]</p> \ No newline at end of file
diff --git a/tests/misc/smart_em.txt b/tests/misc/smart_em.txt
new file mode 100644
index 0000000..3c56842
--- /dev/null
+++ b/tests/misc/smart_em.txt
@@ -0,0 +1,9 @@
+_emphasis_
+
+this_is_not_emphasis
+
+[_punctuation with emphasis_]
+
+[_punctuation_with_emphasis_]
+
+[punctuation_without_emphasis]