Need private packages and team management tools?Check out npm Teams »

remark-numbered-footnotes

2.0.0 • Public • Published

This plugin replaces the footnote references with a number sequence (starting from 1) in the same order as the footnote definitions (not the footnote references).

Reordering the definitions (usually put at the end of the document in the Markdown source) will therefore let you reorder the sequence.

This is useful if you want your footnotes to be superscript numbers without having to manually enter them while keeping the benefit of using strings that make sense to you in your Markdown source.

Warning

If you are using this plugin, your project is most certainly relying on mdast-util-to-hast. Run npm ls mdast-util-to-hast if you're unsure. Starting from mdast-util-to-hast@6.0.0, the footnote order changed. Before 6.0.0, footnotes were following the order in which they were defined, starting from 6.0.0 they follow the order of the references.

a[^first_footnote_reference]
 
b[^`b` second footnote reference but first footnote definition]
 
c[^last_footnote_reference]
 
[^last_footnote_reference]: `c` last footnote reference but second footnote definition
[^first_footnote_reference]: `a` first footnote reference but last footnote definition

Before 6.0.0:

image

After 6.0.0:

image

In the HTML ordered list, the list items 1/2/3 don't match the footnote references numbers anymore.

To avoid this issue you can either use older versions of your dependencies (not recommended) or visit the HAST tree after mdast-util-to-hast to fix the footnote orders (recommended). Here is an example. This way the above markdown will always generate HTML with matching footnote list items and footnote numbered references as can be seen below:

image

Keywords

Install

npm i remark-numbered-footnotes

DownloadsWeekly Downloads

1,685

Version

2.0.0

License

MIT

Unpacked Size

7.44 kB

Total Files

5

Last publish

Collaborators

  • avatar
  • avatar