@@ -14,8 +14,12 @@ Extension for [`mdast-util-from-markdown`][from-markdown] and/or
14
14
When parsing (` from-markdown ` ), must be combined with
15
15
[ ` micromark-extension-gfm ` ] [ extension ] .
16
16
17
- You probably shouldn’t use this package directly, but instead use
18
- [ ` remark-gfm ` ] [ remark-gfm ] with ** [ remark] [ ] ** .
17
+ ## When to use this
18
+
19
+ Use this if you’re dealing with the AST manually and need all of GFM.
20
+ It’s probably nicer to use [ ` remark-gfm ` ] [ remark-gfm ] with
21
+ ** [ remark] [ ] ** , which includes this but provides a nicer interface and
22
+ makes it easier to combine with hundreds of plugins.
19
23
20
24
Alternatively, the extensions can be used separately:
21
25
65
69
* [x] done
66
70
```
67
71
68
- And our script , ` example.js ` , looks as follows:
72
+ And our module , ` example.js ` , looks as follows:
69
73
70
74
``` js
71
- var fs = require ( ' fs' )
72
- var fromMarkdown = require ( ' mdast-util-from-markdown' )
73
- var toMarkdown = require ( ' mdast-util-to-markdown' )
74
- var syntax = require ( ' micromark-extension-gfm' )
75
- var gfm = require ( ' mdast-util-gfm' )
75
+ import fs from ' node: fs'
76
+ import { fromMarkdown } from ' mdast-util-from-markdown'
77
+ import { toMarkdown } from ' mdast-util-to-markdown'
78
+ import { gfm } from ' micromark-extension-gfm'
79
+ import { gfmFromMarkdown , gfmToMarkdown } from ' mdast-util-gfm'
76
80
77
- var doc = fs .readFileSync (' example.md' )
81
+ const doc = fs .readFileSync (' example.md' )
78
82
79
- var tree = fromMarkdown (doc, {
80
- extensions: [syntax ()],
81
- mdastExtensions: [gfm . fromMarkdown ]
83
+ const tree = fromMarkdown (doc, {
84
+ extensions: [gfm ()],
85
+ mdastExtensions: [gfmFromMarkdown ]
82
86
})
83
87
84
88
console .log (tree)
85
89
86
- var out = toMarkdown (tree, {extensions: [gfm . toMarkdown ()]})
90
+ const out = toMarkdown (tree, {extensions: [gfmToMarkdown ()]})
87
91
88
92
console .log (out)
89
93
```
@@ -233,10 +237,6 @@ returns an extension for [`mdast-util-to-markdown`][to-markdown].
233
237
234
238
Passed as ` options ` to [ ` mdast-util-gfm-table ` ] [ table ] .
235
239
236
- The exports are extensions, respectively
237
- for [ ` mdast-util-from-markdown ` ] [ from-markdown ] and
238
- [ ` mdast-util-to-markdown ` ] [ to-markdown ] .
239
-
240
240
## Related
241
241
242
242
* [ ` remarkjs/remark ` ] [ remark ]
0 commit comments