Skip to content

Commit

Permalink
Add support for GFM footnotes
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Oct 2, 2021
1 parent db32db7 commit 39629ed
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @typedef {import('micromark-util-types').Extension} Extension
* @typedef {import('micromark-util-types').HtmlExtension} HtmlExtension
* @typedef {import('micromark-extension-gfm-strikethrough').Options} Options
* @typedef {import('micromark-extension-gfm-footnote').HtmlOptions} HtmlOptions
*/

import {
Expand All @@ -12,6 +13,7 @@ import {
gfmAutolinkLiteral,
gfmAutolinkLiteralHtml
} from 'micromark-extension-gfm-autolink-literal'
import {gfmFootnote, gfmFootnoteHtml} from 'micromark-extension-gfm-footnote'
import {
gfmStrikethrough,
gfmStrikethroughHtml
Expand All @@ -32,6 +34,7 @@ import {
export function gfm(options) {
return combineExtensions([
gfmAutolinkLiteral,
gfmFootnote(),
gfmStrikethrough(options),
gfmTable,
gfmTaskListItem
Expand All @@ -41,11 +44,13 @@ export function gfm(options) {
/**
* Support to compile GFM to HTML.
*
* @param {HtmlOptions} [options]
* @returns {HtmlExtension}
*/
export function gfmHtml() {
export function gfmHtml(options) {
return combineHtmlExtensions([
gfmAutolinkLiteralHtml,
gfmFootnoteHtml(options),
gfmStrikethroughHtml,
gfmTableHtml,
gfmTagfilterHtml,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
],
"dependencies": {
"micromark-extension-gfm-autolink-literal": "^1.0.0",
"micromark-extension-gfm-footnote": "^1.0.0",
"micromark-extension-gfm-strikethrough": "^1.0.0",
"micromark-extension-gfm-table": "^1.0.0",
"micromark-extension-gfm-tagfilter": "^1.0.0",
Expand Down
15 changes: 15 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ Say we have the following file, `example.md`:

www.example.com, https://example.com, and contact@example.com.

## Footnote

A note[^1]

[^1]: Big note.

## Strikethrough

~one~ or ~~two~~ tildes.
Expand Down Expand Up @@ -96,6 +102,8 @@ Now, running `node example` yields:
<h1>GFM</h1>
<h2>Autolink literals</h2>
<p><a href="http://www.example.com">www.example.com</a>, <a href="https://example.com">https://example.com</a>, and <a href="mailto:contact@example.com">contact@example.com</a>.</p>
<h2>Footnote</h2>
<p>A note<sup><a href="#user-content-fn-1" id="user-content-fnref-1" data-footnote-ref="" aria-describedby="footnote-label">1</a></sup></p>
<h2>Strikethrough</h2>
<p><del>one</del> or <del>two</del> tildes.</p>
<h2>Table</h2>
Expand All @@ -116,6 +124,13 @@ Now, running `node example` yields:
<li><input disabled="" type="checkbox"> to do</li>
<li><input checked="" disabled="" type="checkbox"> done</li>
</ul>
<section data-footnotes="" class="footnotes"><h2 id="footnote-label" class="sr-only">Footnotes</h2>
<ol>
<li id="user-content-fn-1">
<p>Big note. <a href="#user-content-fnref-1" data-footnote-backref="" class="data-footnote-backref" aria-label="Back to content">↩</a></p>
</li>
</ol>
</section>
```

## API
Expand Down

0 comments on commit 39629ed

Please sign in to comment.