rlkw1024
rlkw1024

Reputation: 6515

Enable footnotes in Kramdown

Taking the example verbatim from http://kramdown.rubyforge.org/syntax.html#footnotes, I run the following in IRB:

Kramdown::Document.new('This is some text.[^1]. Other text.[^footnote].').to_html

Which returns:

"<p>This is some text.[^1]. Other text.[^footnote].</p>\n"

This seems to indicate that footnotes are disabled in Kramdown by default. How can I enable them? I've looked at the [options documentation] (http://kramdown.rubyforge.org/options.html), but I don't see an option to enable/disable footnotes listed there.

Upvotes: 1

Views: 562

Answers (1)

matt
matt

Reputation: 79743

From the docs you link to:

If there is a footnote definition found for the identifier, a footnote will be created. Otherwise the footnote marker is not converted to a footnote link.

So you need to include the footnote definition, e.g. (there’s a more complete example further down the page in the docs):

This is some text.[^1]. Other text.[^footnote].

[^1]:A footnote.

This produces:

<p>This is some text.<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>. Other text.[^footnote].</p>

<div class="footnotes">
  <ol>
    <li id="fn:1">
      <p>A footnote.<a href="#fnref:1" rel="reference">&#8617;</a></p>
    </li>
  </ol>
</div>

Note that the footnote for [^1] is generated since it has been defined, but [^footnote] is left as it is.

Upvotes: 5

Related Questions