diff options
author | Waylan Limberg <waylan@gmail.com> | 2010-11-04 22:21:19 -0400 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2010-11-04 22:21:19 -0400 |
commit | 25eeace738c873c6e3e30efde25e33b55bd97355 (patch) | |
tree | d5c7daab1b4c6367a661f87d5c5fdd2369378117 | |
parent | 8fb5e4238cd7822b23d041c7bcb915b84b3b1f5e (diff) | |
download | markdown-25eeace738c873c6e3e30efde25e33b55bd97355.tar.gz markdown-25eeace738c873c6e3e30efde25e33b55bd97355.tar.bz2 markdown-25eeace738c873c6e3e30efde25e33b55bd97355.zip |
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.
-rw-r--r-- | markdown/inlinepatterns.py | 16 |
1 files 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'(?<!\w)(_)(\S.+?)\2(?!\w)' # _smart_emphasis_ EMPHASIS_2_RE = r'(_)(.+?)\2' # _emphasis_ LINK_RE = NOIMG + BRK + \ -r'''\(\s*(<.*?>|((?:(?:\(.*?\))|[^\(\)]))*?)\s*((['"])(.*?)\12)?\)''' -# [text](url) or [text](<url>) +r'''\(\s*(<.*?>|((?:(?:\(.*?\))|[^\(\)]))*?)\s*((['"])(.*?)\12\s*)?\)''' +# [text](url) or [text](<url>) or [text](url "title") IMAGE_LINK_RE = r'\!' + BRK + r'\s*\((<.*?>|([^\)]*))\)' # ![alttxt](http://x.com/) or ![alttxt](<http://x.com/>) 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?://[^>]*)>' # <http://www.123.com> @@ -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() |