Skip to content

Commit 095ef8b

Browse files
committed
Add better docs
1 parent 93c3d26 commit 095ef8b

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

.!42543!.editorconfig

Whitespace-only changes.

readme.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ autolink literals in **[mdast][]**.
1414
When parsing (`from-markdown`), must be combined with
1515
[`micromark-extension-gfm-autolink-literal`][extension].
1616

17-
You might want to use this package through [`remark-gfm`][remark-gfm] with
18-
**[remark][]**.
17+
## When to use this
18+
19+
Use [`mdast-util-gfm`][mdast-util-gfm] if you want all of GFM.
20+
Use this otherwise.
1921

2022
## Install
2123

@@ -30,24 +32,24 @@ npm install mdast-util-gfm-autolink-literal
3032

3133
## Use
3234

33-
Say our script, `example.js`, looks as follows:
35+
Say our module, `example.js`, looks as follows:
3436

3537
```js
36-
var fromMarkdown = require('mdast-util-from-markdown')
37-
var toMarkdown = require('mdast-util-to-markdown')
38-
var syntax = require('micromark-extension-gfm-autolink-literal')
39-
var autolinkLiteral = require('mdast-util-gfm-autolink-literal')
38+
import {fromMarkdown} from 'mdast-util-from-markdown'
39+
import {toMarkdown} from 'mdast-util-to-markdown'
40+
import {gfmAutolinkLiteral} from 'micromark-extension-gfm-autolink-literal'
41+
import {gfmAutolinkLiteralFromMarkdown, gfmAutolinkLiteralToMarkdown} from 'mdast-util-gfm-autolink-literal'
4042

41-
var doc = 'www.example.com, https://example.com, and contact@example.com.'
43+
const doc = 'www.example.com, https://example.com, and contact@example.com.'
4244

43-
var tree = fromMarkdown(doc, {
44-
extensions: [syntax],
45-
mdastExtensions: [autolinkLiteral.fromMarkdown]
45+
const tree = fromMarkdown(doc, {
46+
extensions: [gfmAutolinkLiteral],
47+
mdastExtensions: [gfmAutolinkLiteralFromMarkdown]
4648
})
4749

4850
console.log(tree)
4951

50-
var out = toMarkdown(tree, {extensions: [autolinkLiteral.toMarkdown]})
52+
const out = toMarkdown(tree, {extensions: [gfmAutolinkLiteralToMarkdown]})
5153

5254
console.log(out)
5355
```
@@ -174,6 +176,8 @@ abide by its terms.
174176

175177
[mdast]: https://github.com/syntax-tree/mdast
176178

179+
[mdast-util-gfm]: https://github.com/syntax-tree/mdast-util-gfm
180+
177181
[remark]: https://github.com/remarkjs/remark
178182

179183
[remark-gfm]: https://github.com/remarkjs/remark-gfm

0 commit comments

Comments
 (0)