Skip to content

Commit 1480585

Browse files
committed
Add better docs
1 parent 7a6afef commit 1480585

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

readme.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ Extension for [`mdast-util-from-markdown`][from-markdown] and/or
1414
When parsing (`from-markdown`), must be combined with either
1515
[`micromark-extension-mdx`][mdx] or [`micromark-extension-mdxjs`][mdxjs].
1616

17-
You might instead want to use this package through [`remark-mdx`][remark-mdx]
18-
with **[remark][]**.
17+
## When to use this
1918

20-
Alternatively, the extensions can be used separately:
19+
Use this if you’re dealing with the AST manually and want to support all of MDX.
20+
You can also use the extensions separately:
2121

2222
* [`mdast-util-mdx-expression`](https://github.com/syntax-tree/mdast-util-mdx-expression)
2323
— support MDX (or MDX.js) expressions
@@ -62,22 +62,22 @@ Which you can also put inline: {1+1}.
6262
And our script, `example.js`, looks as follows:
6363

6464
```js
65-
var fs = require('fs')
66-
var fromMarkdown = require('mdast-util-from-markdown')
67-
var toMarkdown = require('mdast-util-to-markdown')
68-
var syntax = require('micromark-extension-mdxjs')
69-
var mdx = require('mdast-util-mdx')
65+
import fs from 'node:fs'
66+
import {fromMarkdown} from 'mdast-util-from-markdown'
67+
import {toMarkdown} from 'mdast-util-to-markdown'
68+
import {mdxjs} from 'micromark-extension-mdxjs'
69+
import {mdxFromMarkdown, mdxToMarkdown} from 'mdast-util-mdx'
7070

71-
var doc = fs.readFileSync('example.mdx')
71+
const doc = fs.readFileSync('example.mdx')
7272

73-
var tree = fromMarkdown(doc, {
74-
extensions: [syntax()],
75-
mdastExtensions: [mdx.fromMarkdown]
73+
const tree = fromMarkdown(doc, {
74+
extensions: [mdxjs()],
75+
mdastExtensions: [mdxFromMarkdown]
7676
})
7777

7878
console.log(tree)
7979

80-
var out = toMarkdown(tree, {extensions: [mdx.toMarkdown]})
80+
const out = toMarkdown(tree, {extensions: [mdxToMarkdown]})
8181

8282
console.log(out)
8383
```

0 commit comments

Comments
 (0)