Registry / serialization / markdown-it-footnote

markdown-it-footnote

JSON →
library4.0.0jsnpmunverified

This package provides footnote support for the `markdown-it` markdown parser, implementing both standard and inline footnote syntax based on Pandoc's definition. It integrates seamlessly as a `markdown-it` plugin, extending the parser's capabilities to render footnote references and their corresponding definitions into semantic HTML, complete with back-references. The current stable version is 4.0.0. As a plugin for `markdown-it`, its release cycle often aligns with `markdown-it`'s own, though it maintains independent versioning. Its primary differentiator is its robust and spec-compliant implementation of footnotes within the `markdown-it` ecosystem, offering dedicated customization points for the rendered HTML structure, ensuring flexibility for various output requirements.

npm install markdown-it-footnote
INSTALL
IMPORT
SIG · MARKDOWN-IT-FOOTNO
M
markdown-it-footnote
serializationjavascriptv4.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

markdownitFootnote
const markdownitFootnote = require('markdown-it-footnote');
import markdownitFootnote from 'markdown-it-footnote';
This package is primarily distributed as a CommonJS module. While modern bundlers often handle ESM import syntax, direct ESM usage in Node.js environments might require specific transpilation or configuration.
markdownitFootnote (global)
const markdownitFootnote = window.markdownitFootnote;
When loaded directly in a browser via a <script> tag, without a module system (like CommonJS or ES modules), the plugin exposes itself globally as 'window.markdownitFootnote'.

Demonstrates how to initialize `markdown-it` with the footnote plugin and render markdown content containing both standard and inline footnotes.

const markdownit = require('markdown-it'); const markdownitFootnote = require('markdown-it-footnote'); // Initialize markdown-it and apply the footnote plugin const md = markdownit().use(markdownitFootnote); const markdownContent = ` Here is a normal footnote reference,[^1] and another.[^longnote] Here is an inline note.^[Inlines notes are easier to write, since you don't have to pick an identifier and move down to type the note.] [^1]: Here is the footnote. [^longnote]: Here's one with multiple blocks. Subsequent paragraphs are indented to show that they belong to the previous footnote. This paragraph won’t be part of the note, because it isn’t indented. `; // Render the markdown content to HTML const html = md.render(markdownContent); console.log(html);
Debug
Known issues
breakingVersion 2.0.0 and above of `markdown-it-footnote` requires `markdown-it` version 5.0.0 or higher. Older versions of `markdown-it` are incompatible and will cause parsing errors.
fix
Ensure your project uses `markdown-it` v5.0.0 or later. Upgrade `markdown-it` by running `npm install markdown-it@latest`.
affects: >=2.0.0
gotchaCustomizing the HTML output for footnotes requires overriding specific renderer rules on the `markdown-it` instance. Attempting to directly modify plugin internals or using undocumented APIs is not recommended as the API for template functions is tied to `markdown-it`'s internal renderer architecture.
fix
Access and override rules via `md.renderer.rules.<rule_name>` as shown in the package's documentation examples. Refer to the official `markdown-it` documentation for details on its renderer architecture and rule customization.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: md.use is not a function
The `markdown-it` instance has not been correctly initialized, or the `use` method is being called on a non-`markdown-it` object.
fix
Ensure `markdown-it` is imported and instantiated correctly before attempting to use the plugin: `const md = require('markdown-it')();`.
Footnotes not rendering or displaying incorrectly in the HTML output.
This typically indicates incorrect markdown syntax for footnotes or a conflict with another `markdown-it` plugin altering parsing rules.
fix
Verify that your footnote syntax precisely matches the Pandoc definition (e.g., normal footnotes: `[^id]` for reference and `[^id]:` for definition; inline footnotes: `^[note content]`). Temporarily disable other `markdown-it` plugins to identify potential conflicts.
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies
markdown-itrequiredRequired peer dependency as this is a markdown-it plugin.
Agent activity
34 hits · last 30 days
node
34
Resources
markdown-it-footnote — npm install markdown-it-footnote · libregistry