Markdown Footnotes

This is a plugin to add footnote functionality to the new object-oriented version of PHP-Markdown. It is bundled as a WordPress plugin; anyone wanting it another a context can remove the plugin cruft easily enough.


View and/or down the plugin here.


Footnotes are awesome, but haven't been included in Markdown for various reasons. I know of at least one other WordPress plugin that adds footnote support, but it didn't fit my requirements. (That is, I hate its syntax with the burning heat of an imploding sun, and would prefer death! death! than a life of torture using it.)


This plugin uses a syntax mentioned on the Markdown mailing list last year. It's similar to that used by reference style links. For specifics, see the syntax document.


There's no one way to represent footnotes on the web. Out-of-the-box this script presents in-text footnote references as:

[<a href="#fn-1" id="fnref-1">1</a>]

And the footnotes themselves as:

<li class="footnote" id="fn-1">
<p>Markdown-ed contents of the footnote: this simple paragraph was
wrapped in a `p` element.</p>
[<a href="#fnref-1">return</a>]

It shouldn't be difficult to change the markup if desired, but it requires editing the source.

A note on uniqueness

The id element is required to be unique on a page; this is problematic if multiple documents can appear on a single page, as with (for example) a blogging system providing a view of several recent entries. To help with this, the footnote id is passed to the footNoteGUID method.

An example for WordPress:

class WP_Markdown_Footnotes extends Markdown_Footnotes {
    // Use the WordPress post id as part of every
    // footnote HTML `id` attribute to preserve uniqueness.
    function footNoteGUID($fn_id) {
        return get_the_ID() . '-' . $fn_id;