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 🙏

© 2026 – Pkg Stats / Ryan Hefner

marked-github-footnote

v1.0.0

Published

A lightweight, zero-dependency marked extension that renders GitHub-style footnotes ([^1]) with proper tab and lazy-continuation handling

Readme

marked-github-footnote npm version

A lightweight, zero-dependency marked extension that renders GitHub-style footnotes ([^1]) the way GitHub actually does.

Instead of grabbing footnote bodies with a single regex and patching the output with string heuristics, it scans definitions line by line the way marked's own list tokenizer does. That buys correct handling of the cases other footnote extensions get wrong:

  • Tab-indented continuation lines stay inside the footnote (tabs expand to 4-column stops, per CommonMark)
  • Lazy paragraph continuation joins the footnote paragraph, and headings/fences/lists correctly interrupt it
  • Multi-block bodies (paragraphs, lists, fenced code with blank lines) are de-indented and handed to the block lexer whole — no last-line guessing
  • Labels never reach HTML attributes unencoded — no attribute-injection XSS via [^label]
  • Footnotes are numbered and ordered by first reference, labels match case-insensitively, unreferenced definitions are omitted — all GitHub behavior

Installation

npm install marked-github-footnote

Requires marked >= 12.

Usage

import { marked } from "marked";
import { markedGithubFootnote } from "marked-github-footnote";

marked.use(markedGithubFootnote());

const html = marked.parse(markdown);

Given this Markdown:

Here is a footnote reference[^1], and another[^long].

[^1]: The first footnote.

[^long]: A footnote with multiple lines.

    Indented lines belong to the same footnote.

    - even lists
    - work here

You get this HTML:

<p>
  Here is a footnote reference<sup
    ><a
      href="#fn-1"
      id="fnref-1"
      data-footnote-ref
      aria-describedby="footnote-label"
      >1</a
    ></sup
  >, and another<sup
    ><a
      href="#fn-long"
      id="fnref-long"
      data-footnote-ref
      aria-describedby="footnote-label"
      >2</a
    ></sup
  >.
</p>
<section data-footnotes role="doc-endnotes">
  <h2 class="sr-only" id="footnote-label">Footnotes</h2>
  <ol>
    <li id="fn-1">
      <p>
        The first footnote.
        <a
          href="#fnref-1"
          data-footnote-backref
          aria-label="Back to reference 1"
          >↩</a
        >
      </p>
    </li>
    <li id="fn-long">
      <p>A footnote with multiple lines.</p>
      <p>Indented lines belong to the same footnote.</p>
      <ul>
        <li>even lists</li>
        <li>work here</li>
      </ul>
      <a
        href="#fnref-long"
        data-footnote-backref
        aria-label="Back to reference 2"
        >↩</a
      >
    </li>
  </ol>
</section>

Options

| Option | Default | Description | | -------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | | prefixId | "" | Prepended to every generated id. Use "user-content-" to reproduce GitHub's ids verbatim. | | heading | "Footnotes" | Text of the visually hidden footnotes section heading. | | backRefLabel | "Back to reference {0}{1}" | aria-label template for back-reference links. {0} is the reference number, {1} is the suffix (e.g. "-2"). Supports i18n. |

Why this instead of marked-footnote?

marked-footnote is the official marked extension for footnotes. marked-github-footnote differs in several important ways:

  • Correct tab expansion: Tabs expand to 4-column stops per CommonMark, not simply replaced with 4 spaces. A tab at column 2 only advances to column 4 — that should not count as a 4-space indent. marked-footnote gets this wrong.
  • Lazy paragraph continuation: Blank lines between paragraphs inside a footnote definition are preserved, and unindented text continues the paragraph. marked-footnote has no support for this.
  • Paragraph interruption detection: Headings, fences, blockquotes, lists, and HTML blocks correctly break footnote definitions. marked-footnote does not detect these.
  • Case-insensitive labels: [^Note] matches [^note]: ..., like GitHub. marked-footnote is case-sensitive.
  • First-reference ordering: Footnotes are numbered by first appearance in text, not definition order. marked-footnote uses definition order.
  • Labels never become HTML text: Labels only appear in URL-encoded attributes, reducing XSS surface. marked-footnote can render raw label text.

If you need GitHub-fidelity footnotes, use marked-github-footnote. If you need more configuration options (custom CSS classes, <hr> divider, bracket markers like [1]), use marked-footnote.

License

MIT