🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
72
node_modules/micromark-extension-mdx-jsx/dev/lib/syntax.js
generated
vendored
Normal file
72
node_modules/micromark-extension-mdx-jsx/dev/lib/syntax.js
generated
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/**
|
||||
* @typedef {import('micromark-util-types').Extension} Extension
|
||||
* @typedef {import('micromark-factory-mdx-expression').Acorn} Acorn
|
||||
* @typedef {import('micromark-factory-mdx-expression').AcornOptions} AcornOptions
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef Options
|
||||
* Configuration (optional).
|
||||
* @property {Acorn | null | undefined} [acorn]
|
||||
* Acorn parser to use (optional).
|
||||
* @property {AcornOptions | null | undefined} [acornOptions]
|
||||
* Configuration for acorn (default: `{ecmaVersion: 2020, locations: true,
|
||||
* sourceType: 'module'}`).
|
||||
*
|
||||
* All fields except `locations` can be set.
|
||||
* @property {boolean | null | undefined} [addResult=false]
|
||||
* Whether to add `estree` fields to tokens with results from acorn.
|
||||
*/
|
||||
|
||||
import {codes} from 'micromark-util-symbol/codes.js'
|
||||
import {jsxText} from './jsx-text.js'
|
||||
import {jsxFlow} from './jsx-flow.js'
|
||||
|
||||
/**
|
||||
* Create an extension for `micromark` to enable MDX JSX syntax.
|
||||
*
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns {Extension}
|
||||
* Extension for `micromark` that can be passed in `extensions` to enable MDX
|
||||
* JSX syntax.
|
||||
*/
|
||||
export function mdxJsx(options) {
|
||||
const settings = options || {}
|
||||
const acorn = settings.acorn
|
||||
/** @type {AcornOptions | undefined} */
|
||||
let acornOptions
|
||||
|
||||
if (acorn) {
|
||||
if (!acorn.parse || !acorn.parseExpressionAt) {
|
||||
throw new Error(
|
||||
'Expected a proper `acorn` instance passed in as `options.acorn`'
|
||||
)
|
||||
}
|
||||
|
||||
acornOptions = Object.assign(
|
||||
{ecmaVersion: 2020, sourceType: 'module'},
|
||||
settings.acornOptions,
|
||||
{locations: true}
|
||||
)
|
||||
} else if (settings.acornOptions || settings.addResult) {
|
||||
throw new Error('Expected an `acorn` instance passed in as `options.acorn`')
|
||||
}
|
||||
|
||||
return {
|
||||
flow: {
|
||||
[codes.lessThan]: jsxFlow(
|
||||
acorn || undefined,
|
||||
acornOptions,
|
||||
settings.addResult || false
|
||||
)
|
||||
},
|
||||
text: {
|
||||
[codes.lessThan]: jsxText(
|
||||
acorn || undefined,
|
||||
acornOptions,
|
||||
settings.addResult || false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue