Native HTML popover footnotes for markdown-it markdown parser. Based on markdown-it-footnote.
  • TypeScript 75.6%
  • HTML 24.4%
Find a file
2026-08-06 16:59:03 -05:00
src feat: replace links to a footnote section with native html popovers 2026-08-06 16:43:27 -05:00
test feat: replace links to a footnote section with native html popovers 2026-08-06 16:43:27 -05:00
.gitignore Initial commit 2026-07-22 13:54:59 +00:00
.nvmrc Initial commit 2026-07-22 13:54:59 +00:00
CHANGELOG.md chore(release): 1.0.0 2026-08-06 16:47:57 -05:00
eslint.config.ts Initial commit 2026-07-22 13:54:59 +00:00
LICENSE refactor: modularize and rewrite markdown-it-footnote in typescript 2026-07-26 17:07:29 -05:00
package.json feat: replace links to a footnote section with native html popovers 2026-08-06 16:43:27 -05:00
pnpm-lock.yaml refactor: modularize and rewrite markdown-it-footnote in typescript 2026-07-26 17:07:29 -05:00
README.md feat: replace links to a footnote section with native html popovers 2026-08-06 16:43:27 -05:00
styling-sample.html docs: fixes a minor CSS issue in the styling sample 2026-08-06 16:59:03 -05:00
tsconfig.build.json Initial commit 2026-07-22 13:54:59 +00:00
tsconfig.json Initial commit 2026-07-22 13:54:59 +00:00

markdown-it-popover-notes

NPM Version License

Native HTML popover footnotes for markdown-it markdown parser. Based on markdown-it-footnote.

Based on markdown-it-footnote, which you should probably use with custom render methods instead.

Markup is based on pandoc definition.

Usage Examples

Normal Footnotes

Input:

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

[^1]: Here is the footnote.

[^longnote]: Heres one with multiple blocks.

    Subsequent paragraphs are indented to show that they belong to the previous footnote.

        { some.code }

    The whole paragraph can be indented, or just the first line. In this way, multi-paragraph footnotes work like multi-paragraph list items.

This paragraph wont be part of the note, because it isnt indented.

Output:

<p>Here is a footnote reference,<sup><button popovertarget="ref-1">[1]</button></sup> and another.<sup><button popovertarget="ref-2">[2]</button></sup></p>
<p>This paragraph wont be part of the note, because it isnt indented.</p>
<section id="popover-footnotes">
  <aside id="ref-1" popover="auto">
    <p>Here is the footnote.</p>
  </aside>
  <aside id="ref-2" popover="auto">
    <p>Heres one with multiple blocks.</p>
    <p>Subsequent paragraphs are indented to show that they belong to the previous footnote.</p>
    <pre><code>{ some.code }</code></pre>
    <p>The whole paragraph can be indented, or just the first line. In this way, multi-paragraph footnotes work like multi-paragraph list items.</p>
  </aside>
</section>

Inline Footnotes

Input:

Here is an inline note^[Inlines notes are easier to write.] with some text after.

Output:

<p>Here is an inline note<sup><button popovertarget="ref-1">[1]</button></sup> with some text after.</p>
<section id="popover-footnotes">
  <aside id="ref-1" popover="auto">
    <p>Inlines notes are easier to write.</p>
  </aside>
</section>

Installation

Install markdown-it-popover-notes from npm with your favorite package manager.

Usage

import MarkdownIt from "markdown-it";
import popoverNotesPlugin from "markdown-it-popover-notes";

const md = MarkdownIt();
md.use(popoverNotesPlugin);

const html = md.render("Footnotes are cool, but popovers are cooler.^[Popovers are cooler because they don't make the page move!]");

Styling

Without a little CSS, the popovers float in the middle of the screen instead of appearing next to the superscript reference. Below are some minimal styles to get you started. There is a more detailed example in styling-sample.html.

button[popovertarget] {
  background: unset;
  border: unset;
  color: LinkText;
  cursor: pointer;
}

[popover] {
  position-area: block-start;
  position-try-fallbacks: flip-block flip-inline;
  margin: 0.5rem;
  padding: 0.5rem;
  inset: auto;
}