From 1599e909fd5c7a80f51247d7232c7627693206e6 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Thu, 25 Mar 2010 13:50:13 -0400 Subject: Fixed ticket 59. Reference links now strip angle brackets from the url. --- markdown/preprocessors.py | 5 +++-- tests/basic/links-reference.html | 4 +++- tests/basic/links-reference.txt | 8 ++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/markdown/preprocessors.py b/markdown/preprocessors.py index b199f0a..3fabcf2 100644 --- a/markdown/preprocessors.py +++ b/markdown/preprocessors.py @@ -275,14 +275,15 @@ class ReferencePreprocessor(Preprocessor): m = self.RE.match(line) if m: id = m.group(2).strip().lower() + link = m.group(3).lstrip('<').rstrip('>') t = m.group(4).strip() # potential title if not t: - self.markdown.references[id] = (m.group(3), t) + self.markdown.references[id] = (link, t) elif (len(t) >= 2 and (t[0] == t[-1] == "\"" or t[0] == t[-1] == "\'" or (t[0] == "(" and t[-1] == ")") ) ): - self.markdown.references[id] = (m.group(3), t[1:-1]) + self.markdown.references[id] = (link, t[1:-1]) else: new_text.append(line) else: diff --git a/tests/basic/links-reference.html b/tests/basic/links-reference.html index 165c71a..9780bf3 100644 --- a/tests/basic/links-reference.html +++ b/tests/basic/links-reference.html @@ -7,4 +7,6 @@

Indented thrice.

Indented [four][] times.

[four]: /url
-
\ No newline at end of file + +

With angle brackets.

+

And without.

\ No newline at end of file diff --git a/tests/basic/links-reference.txt b/tests/basic/links-reference.txt index b2fa734..9993b10 100644 --- a/tests/basic/links-reference.txt +++ b/tests/basic/links-reference.txt @@ -29,3 +29,11 @@ Indented [four][] times. [b]: /url/ + +With [angle brackets][]. + +And [without][]. + +[angle brackets]: "Angle Brackets" +[without]: http://example.com/ "Without angle brackets." + -- cgit v1.2.3