From 25eeace738c873c6e3e30efde25e33b55bd97355 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Thu, 4 Nov 2010 22:21:19 -0400 Subject: Fixed a few inline issues found from running the currenlty skipped tests from tests/pl/Tests_2007/. Namely, improved simple reference links and fixed a small issue with titles in links. --- markdown/inlinepatterns.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/markdown/inlinepatterns.py b/markdown/inlinepatterns.py index 793ad1e..1398b80 100644 --- a/markdown/inlinepatterns.py +++ b/markdown/inlinepatterns.py @@ -103,13 +103,13 @@ STRONG_EM_RE = r'(\*{3}|_{3})(.+?)\2' # ***strong*** SMART_EMPHASIS_RE = r'(?|((?:(?:\(.*?\))|[^\(\)]))*?)\s*((['"])(.*?)\12)?\)''' -# [text](url) or [text]() +r'''\(\s*(<.*?>|((?:(?:\(.*?\))|[^\(\)]))*?)\s*((['"])(.*?)\12\s*)?\)''' +# [text](url) or [text]() or [text](url "title") IMAGE_LINK_RE = r'\!' + BRK + r'\s*\((<.*?>|([^\)]*))\)' # ![alttxt](http://x.com/) or ![alttxt]() REFERENCE_RE = NOIMG + BRK+ r'\s*\[([^\]]*)\]' # [Google][3] -SHORT_REF_RE = NOIMG + BRK # [Google] +SHORT_REF_RE = NOIMG + r'\[([^\]]+)\]' # [Google] IMAGE_REFERENCE_RE = r'\!' + BRK + '\s*\[([^\]]*)\]' # ![alt text][2] NOT_STRONG_RE = r'((^| )(\*|_)( |$))' # stand-alone * or _ AUTOLINK_RE = r'<((?:f|ht)tps?://[^>]*)>' # @@ -256,7 +256,7 @@ class LinkPattern(Pattern): def handleMatch(self, m): el = util.etree.Element("a") el.text = m.group(2) - title = m.group(11) + title = m.group(13) href = m.group(9) if href: @@ -332,10 +332,12 @@ class ReferencePattern(LinkPattern): NEWLINE_CLEANUP_RE = re.compile(r'[ ]?\n', re.MULTILINE) def handleMatch(self, m): - if m.group(9): + try: id = m.group(9).lower() - else: - # if we got something like "[Google][]" + except IndexError: + id = None + if not id: + # if we got something like "[Google][]" or "[Goggle]" # we'll use "google" as the id id = m.group(2).lower() -- cgit v1.2.3