@@ -16,10 +16,10 @@ When parsing (`from-markdown`), must be combined with
16
16
This utility handles parsing and serializing.
17
17
See [ ` micromark-extension-mdx-expression ` ] [ extension ] for how the syntax works.
18
18
19
- You probably should use either [ ` micromark-extension-mdx ` ] [ mdx ] or
20
- [ ` micromark-extension-mdxjs ` ] [ mdxjs ] with [ ` mdast-util-mdx ` ] [ mdast-util-mdx ]
21
- (which both include this package) to support all of MDX (or MDX.js) .
22
- Or use it all through [ ` remark-mdx ` ] [ remark-mdx ] ( ** [ remark ] [ ] ** ) .
19
+ ## When to use this
20
+
21
+ Use [ ` mdast-util-mdx ` ] [ mdast-util-mdx ] if you want all of MDX / MDX.js.
22
+ Use this otherwise .
23
23
24
24
## Install
25
25
@@ -44,26 +44,26 @@ Say we have an MDX.js file, `example.mdx`:
44
44
b { true } .
45
45
```
46
46
47
- And our script , ` example.js ` , looks as follows:
47
+ And our module , ` example.js ` , looks as follows:
48
48
49
49
``` js
50
- var fs = require ( ' fs' )
51
- var acorn = require ( ' acorn' )
52
- var syntax = require ( ' micromark-extension-mdx-expression ' )
53
- var fromMarkdown = require ( ' mdast-util-from -markdown' )
54
- var toMarkdown = require ( ' mdast-util-to-markdown ' )
55
- var mdxExpression = require ( ' mdast-util-mdx-expression' )
50
+ import fs from ' node: fs'
51
+ import * as acorn from ' acorn'
52
+ import { fromMarkdown } from ' mdast-util-from-markdown '
53
+ import { toMarkdown } from ' mdast-util-to -markdown'
54
+ import { mdxExpression } from ' micromark-extension-mdx-expression '
55
+ import { mdxExpressionFromMarkdown , mdxExpressionToMarkdown } from ' mdast-util-mdx-expression'
56
56
57
57
var doc = fs .readFileSync (' example.mdx' )
58
58
59
59
var tree = fromMarkdown (doc, {
60
- extensions: [syntax ({acorn : acorn, addResult: true })],
61
- mdastExtensions: [mdxExpression . fromMarkdown ]
60
+ extensions: [mdxExpression ({ acorn, addResult: true })],
61
+ mdastExtensions: [mdxExpressionFromMarkdown ]
62
62
})
63
63
64
64
console .log (tree)
65
65
66
- var out = toMarkdown (tree, {extensions: [mdxExpression . toMarkdown ]})
66
+ var out = toMarkdown (tree, {extensions: [mdxExpressionToMarkdown ]})
67
67
68
68
console .log (out)
69
69
```
@@ -303,10 +303,6 @@ abide by its terms.
303
303
304
304
[ extension ] : https://github.com/micromark/micromark-extension-mdx-expression
305
305
306
- [ mdx ] : https://github.com/micromark/micromark-extension-mdx
307
-
308
- [ mdxjs ] : https://github.com/micromark/micromark-extension-mdxjs
309
-
310
306
[ mdast-util-mdx ] : https://github.com/syntax-tree/mdast-util-mdx
311
307
312
308
[ estree ] : https://github.com/estree/estree
@@ -316,5 +312,3 @@ abide by its terms.
316
312
[ dfn-flow-content ] : #flowcontent-mdx-expression
317
313
318
314
[ dfn-phrasing-content ] : #phrasingcontent-mdx-expression
319
-
320
- [ remark-mdx ] : https://github.com/mdx-js/mdx/tree/next/packages/remark-mdx
0 commit comments