Skip to content

Commit dcc9e6a

Browse files
committed
Add support for GFM footnotes
1 parent aeb53be commit dcc9e6a

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

index.js

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import {
99
gfmAutolinkLiteralFromMarkdown,
1010
gfmAutolinkLiteralToMarkdown
1111
} from 'mdast-util-gfm-autolink-literal'
12+
import {
13+
gfmFootnoteFromMarkdown,
14+
gfmFootnoteToMarkdown
15+
} from 'mdast-util-gfm-footnote'
1216
import {
1317
gfmStrikethroughFromMarkdown,
1418
gfmStrikethroughToMarkdown
@@ -25,6 +29,7 @@ import {
2529
export function gfmFromMarkdown() {
2630
return [
2731
gfmAutolinkLiteralFromMarkdown,
32+
gfmFootnoteFromMarkdown(),
2833
gfmStrikethroughFromMarkdown,
2934
gfmTableFromMarkdown,
3035
gfmTaskListItemFromMarkdown
@@ -39,6 +44,7 @@ export function gfmToMarkdown(options) {
3944
return {
4045
extensions: [
4146
gfmAutolinkLiteralToMarkdown,
47+
gfmFootnoteToMarkdown(),
4248
gfmStrikethroughToMarkdown,
4349
gfmTableToMarkdown(options),
4450
gfmTaskListItemToMarkdown

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
],
4141
"dependencies": {
4242
"mdast-util-gfm-autolink-literal": "^1.0.0",
43+
"mdast-util-gfm-footnote": "^1.0.0",
4344
"mdast-util-gfm-strikethrough": "^1.0.0",
4445
"mdast-util-gfm-table": "^1.0.0",
4546
"mdast-util-gfm-task-list-item": "^1.0.0"

readme.md

+30
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Alternatively, the extensions can be used separately:
2525

2626
* [`syntax-tree/mdast-util-gfm-autolink-literal`](https://github.com/syntax-tree/mdast-util-gfm-autolink-literal)
2727
— support GFM autolink literals
28+
* [`syntax-tree/mdast-util-gfm-footnote`](https://github.com/syntax-tree/mdast-util-gfm-footnote)
29+
— support GFM footnotes
2830
* [`syntax-tree/mdast-util-gfm-strikethrough`](https://github.com/syntax-tree/mdast-util-gfm-strikethrough)
2931
— support GFM strikethrough
3032
* [`syntax-tree/mdast-util-gfm-table`](https://github.com/syntax-tree/mdast-util-gfm-table)
@@ -54,6 +56,12 @@ Say we have the following file, `example.md`:
5456

5557
www.example.com, https://example.com, and [email protected].
5658

59+
## Footnote
60+
61+
A note[^1]
62+
63+
[^1]: Big note.
64+
5765
## Strikethrough
5866

5967
~one~ or ~~two~~ tildes.
@@ -130,6 +138,22 @@ Now, running `node example` yields:
130138
{type: 'text', value: '.'}
131139
]
132140
},
141+
{type: 'heading', depth: 2, children: [{type: 'text', value: 'Footnote'}]},
142+
{
143+
type: 'paragraph',
144+
children: [
145+
{type: 'text', value: 'A note'},
146+
{type: 'footnoteReference', identifier: '1', label: '1'}
147+
]
148+
},
149+
{
150+
type: 'footnoteDefinition',
151+
identifier: '1',
152+
label: '1',
153+
children: [
154+
{type: 'paragraph', children: [{type: 'text', value: 'Big note.'}]}
155+
]
156+
},
133157
{
134158
type: 'heading',
135159
depth: 2,
@@ -202,6 +226,12 @@ Now, running `node example` yields:
202226

203227
[www.example.com](http://www.example.com), <https://example.com>, and <[email protected]>.
204228

229+
## Footnote
230+
231+
A note[^1]
232+
233+
[^1]: Big note.
234+
205235
## Strikethrough
206236

207237
~~one~~ or ~~two~~ tildes.

0 commit comments

Comments
 (0)