aboutsummaryrefslogtreecommitdiffstats
path: root/markdown/extensions
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2012-08-09 06:15:17 -0400
committerWaylan Limberg <waylan@gmail.com>2012-08-09 06:32:49 -0400
commit2fe5b5b5803c138f70e5c90aaa77f85f3c596f1d (patch)
tree6038a53672fa46a4b281b1f848128c832396163f /markdown/extensions
parentb2939d19260aca2a308e2ff5f135d36e5bdecc60 (diff)
downloadmarkdown-2fe5b5b5803c138f70e5c90aaa77f85f3c596f1d.tar.gz
markdown-2fe5b5b5803c138f70e5c90aaa77f85f3c596f1d.tar.bz2
markdown-2fe5b5b5803c138f70e5c90aaa77f85f3c596f1d.zip
Fixed #129. Footnotes now output valid HTML5.
As HTML5 has depreciated use of `rev=anything` and `rel=footnotes`, they are no longer inlcuded in the output when the output_format is set to HTML5. Note that if someone successful registers a spec for `rel=footnotes` in the future (as a microformat), then that could be considered valid. But until that happens, it is invlaid to use in HTML5. Therefore, we remove it from the output (when outputing HTML% only). As an alternative, two new classes are set (in all output_formats). On the link to the footnote (where `rel=footnotes` was used), we set `class=footnote-ref` and on the backlink (where `rev=footnote` was used), we set `class=footnote-backref`. Also updated the tests to reflect to the new classes in the output.
Diffstat (limited to 'markdown/extensions')
-rw-r--r--markdown/extensions/footnotes.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/markdown/extensions/footnotes.py b/markdown/extensions/footnotes.py
index 3d83807..cfe41ed 100644
--- a/markdown/extensions/footnotes.py
+++ b/markdown/extensions/footnotes.py
@@ -61,6 +61,7 @@ class FootnoteExtension(markdown.Extension):
""" Add pieces to Markdown. """
md.registerExtension(self)
self.parser = md.parser
+ self.md = md
# Insert a preprocessor before ReferencePreprocessor
md.preprocessors.add("footnote", FootnotePreprocessor(self),
"<reference")
@@ -133,7 +134,9 @@ class FootnoteExtension(markdown.Extension):
self.parser.parseChunk(li, self.footnotes[id])
backlink = etree.Element("a")
backlink.set("href", "#" + self.makeFootnoteRefId(id))
- backlink.set("rev", "footnote")
+ if self.md.output_format not in ['html5', 'xhtml5']:
+ backlink.set("rev", "footnote") # Invalid in HTML5
+ backlink.set("class", "footnote-backref")
backlink.set("title", "Jump back to footnote %d in the text" % \
(self.footnotes.index(id)+1))
backlink.text = FN_BACKLINK_TEXT
@@ -255,7 +258,9 @@ class FootnotePattern(markdown.inlinepatterns.Pattern):
a = etree.SubElement(sup, "a")
sup.set('id', self.footnotes.makeFootnoteRefId(id))
a.set('href', '#' + self.footnotes.makeFootnoteId(id))
- a.set('rel', 'footnote')
+ if self.footnotes.md.output_format not in ['html5', 'xhtml5']:
+ a.set('rel', 'footnote') # invalid in HTML5
+ a.set('class', 'footnote-ref')
a.text = unicode(self.footnotes.footnotes.index(id) + 1)
return sup
else: