Skip to content

Commit 3e9774c

Browse files
committed
Add better docs
1 parent 40af676 commit 3e9774c

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

readme.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ Extension for [`mdast-util-from-markdown`][from-markdown] and/or
1414
When parsing (`from-markdown`), must be combined with
1515
[`micromark-extension-gfm`][extension].
1616

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.
1923

2024
Alternatively, the extensions can be used separately:
2125

@@ -65,25 +69,25 @@ www.example.com, https://example.com, and [email protected].
6569
* [x] done
6670
```
6771

68-
And our script, `example.js`, looks as follows:
72+
And our module, `example.js`, looks as follows:
6973

7074
```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'
7680

77-
var doc = fs.readFileSync('example.md')
81+
const doc = fs.readFileSync('example.md')
7882

79-
var tree = fromMarkdown(doc, {
80-
extensions: [syntax()],
81-
mdastExtensions: [gfm.fromMarkdown]
83+
const tree = fromMarkdown(doc, {
84+
extensions: [gfm()],
85+
mdastExtensions: [gfmFromMarkdown]
8286
})
8387

8488
console.log(tree)
8589

86-
var out = toMarkdown(tree, {extensions: [gfm.toMarkdown()]})
90+
const out = toMarkdown(tree, {extensions: [gfmToMarkdown()]})
8791

8892
console.log(out)
8993
```
@@ -233,10 +237,6 @@ returns an extension for [`mdast-util-to-markdown`][to-markdown].
233237

234238
Passed as `options` to [`mdast-util-gfm-table`][table].
235239

236-
The exports are extensions, respectively
237-
for [`mdast-util-from-markdown`][from-markdown] and
238-
[`mdast-util-to-markdown`][to-markdown].
239-
240240
## Related
241241

242242
* [`remarkjs/remark`][remark]

0 commit comments

Comments
 (0)