npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@amanda-mitchell/remark-renumber-footnotes

v3.0.0

Published

A remark-parse plugin that renumbers footnotes sequentially.

Downloads

38

Readme

@amanda-mitchell/remark-renumber-footnotes

This is a remark-parse plugin that renumbers footnotes so that they're always sequential in order of when the reference first appears in the document.

Installation

yarn add @amanda-mitchell/remark-renumber-footnotes

Use

Construct a unified parser and pass renumberFootnotes to it as a plugin:

const unified = require('unified');
const markdown = require('remark-parse');
const remarkGfm = require('remark-gfm');
const {
  renumberFootnotes,
} = require('@amanda-mitchell/remark-renumber-footnotes');
const html = require('remark-html');

const doc = `[^1]: Second

This is a document[^2] with[^2] a couple[^1] of footnotes[^foo].

[^foo]: Last item

[^2]:	First
`;

const processor = unified()
	.use(markdown)
	.use(remarkGfm)
	.use(renumberFootnotes)
	.use(html)
	.freeze();

processor.process(doc).then({ contents } => console.log(contents))

When run, this script will print

<p>This is a document<sup><a href="#user-content-fn-1" id="user-content-user-content-fnref-1" data-footnote-ref aria-describedby="user-content-footnote-label">1</a></sup> with<sup><a href="#user-content-fn-1" id="user-content-user-content-fnref-1-2" data-footnote-ref aria-describedby="user-content-footnote-label">1</a></sup> a couple<sup><a href="#user-content-fn-2" id="user-content-user-content-fnref-2" data-footnote-ref aria-describedby="user-content-footnote-label">2</a></sup> of footnotes<sup><a href="#user-content-fn-3" id="user-content-user-content-fnref-3" data-footnote-ref aria-describedby="user-content-footnote-label">3</a></sup>.</p>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="user-content-footnote-label">Footnotes</h2>
<ol>
<li id="user-content-user-content-fn-1">
<p>First <a href="#user-content-fnref-1" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a> <a href="#user-content-fnref-1-2" data-footnote-backref="" aria-label="Back to reference 1-2" class="data-footnote-backref">↩<sup>2</sup></a></p>
</li>
<li id="user-content-user-content-fn-2">
<p>Second <a href="#user-content-fnref-2" data-footnote-backref="" aria-label="Back to reference 2" class="data-footnote-backref">↩</a></p>
</li>
<li id="user-content-user-content-fn-3">
<p>Last item <a href="#user-content-fnref-3" data-footnote-backref="" aria-label="Back to reference 3" class="data-footnote-backref">↩</a></p>
</li>
</ol>
</section>

Options

By default, this plugin will modify footnotes with non-numeric identifiers. If you would like to disable this behavior you can pass

{ ignoreNonnumericFootnotes: true }

As the options for this plugin.