diff options
-rw-r--r-- | markdown/inlinepatterns.py | 12 | ||||
-rw-r--r-- | tests/misc/em_strong.html | 10 | ||||
-rw-r--r-- | tests/misc/em_strong.txt | 20 |
3 files changed, 36 insertions, 6 deletions
diff --git a/markdown/inlinepatterns.py b/markdown/inlinepatterns.py index 89fa3b2..5e14067 100644 --- a/markdown/inlinepatterns.py +++ b/markdown/inlinepatterns.py @@ -64,14 +64,14 @@ NOIMG = r'(?<!\!)' 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*** +EMPHASIS_RE = r'(\*)([^\*]+)\2' # *emphasis* +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'(?<!\S)(_)(\S.+?)\2' # _emphasis_ else: - EMPHASIS_2_RE = r'(_)(.*?)\2' # _emphasis_ + EMPHASIS_2_RE = r'(_)(.+?)\2' # _emphasis_ LINK_RE = NOIMG + BRK + \ r'''\(\s*(<.*?>|((?:(?:\(.*?\))|[^\(\)]))*?)\s*((['"])(.*)\12)?\)''' @@ -81,7 +81,7 @@ IMAGE_LINK_RE = r'\!' + BRK + r'\s*\((<.*?>|([^\)]*))\)' # ![alttxt](http://x.com/) or ![alttxt](<http://x.com/>) REFERENCE_RE = NOIMG + BRK+ r'\s*\[([^\]]*)\]' # [Google][3] IMAGE_REFERENCE_RE = r'\!' + BRK + '\s*\[([^\]]*)\]' # ![alt text][2] -NOT_STRONG_RE = r'( \* )' # stand-alone * or _ +NOT_STRONG_RE = r'((^| )(\*|_)( |$))' # stand-alone * or _ AUTOLINK_RE = r'<((?:f|ht)tps?://[^>]*)>' # <http://www.123.com> AUTOMAIL_RE = r'<([^> \!]*@[^> ]*)>' # <me@example.com> diff --git a/tests/misc/em_strong.html b/tests/misc/em_strong.html new file mode 100644 index 0000000..75c92d8 --- /dev/null +++ b/tests/misc/em_strong.html @@ -0,0 +1,10 @@ +<p>One asterisk: *</p> +<p>One underscore: _</p> +<p>Two asterisks: **</p> +<p>With spaces: * *</p> +<p>Two underscores __</p> +<p>with spaces: _ _</p> +<p>three asterisks: ***</p> +<p>with spaces: * * *</p> +<p>three underscores: ___</p> +<p>with spaces: _ _ _</p>
\ No newline at end of file diff --git a/tests/misc/em_strong.txt b/tests/misc/em_strong.txt new file mode 100644 index 0000000..d0774ad --- /dev/null +++ b/tests/misc/em_strong.txt @@ -0,0 +1,20 @@ +One asterisk: * + +One underscore: _ + +Two asterisks: ** + +With spaces: * * + +Two underscores __ + +with spaces: _ _ + +three asterisks: *** + +with spaces: * * * + +three underscores: ___ + +with spaces: _ _ _ + |