Skip to content
David D Lowe edited this page Apr 27, 2017 · 4 revisions

footnotes extra

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.&nbsp;
<a href="#fnref-note-id" class="footnoteBackLink" title="Jump back to footnote 1 in the text.">&#8617;</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:

Notes:

  • 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 the class="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!).

Configuration:

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="&#8617;")

markdown = Markdown(extras=["footnotes"], footnote_title="Jump back to footnote %d in the text.", footnote_return_symbol="&#8617;")

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.

(Return to Extras page.)

Clone this wiki locally