aboutsummaryrefslogtreecommitdiffstats
path: root/markdown/inlinepatterns.py
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2009-03-30 22:48:25 -0400
committerWaylan Limberg <waylan@gmail.com>2009-03-30 22:48:25 -0400
commit6d972b91d30d6e314fee111354b98ed4130eebe6 (patch)
treecbe5800850ec9d4ca8e679c0868bfe2a0af11752 /markdown/inlinepatterns.py
parentc84c8280cd71aef3191529ba286ebe85714365b2 (diff)
downloadmarkdown-6d972b91d30d6e314fee111354b98ed4130eebe6.tar.gz
markdown-6d972b91d30d6e314fee111354b98ed4130eebe6.tar.bz2
markdown-6d972b91d30d6e314fee111354b98ed4130eebe6.zip
Improved inline pattern regex for em & strong and added tests. Fixes Ticket 30 and other related issues. Note that I went with php's behavior rather than perl's when we have have three (ie.: *** or ___) without a closing three.
Diffstat (limited to 'markdown/inlinepatterns.py')
-rw-r--r--markdown/inlinepatterns.py12
1 files changed, 6 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>