@@ -13,8 +13,12 @@ Extension for [`mdast-util-from-markdown`][from-markdown] and/or
13
13
When parsing (` from-markdown ` ), must be combined with
14
14
[ ` micromark-extension-footnote ` ] [ extension ] .
15
15
16
- You probably shouldn’t use this package directly, but instead use
17
- [ ` remark-footnotes ` ] [ remark-footnotes ] with ** [ remark] [ ] ** .
16
+ ## When to use this
17
+
18
+ Use this if you’re dealing with the AST manually.
19
+ It might be better to use [ ` remark-footnotes ` ] [ remark-footnotes ] with
20
+ ** [ remark] [ ] ** , which includes this but provides a nicer interface and makes it
21
+ easier to combine with hundreds of plugins.
18
22
19
23
## Install
20
24
@@ -55,25 +59,25 @@ you don’t have to pick an identifier and move down to type the
55
59
note.]
56
60
```
57
61
58
- And our script , ` example.js ` , looks as follows:
62
+ And our module , ` example.js ` , looks as follows:
59
63
60
64
``` js
61
- var fs = require ( ' fs' )
62
- var fromMarkdown = require ( ' mdast-util-from-markdown' )
63
- var toMarkdown = require ( ' mdast-util-to-markdown' )
64
- var syntax = require ( ' micromark-extension-footnote' )
65
- var footnote = require ( ' mdast-util-footnote' )
65
+ import fs from ' node: fs'
66
+ import { fromMarkdown } from ' mdast-util-from-markdown'
67
+ import { toMarkdown } from ' mdast-util-to-markdown'
68
+ import { footnote } from ' micromark-extension-footnote'
69
+ import { footnoteFromMarkdown , footnoteToMarkdown } from ' mdast-util-footnote'
66
70
67
- var doc = fs .readFileSync (' example.md' )
71
+ const doc = fs .readFileSync (' example.md' )
68
72
69
- var tree = fromMarkdown (doc, {
70
- extensions: [syntax ({inlineNotes: true })],
71
- mdastExtensions: [footnote . fromMarkdown ]
73
+ const tree = fromMarkdown (doc, {
74
+ extensions: [footnote ({inlineNotes: true })],
75
+ mdastExtensions: [footnoteFromMarkdown ]
72
76
})
73
77
74
78
console .log (tree)
75
79
76
- var out = toMarkdown (tree, {extensions: [footnote . toMarkdown ]})
80
+ const out = toMarkdown (tree, {extensions: [footnoteToMarkdown ]})
77
81
78
82
console .log (out)
79
83
```
0 commit comments