comark-footnotes
v0.11.0
Published
Footnotes in Comark: [^1] references, [^1]: definitions over several lines and blocks, and ^[inline notes], in place of comark/plugins/footnotes.
Maintainers
Readme
comark-footnotes
Footnotes in Comark, in place of comark/plugins/footnotes: [^1] references, [^1]: definitions that hold any Markdown over several lines and blocks, and ^[inline notes]. A parse plugin with no components, so it works in any renderer.
pnpm add comark comark-footnotesimport { parseMarkdown } from "comark";
import footnotes from "comark-footnotes";
const document = await parseMarkdown(markdown, {
plugins: [footnotes()],
});The deploy waits when the roof holds more than 12 pigeons[^count], unless it's a hotfix^[Two approvals.].
[^count]: Counted once, from the window,
at 9:00.
Pigeons that fly off mid-count still count.Notes are numbered in the order they're first referenced and listed in a section at the end. It takes the same options as Comark's plugin (label, hr, backRef) and writes the same nodes. Remove comark/plugins/footnotes when you add this one.
Compared with Comark's plugin, a definition inside fenced code stays in the code, Markdown in a note renders, and a note can run over several lines and blocks. A reference used twice gets its own id, fnref-label-2.
Issues
A reference with no definition stays as text, and a definition nothing references is dropped. Each adds a sentence to meta.issues:
footnotes: [^gone] has no definition; add a "[^gone]: …" line, or remove the reference.
footnotes: [^spare]: is never referenced; add [^spare] where it applies, or remove the definition.Credits
The parser is ported from markdown-it-footnote by Vitaly Puzrin and Alex Kocharin, MIT.
