{"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"bugs":{"url":"https://github.com/syntax-tree/mdast-util-gfm-footnote/issues"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"}],"dependencies":{"@types/mdast":"^4.0.0","devlop":"^1.1.0","mdast-util-from-markdown":"^2.0.0","mdast-util-to-markdown":"^2.0.0","micromark-util-normalize-identifier":"^2.0.0"},"description":"mdast extension to parse and serialize GFM footnotes","devDependencies":{"@types/node":"^22.0.0","c8":"^10.0.0","micromark-extension-gfm-footnote":"^2.0.0","prettier":"^3.0.0","remark-cli":"^12.0.0","remark-preset-wooorm":"^11.0.0","type-coverage":"^2.0.0","typescript":"^5.0.0","xo":"^0.60.0"},"exports":"./index.js","funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"keywords":["footnote","gfm","markdown","markup","mdast-util","mdast","note","unist","utility","util"],"license":"MIT","name":"mdast-util-gfm-footnote","prettier":{"bracketSpacing":false,"semi":false,"singleQuote":true,"tabWidth":2,"trailingComma":"none","useTabs":false},"remarkConfig":{"plugins":["remark-preset-wooorm"]},"repository":{"type":"git","url":"git+https://github.com/syntax-tree/mdast-util-gfm-footnote.git"},"scripts":{"build":"tsc --build --clean && tsc --build && type-coverage","format":"remark --frail --output --quiet -- . && prettier --log-level warn --write -- . && xo --fix","test-api-dev":"node --conditions development test.js","test-api-prod":"node --conditions production test.js","test-api":"npm run test-api-dev && npm run test-api-prod","test-coverage":"c8 --100 --reporter lcov npm run test-api","test":"npm run build && npm run format && npm run test-coverage"},"sideEffects":false,"typeCoverage":{"atLeast":100,"strict":true},"type":"module","version":"2.1.0","xo":{"overrides":[{"files":["**/*.d.ts"],"rules":{"@typescript-eslint/array-type":["error",{"default":"generic"}],"@typescript-eslint/ban-types":["error",{"extendDefaults":true}],"@typescript-eslint/consistent-type-definitions":["error","interface"]}}],"prettier":true,"rules":{"unicorn/prefer-at":"off"}},"_id":"mdast-util-gfm-footnote@2.1.0","gitHead":"8ff7529028c33d336caa3ea0af2db19001157f96","types":"./index.d.ts","homepage":"https://github.com/syntax-tree/mdast-util-gfm-footnote#readme","_nodeVersion":"23.1.0","_npmVersion":"11.1.0","dist":{"integrity":"sha512-sqpDWlsHn7Ac9GNZQMeUzPQSMzR6Wv0WKRNvQRg0KqHh02fpTz69Qc1QSseNX29bhz1ROIyNyxExfawVKTm1GQ==","shasum":"7778e9d9ca3df7238cc2bd3fa2b1bf6a65b19403","tarball":"http://registry-npm.ywwl.com/mdast-util-gfm-footnote/download/mdast-util-gfm-footnote-2.1.0.tgz","fileCount":8,"unpackedSize":24051,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCLWiDFPqXJH90UKrs1CwSQw58sN2iDjyTQsvAZUUbGtwIhAKNMWvyU3tT0/lgXatWDBnqMLOAFPT1L5iYKJtcV4cIJ"}],"size":7145,"noattachment":false,"key":"/mdast-util-gfm-footnote/-/mdast-util-gfm-footnote-2.1.0.tgz"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"},{"name":"kmck","email":"keith@mcknig.ht"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mdast-util-gfm-footnote_2.1.0_1739188342960_0.24898582389844237"},"_hasShrinkwrap":false,"readme":"# mdast-util-gfm-footnote\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n[mdast][] extensions to parse and serialize [GFM][] footnotes.\n\n## Contents\n\n* [What is this?](#what-is-this)\n* [When to use this](#when-to-use-this)\n* [Install](#install)\n* [Use](#use)\n* [API](#api)\n  * [`gfmFootnoteFromMarkdown()`](#gfmfootnotefrommarkdown)\n  * [`gfmFootnoteToMarkdown(options?)`](#gfmfootnotetomarkdownoptions)\n  * [`ToMarkdownOptions`](#tomarkdownoptions)\n* [HTML](#html)\n* [Syntax](#syntax)\n* [Syntax tree](#syntax-tree)\n  * [Nodes](#nodes)\n  * [Content model](#content-model)\n* [Types](#types)\n* [Compatibility](#compatibility)\n* [Related](#related)\n* [Contribute](#contribute)\n* [License](#license)\n\n## What is this?\n\nThis package contains two extensions that add support for GFM footnote syntax\nin markdown to [mdast][].\nThese extensions plug into\n[`mdast-util-from-markdown`][mdast-util-from-markdown] (to support parsing\nfootnotes in markdown into a syntax tree) and\n[`mdast-util-to-markdown`][mdast-util-to-markdown] (to support serializing\nfootnotes in syntax trees to markdown).\n\nGFM footnotes were [announced September 30, 2021][post] but are not specified.\nTheir implementation on github.com is currently buggy.\nThe bugs have been reported on [`cmark-gfm`][cmark-gfm].\n\n## When to use this\n\nYou can use these extensions when you are working with\n`mdast-util-from-markdown` and `mdast-util-to-markdown` already.\n\nWhen working with `mdast-util-from-markdown`, you must combine this package\nwith [`micromark-extension-gfm-footnote`][micromark-extension-gfm-footnote].\n\nWhen you don’t need a syntax tree, you can use [`micromark`][micromark]\ndirectly with `micromark-extension-gfm-footnote`.\n\nWhen you are working with syntax trees and want all of GFM, use\n[`mdast-util-gfm`][mdast-util-gfm] instead.\n\nAll these packages are used [`remark-gfm`][remark-gfm], which\nfocusses on making it easier to transform content by abstracting these\ninternals away.\n\nThis utility does not handle how markdown is turned to HTML.\nThat’s done by [`mdast-util-to-hast`][mdast-util-to-hast].\nIf your content is not in English, you should configure that utility.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install mdast-util-gfm-footnote\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {gfmFootnoteFromMarkdown, gfmFootnoteToMarkdown} from 'https://esm.sh/mdast-util-gfm-footnote@2'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n<script type=\"module\">\n  import {gfmFootnoteFromMarkdown, gfmFootnoteToMarkdown} from 'https://esm.sh/mdast-util-gfm-footnote@2?bundle'\n</script>\n```\n\n## Use\n\nSay our document `example.md` contains:\n\n```markdown\nIn the Solar System, Mercury[^mercury] and Venus[^venus] have very small tilts.\n\n[^mercury]:\n    **Mercury** is the first planet from the Sun and the smallest\n    in the Solar System.\n\n[^venus]:\n    **Venus** is the second planet from\n    the Sun.\n```\n\n…and our module `example.js` looks as follows:\n\n```js\nimport fs from 'node:fs/promises'\nimport {fromMarkdown} from 'mdast-util-from-markdown'\nimport {\n  gfmFootnoteFromMarkdown,\n  gfmFootnoteToMarkdown\n} from 'mdast-util-gfm-footnote'\nimport {toMarkdown} from 'mdast-util-to-markdown'\nimport {gfmFootnote} from 'micromark-extension-gfm-footnote'\n\nconst value = await fs.readFile('example.md', 'utf8')\n\nconst tree = fromMarkdown(value, {\n  extensions: [gfmFootnote()],\n  mdastExtensions: [gfmFootnoteFromMarkdown()]\n})\n\nconsole.log(tree)\n\nconst result = toMarkdown(tree, {\n  extensions: [gfmFootnoteToMarkdown({firstLineBlank: true})]\n})\n\nconsole.log(result)\n```\n\n…now running `node example.js` yields (positional info removed for brevity):\n\n```js\n{\n  type: 'root',\n  children: [\n    {\n      type: 'paragraph',\n      children: [\n        {type: 'text', value: 'In the Solar System, Mercury'},\n        {type: 'footnoteReference', identifier: 'mercury', label: 'mercury'},\n        {type: 'text', value: ' and Venus'},\n        {type: 'footnoteReference', identifier: 'venus', label: 'venus'},\n        {type: 'text', value: ' have very small tilts.'}\n      ]\n    },\n    {\n      type: 'footnoteDefinition',\n      identifier: 'mercury',\n      label: 'mercury',\n      children: [\n        {\n          type: 'paragraph',\n          children: [\n            {type: 'strong', children: [{type: 'text', value: 'Mercury'}]},\n            {\n              type: 'text',\n              value:\n                ' is the first planet from the Sun and the smallest\\n' +\n                'in the Solar System.'\n            }\n          ]\n        }\n      ]\n    },\n    {\n      type: 'footnoteDefinition',\n      identifier: 'venus',\n      label: 'venus',\n      children: [\n        {\n          type: 'paragraph',\n          children: [\n            {type: 'strong', children: [{type: 'text', value: 'Venus'}]},\n            {type: 'text', value: ' is the second planet from\\nthe Sun.'}\n          ]\n        }\n      ]\n    }\n  ]\n}\n```\n\n```markdown\nIn the Solar System, Mercury[^mercury] and Venus[^venus] have very small tilts.\n\n[^mercury]:\n    **Mercury** is the first planet from the Sun and the smallest\n    in the Solar System.\n\n[^venus]:\n    **Venus** is the second planet from\n    the Sun.\n```\n\n## API\n\nThis package exports the identifiers\n[`gfmFootnoteFromMarkdown`][api-gfmfootnotefrommarkdown] and\n[`gfmFootnoteToMarkdown`][api-gfmfootnotetomarkdown].\nThere is no default export.\nIt exports the type [`ToMarkdownOptions`][api-to-markdown-options].\n\n### `gfmFootnoteFromMarkdown()`\n\nCreate an extension for\n[`mdast-util-from-markdown`][mdast-util-from-markdown]\nto enable GFM footnotes in markdown.\n\n###### Returns\n\nExtension for `mdast-util-from-markdown`\n([`FromMarkdownExtension`][frommarkdownextension]).\n\n### `gfmFootnoteToMarkdown(options?)`\n\nCreate an extension for\n[`mdast-util-to-markdown`][mdast-util-to-markdown]\nto enable GFM footnotes in markdown.\n\n###### Parameters\n\n* `options` ([`ToMarkdownOptions`][api-to-markdown-options], optional)\n  — configuration\n\n###### Returns\n\nExtension for `mdast-util-to-markdown`\n([`ToMarkdownExtension`][tomarkdownextension]).\n\n### `ToMarkdownOptions`\n\nConfiguration (TypeScript type).\n\n###### Fields\n\n* `firstLineBlank` (`boolean`, default: `false`)\n  — use a blank line for the first line of footnote definitions\n\n## HTML\n\nThis utility does not handle how markdown is turned to HTML.\nThat’s done by [`mdast-util-to-hast`][mdast-util-to-hast].\nIf your content is not in English, you should configure that utility.\n\n## Syntax\n\nSee [Syntax in `micromark-extension-gfm-footnote`][syntax].\n\n## Syntax tree\n\nThe following interfaces are added to **[mdast][]** by this utility.\n\n### Nodes\n\n#### `FootnoteDefinition`\n\n```idl\ninterface FootnoteDefinition <: Parent {\n  type: 'footnoteDefinition'\n  children: [FlowContent]\n}\n\nFootnoteDefinition includes Association\n```\n\n**FootnoteDefinition** (**[Parent][dfn-parent]**) represents content relating\nto the document that is outside its flow.\n\n**FootnoteDefinition** can be used where **[flow][dfn-flow-content]** content\nis expected.\nIts content model is also **[flow][dfn-flow-content]** content.\n\n**FootnoteDefinition** includes the mixin\n**[Association][dfn-mxn-association]**.\n\n**FootnoteDefinition** should be associated with\n**[FootnoteReferences][dfn-footnote-reference]**.\n\nFor example, the following markdown:\n\n```markdown\n[^alpha]: bravo and charlie.\n```\n\nYields:\n\n```js\n{\n  type: 'footnoteDefinition',\n  identifier: 'alpha',\n  label: 'alpha',\n  children: [{\n    type: 'paragraph',\n    children: [{type: 'text', value: 'bravo and charlie.'}]\n  }]\n}\n```\n\n#### `FootnoteReference`\n\n```idl\ninterface FootnoteReference <: Node {\n  type: 'footnoteReference'\n}\n\nFootnoteReference includes Association\n```\n\n**FootnoteReference** (**[Node][dfn-node]**) represents a marker through\nassociation.\n\n**FootnoteReference** can be used where\n**[phrasing][dfn-phrasing-content]** content is expected.\nIt has no content model.\n\n**FootnoteReference** includes the mixin **[Association][dfn-mxn-association]**.\n\n**FootnoteReference** should be associated with a\n**[FootnoteDefinition][dfn-footnote-definition]**.\n\nFor example, the following markdown:\n\n```markdown\n[^alpha]\n```\n\nYields:\n\n```js\n{\n  type: 'footnoteReference',\n  identifier: 'alpha',\n  label: 'alpha'\n}\n```\n\n### Content model\n\n#### `FlowContent` (GFM footnotes)\n\n```idl\ntype FlowContentGfm = FootnoteDefinition | FlowContent\n```\n\n#### `PhrasingContent` (GFM footnotes)\n\n```idl\ntype PhrasingContentGfm = FootnoteReference | PhrasingContent\n```\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt does not export additional types.\n\nThe `FootnoteDefinition` and `FootnoteReference` types of the mdast nodes are\nexposed from `@types/mdast`.\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line,\n`mdast-util-gfm-footnote@^2`, compatible with Node.js 16.\n\n## Related\n\n* [`remark-gfm`][remark-gfm]\n  — remark plugin to support GFM\n* [`mdast-util-gfm`][mdast-util-gfm]\n  — same but all of GFM (autolink literals, footnotes, strikethrough, tables,\n  tasklists)\n* [`micromark-extension-gfm-footnote`][micromark-extension-gfm-footnote]\n  — micromark extension to parse GFM footnotes\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for\nways to get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n<!-- Definitions -->\n\n[api-gfmfootnotefrommarkdown]: #gfmfootnotefrommarkdown\n\n[api-gfmfootnotetomarkdown]: #gfmfootnotetomarkdownoptions\n\n[api-to-markdown-options]: #tomarkdownoptions\n\n[author]: https://wooorm.com\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[build]: https://github.com/syntax-tree/mdast-util-gfm-footnote/actions\n\n[build-badge]: https://github.com/syntax-tree/mdast-util-gfm-footnote/workflows/main/badge.svg\n\n[chat]: https://github.com/syntax-tree/unist/discussions\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[cmark-gfm]: https://github.com/github/cmark-gfm\n\n[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md\n\n[collective]: https://opencollective.com/unified\n\n[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md\n\n[coverage]: https://codecov.io/github/syntax-tree/mdast-util-gfm-footnote\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-gfm-footnote.svg\n\n[dfn-flow-content]: #flowcontent-gfm-footnotes\n\n[dfn-footnote-definition]: #footnotedefinition\n\n[dfn-footnote-reference]: #footnotereference\n\n[dfn-mxn-association]: https://github.com/syntax-tree/mdast#association\n\n[dfn-node]: https://github.com/syntax-tree/unist#node\n\n[dfn-parent]: https://github.com/syntax-tree/mdast#parent\n\n[dfn-phrasing-content]: #phrasingcontent-gfm-footnotes\n\n[downloads]: https://www.npmjs.com/package/mdast-util-gfm-footnote\n\n[downloads-badge]: https://img.shields.io/npm/dm/mdast-util-gfm-footnote.svg\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[frommarkdownextension]: https://github.com/syntax-tree/mdast-util-from-markdown#extension\n\n[gfm]: https://github.github.com/gfm/\n\n[health]: https://github.com/syntax-tree/.github\n\n[license]: license\n\n[mdast]: https://github.com/syntax-tree/mdast\n\n[mdast-util-from-markdown]: https://github.com/syntax-tree/mdast-util-from-markdown\n\n[mdast-util-gfm]: https://github.com/syntax-tree/mdast-util-gfm\n\n[mdast-util-to-hast]: https://github.com/syntax-tree/mdast-util-to-hast\n\n[mdast-util-to-markdown]: https://github.com/syntax-tree/mdast-util-to-markdown\n\n[micromark]: https://github.com/micromark/micromark\n\n[micromark-extension-gfm-footnote]: https://github.com/micromark/micromark-extension-gfm-footnote\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[post]: https://github.blog/changelog/2021-09-30-footnotes-now-supported-in-markdown-fields/\n\n[remark-gfm]: https://github.com/remarkjs/remark-gfm\n\n[size]: https://bundlejs.com/?q=mdast-util-gfm-footnote\n\n[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=mdast-util-gfm-footnote\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[support]: https://github.com/syntax-tree/.github/blob/main/support.md\n\n[syntax]: https://github.com/micromark/micromark-extension-gfm-footnote#syntax\n\n[tomarkdownextension]: https://github.com/syntax-tree/mdast-util-to-markdown#options\n\n[typescript]: https://www.typescriptlang.org\n","publish_time":1739188343193,"_cnpm_publish_time":1739188343193,"dist-tags":{"latest":"2.1.0"}}