v2.0.1

Footnotes

Last updated


This page covers footnote references and definitions, the numbering rule, multi-line definitions and unresolved references.

Syntax


SyntaxNotes
text[^1], text[^note]Reference; the id can be a number or a word and is case-insensitive
[^1]: contentDefinition, checked at the top level only; the content accepts inline formatting and can reference other footnotes
Indented line after a definitionBelongs to the same footnote and can continue over several paragraphs
Unindented text after a definitionJoins the same paragraph until another block starts

Output


CaseResult
Reference with a definition<sup class="md-footnote-ref"> linking to #md-fn-{index}
Numbering1, 2, 3... by first reference; referencing the same footnote again reuses its number
Footnote sectionA <section class="md-footnotes"> at the end, each item with id="md-fn-{index}"
Reference without a definitionOutput as the literal [^id] text
Definition that is never referencedNot output
[^1] inside code or escapedNot treated as a reference

Examples


Footnotes


Numbered and named footnotes, repeated and case-insensitive references, undefined references, footnotes in footnotes and unused definitions.
  1. <div id="out" class="nanomd"></div>
  2. <script type="text/markdown" id="md">
  3. Footnotes: first[^1], named[^note], again[^1], different case[^NOTE], undefined[^missing], not in code `[^1]`, escaped \[^1]
  4. [^note]: Named footnote content with **bold**, referencing another footnote[^nested]
  5. Indented second paragraph
  6. [^1]: First footnote content
  7. continuing the same paragraph
  8. [^nested]: A footnote referenced from a footnote
  9. [^unused]: Unreferenced footnotes are not output
  10. </script>
  11. <script>
  12. const out = document.getElementById("out");
  13. out.innerHTML = MDParser.Parse(document.getElementById("md").textContent).html();
  14. MDParser.Refresh(out);
  15. </script>
Live preview · @pardnchiu/nanomd@2.0.1
中文