Skip to content
This repository was archived by the owner on Aug 9, 2023. It is now read-only.

Commit 24647aa

Browse files
committed
Add better docs
1 parent 3bb1a7b commit 24647aa

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

readme.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ Extension for [`mdast-util-from-markdown`][from-markdown] and/or
1313
When parsing (`from-markdown`), must be combined with
1414
[`micromark-extension-footnote`][extension].
1515

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

1923
## Install
2024

@@ -55,25 +59,25 @@ you don’t have to pick an identifier and move down to type the
5559
note.]
5660
```
5761

58-
And our script, `example.js`, looks as follows:
62+
And our module, `example.js`, looks as follows:
5963

6064
```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'
6670

67-
var doc = fs.readFileSync('example.md')
71+
const doc = fs.readFileSync('example.md')
6872

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]
7276
})
7377

7478
console.log(tree)
7579

76-
var out = toMarkdown(tree, {extensions: [footnote.toMarkdown]})
80+
const out = toMarkdown(tree, {extensions: [footnoteToMarkdown]})
7781

7882
console.log(out)
7983
```

0 commit comments

Comments
 (0)