aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2010-03-25 13:50:13 -0400
committerWaylan Limberg <waylan@gmail.com>2010-03-25 13:50:13 -0400
commit1599e909fd5c7a80f51247d7232c7627693206e6 (patch)
tree13d0ad4279e7123c754ed7b807bed0b819a2bb43
parent834f04b887c15017a2e08bb76f8a269d9ae074a2 (diff)
downloadmarkdown-1599e909fd5c7a80f51247d7232c7627693206e6.tar.gz
markdown-1599e909fd5c7a80f51247d7232c7627693206e6.tar.bz2
markdown-1599e909fd5c7a80f51247d7232c7627693206e6.zip
Fixed ticket 59. Reference links now strip angle brackets from the url.
-rw-r--r--markdown/preprocessors.py5
-rw-r--r--tests/basic/links-reference.html4
-rw-r--r--tests/basic/links-reference.txt8
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 @@
<p>Indented <a href="/url">thrice</a>.</p>
<p>Indented [four][] times.</p>
<pre><code>[four]: /url
-</code></pre> \ No newline at end of file
+</code></pre>
+<p>With <a href="http://example.com/" title="Angle Brackets">angle brackets</a>.</p>
+<p>And <a href="http://example.com/" title="Without angle brackets.">without</a>.</p> \ 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]: <http://example.com/> "Angle Brackets"
+[without]: http://example.com/ "Without angle brackets."
+