-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (36 loc) · 1.09 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* @typedef {import('micromark-extension-mdx-expression').Options} Options
* @typedef {import('micromark-util-types').Extension} Extension
*/
import {Parser} from 'acorn'
import acornJsx from 'acorn-jsx'
import {mdxExpression} from 'micromark-extension-mdx-expression'
import {mdxJsx} from 'micromark-extension-mdx-jsx'
import {mdxMd} from 'micromark-extension-mdx-md'
import {mdxjsEsm} from 'micromark-extension-mdxjs-esm'
import {combineExtensions} from 'micromark-util-combine-extensions'
/**
* Create an extension for `micromark` to enable MDX syntax.
*
* @param {Options | null | undefined} [options]
* Configuration (optional).
* @returns {Extension}
* Extension for `micromark` that can be passed in `extensions` to enable MDX
* syntax.
*/
export function mdxjs(options) {
const settings = Object.assign(
{
acorn: Parser.extend(acornJsx()),
acornOptions: {ecmaVersion: 2024, sourceType: 'module'},
addResult: true
},
options
)
return combineExtensions([
mdxjsEsm(settings),
mdxExpression(settings),
mdxJsx(settings),
mdxMd()
])
}