@@ -16,10 +16,10 @@ When parsing (`from-markdown`), must be combined with
1616This utility handles parsing and serializing.
1717See [ ` micromark-extension-mdx-expression ` ] [ extension ] for how the syntax works.
1818
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 .
2323
2424## Install
2525
@@ -44,26 +44,26 @@ Say we have an MDX.js file, `example.mdx`:
4444b { true } .
4545```
4646
47- And our script , ` example.js ` , looks as follows:
47+ And our module , ` example.js ` , looks as follows:
4848
4949``` 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'
5656
5757var doc = fs .readFileSync (' example.mdx' )
5858
5959var tree = fromMarkdown (doc, {
60- extensions: [syntax ({acorn : acorn, addResult: true })],
61- mdastExtensions: [mdxExpression . fromMarkdown ]
60+ extensions: [mdxExpression ({ acorn, addResult: true })],
61+ mdastExtensions: [mdxExpressionFromMarkdown ]
6262})
6363
6464console .log (tree)
6565
66- var out = toMarkdown (tree, {extensions: [mdxExpression . toMarkdown ]})
66+ var out = toMarkdown (tree, {extensions: [mdxExpressionToMarkdown ]})
6767
6868console .log (out)
6969```
@@ -303,10 +303,6 @@ abide by its terms.
303303
304304[ extension ] : https://github.com/micromark/micromark-extension-mdx-expression
305305
306- [ mdx ] : https://github.com/micromark/micromark-extension-mdx
307-
308- [ mdxjs ] : https://github.com/micromark/micromark-extension-mdxjs
309-
310306[ mdast-util-mdx ] : https://github.com/syntax-tree/mdast-util-mdx
311307
312308[ estree ] : https://github.com/estree/estree
@@ -316,5 +312,3 @@ abide by its terms.
316312[ dfn-flow-content ] : #flowcontent-mdx-expression
317313
318314[ dfn-phrasing-content ] : #phrasingcontent-mdx-expression
319-
320- [ remark-mdx ] : https://github.com/mdx-js/mdx/tree/next/packages/remark-mdx
0 commit comments