Project: syntax-tree/mdast-util-gfm-footnote

Package: mdast-util-gfm-footnote@1.0.0

  1. Dependents: 1
  2. mdast extension to parse and serialize GFM footnotes
  1. util 144
  2. utility 140
  3. markdown 139
  4. unist 127
  5. mdast 83
  6. mdast-util 31
  7. gfm 20
  8. markup 19
  9. footnote 7
  10. note 5


Build Coverage Downloads Size Sponsors Backers Chat

Extension for mdast-util-from-markdown and/or mdast-util-to-markdown to support GitHub flavored markdown (GFM) footnotes in mdast. When parsing (from-markdown), must be combined with micromark-extension-gfm-footnote.

GFM footnotes were announced September 30, 2021 but are neither specified nor supported in all their products (e.g., Gists). Their implementation on github.com is currently quite buggy. The bugs have been reported on cmark-gfm. This micromark extension matches github.com except for its bugs.

When to use this

Use mdast-util-gfm if you want all of GFM. Use this otherwise.


This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.


npm install mdast-util-gfm-footnote


Say our module, example.js, looks as follows:

import {fromMarkdown} from 'mdast-util-from-markdown'
import {toMarkdown} from 'mdast-util-to-markdown'
import {gfmFootnote} from 'micromark-extension-gfm-footnote'
import {gfmFootnoteFromMarkdown, gfmFootnoteToMarkdown} from 'mdast-util-gfm-footnote'

const doc = 'Hi![^1]\n\n[^1]: big note'

const tree = fromMarkdown(doc, {
  extensions: [gfmFootnote()],
  mdastExtensions: [gfmFootnoteFromMarkdown()]


const out = toMarkdown(tree, {extensions: [gfmFootnoteToMarkdown()]})


Now, running node example yields:

  type: 'root',
  children: [
      type: 'paragraph',
      children: [
        {type: 'text', value: 'Hi!'},
        {type: 'footnoteReference', identifier: '1', label: '1'}
      type: 'footnoteDefinition',
      identifier: '1',
      label: '1',
      children: [
        {type: 'paragraph', children: [{type: 'text', value: 'big note'}]}

[^1]: big note




Support footnotes. The exports are functions that can be called to get extensions, respectively for mdast-util-from-markdown and mdast-util-to-markdown.


See contributing.md in syntax-tree/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.


MIT © Titus Wormer