- Notifications
You must be signed in to change notification settings - Fork 440
footnotes
David D Lowe edited this page Apr 27, 2017 · 4 revisions
The footnotes
extra provides support for footnotes with the following syntax:
This is a paragraph with a footnote. [^note-id] [^note-id]: This is the text of the note.
Which produces HTML like this:
<p>This is a paragraph with a footnote. <sup class="footnote-ref" id="fnref-note-id"> <a href="#fn-note-id">1</a></sup> </p> ... <div class="footnotes"> <hr /> <ol> <li id="fn-note-id"> <p>This is the text of the note. <a href="#fnref-note-id" class="footnoteBackLink" title="Jump back to footnote 1 in the text.">↩</a></p> </li> <li>...for subsequent footnotes </li> </ol> </div>
This is as close as I can tell is the favoured output from the following sources:
- http://daringfireball.net/2005/07/footnotes
- http://six.pairlist.net/pipermail/markdown-discuss/2005-August/001442.html
- http://six.pairlist.net/pipermail/markdown-discuss/2005-August/001480.html
- I couldn't tell from the markdown-discuss discussion on footnotes whether John Gruber meant that the current date was added as a suffix to the anchors in his private Markdown.pl or whether he was literally putting in the "YYYY-MM-DD" strings in his markdown text.
- Daringfireball.net (John Gruber's) site uses the "footnoteBackLink" class on the backref
<a>
. Also, he does not add theclass="footnote-ref"
on<sup>
. Neither of these jive with what was described here. - Add hooks/variables on the
Markdown
class to allow easy tweaking of this output above.
Patch partly from Adam Gomaa (thanks Adam!).
The parameters footnote_title
and footnote_return_symbol
can be used to customise the title attribute of the return link in the footnote, and the contents of that link, respectively. This is especially useful for internationalisation.
html = markdown2.markdown(input, extras=["footnotes"], footnote_title="Jump back to footnote %d in the text.", footnote_return_symbol="↩") markdown = Markdown(extras=["footnotes"], footnote_title="Jump back to footnote %d in the text.", footnote_return_symbol="↩")
Both of these parameters are optional. If footnote_title
is specified, it must contain %d
. Both of these parameters will be included in the final HTML unescaped after string formatting to replace %d
with the number of the footnote.
(Return to Extras page.)