diff options
author | Waylan Limberg <waylan@gmail.com> | 2010-08-25 11:06:17 -0400 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2010-08-25 11:06:17 -0400 |
commit | 5ee12763465d123a313d43fc0fb497636f727d34 (patch) | |
tree | d758f37eef3fa689cbc3c31af72a0f71bbb7d500 /markdown/extensions | |
parent | 45e77f48b380c97ff07f050a4a1b9041a0784050 (diff) | |
download | markdown-5ee12763465d123a313d43fc0fb497636f727d34.tar.gz markdown-5ee12763465d123a313d43fc0fb497636f727d34.tar.bz2 markdown-5ee12763465d123a313d43fc0fb497636f727d34.zip |
Fixed Ticket 70 and added a test. Footnote references whithout a coresponding definition no longer raise an error. They now pass through as plain text - which is the same behavior as PHP Markdown Extra. Thanks for the report Benjamin Bach.
Diffstat (limited to 'markdown/extensions')
-rw-r--r-- | markdown/extensions/footnotes.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/markdown/extensions/footnotes.py b/markdown/extensions/footnotes.py index 2bdabe9..644e89f 100644 --- a/markdown/extensions/footnotes.py +++ b/markdown/extensions/footnotes.py @@ -261,14 +261,17 @@ class FootnotePattern(markdown.inlinepatterns.Pattern): self.footnotes = footnotes def handleMatch(self, m): - sup = etree.Element("sup") - a = etree.SubElement(sup, "a") id = m.group(2) - sup.set('id', self.footnotes.makeFootnoteRefId(id)) - a.set('href', '#' + self.footnotes.makeFootnoteId(id)) - a.set('rel', 'footnote') - a.text = str(self.footnotes.footnotes.index(id) + 1) - return sup + if id in self.footnotes.footnotes.keys(): + sup = etree.Element("sup") + a = etree.SubElement(sup, "a") + sup.set('id', self.footnotes.makeFootnoteRefId(id)) + a.set('href', '#' + self.footnotes.makeFootnoteId(id)) + a.set('rel', 'footnote') + a.text = unicode(self.footnotes.footnotes.index(id) + 1) + return sup + else: + return None class FootnoteTreeprocessor(markdown.treeprocessors.Treeprocessor): |