🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
67
node_modules/micromark-extension-mdx-jsx/dev/index.d.ts
generated
vendored
Normal file
67
node_modules/micromark-extension-mdx-jsx/dev/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import type {Program} from 'estree'
|
||||
|
||||
export {mdxJsx, type Options} from './lib/syntax.js'
|
||||
|
||||
declare module 'micromark-util-types' {
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
||||
interface Token {
|
||||
estree?: Program
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
||||
interface TokenTypeMap {
|
||||
esWhitespace: 'esWhitespace'
|
||||
|
||||
mdxJsxFlowTag: 'mdxJsxFlowTag'
|
||||
mdxJsxFlowTagMarker: 'mdxJsxFlowTagMarker'
|
||||
mdxJsxFlowTagClosingMarker: 'mdxJsxFlowTagClosingMarker'
|
||||
mdxJsxFlowTagSelfClosingMarker: 'mdxJsxFlowTagSelfClosingMarker'
|
||||
mdxJsxFlowTagName: 'mdxJsxFlowTagName'
|
||||
mdxJsxFlowTagNamePrimary: 'mdxJsxFlowTagNamePrimary'
|
||||
mdxJsxFlowTagNameMemberMarker: 'mdxJsxFlowTagNameMemberMarker'
|
||||
mdxJsxFlowTagNameMember: 'mdxJsxFlowTagNameMember'
|
||||
mdxJsxFlowTagNamePrefixMarker: 'mdxJsxFlowTagNamePrefixMarker'
|
||||
mdxJsxFlowTagNameLocal: 'mdxJsxFlowTagNameLocal'
|
||||
mdxJsxFlowTagExpressionAttribute: 'mdxJsxFlowTagExpressionAttribute'
|
||||
mdxJsxFlowTagExpressionAttributeMarker: 'mdxJsxFlowTagExpressionAttributeMarker'
|
||||
mdxJsxFlowTagExpressionAttributeValue: 'mdxJsxFlowTagExpressionAttributeValue'
|
||||
mdxJsxFlowTagAttribute: 'mdxJsxFlowTagAttribute'
|
||||
mdxJsxFlowTagAttributeName: 'mdxJsxFlowTagAttributeName'
|
||||
mdxJsxFlowTagAttributeNamePrimary: 'mdxJsxFlowTagAttributeNamePrimary'
|
||||
mdxJsxFlowTagAttributeNamePrefixMarker: 'mdxJsxFlowTagAttributeNamePrefixMarker'
|
||||
mdxJsxFlowTagAttributeNameLocal: 'mdxJsxFlowTagAttributeNameLocal'
|
||||
mdxJsxFlowTagAttributeInitializerMarker: 'mdxJsxFlowTagAttributeInitializerMarker'
|
||||
mdxJsxFlowTagAttributeValueLiteral: 'mdxJsxFlowTagAttributeValueLiteral'
|
||||
mdxJsxFlowTagAttributeValueLiteralMarker: 'mdxJsxFlowTagAttributeValueLiteralMarker'
|
||||
mdxJsxFlowTagAttributeValueLiteralValue: 'mdxJsxFlowTagAttributeValueLiteralValue'
|
||||
mdxJsxFlowTagAttributeValueExpression: 'mdxJsxFlowTagAttributeValueExpression'
|
||||
mdxJsxFlowTagAttributeValueExpressionMarker: 'mdxJsxFlowTagAttributeValueExpressionMarker'
|
||||
mdxJsxFlowTagAttributeValueExpressionValue: 'mdxJsxFlowTagAttributeValueExpressionValue'
|
||||
|
||||
mdxJsxTextTag: 'mdxJsxTextTag'
|
||||
mdxJsxTextTagMarker: 'mdxJsxTextTagMarker'
|
||||
mdxJsxTextTagClosingMarker: 'mdxJsxTextTagClosingMarker'
|
||||
mdxJsxTextTagSelfClosingMarker: 'mdxJsxTextTagSelfClosingMarker'
|
||||
mdxJsxTextTagName: 'mdxJsxTextTagName'
|
||||
mdxJsxTextTagNamePrimary: 'mdxJsxTextTagNamePrimary'
|
||||
mdxJsxTextTagNameMemberMarker: 'mdxJsxTextTagNameMemberMarker'
|
||||
mdxJsxTextTagNameMember: 'mdxJsxTextTagNameMember'
|
||||
mdxJsxTextTagNamePrefixMarker: 'mdxJsxTextTagNamePrefixMarker'
|
||||
mdxJsxTextTagNameLocal: 'mdxJsxTextTagNameLocal'
|
||||
mdxJsxTextTagExpressionAttribute: 'mdxJsxTextTagExpressionAttribute'
|
||||
mdxJsxTextTagExpressionAttributeMarker: 'mdxJsxTextTagExpressionAttributeMarker'
|
||||
mdxJsxTextTagExpressionAttributeValue: 'mdxJsxTextTagExpressionAttributeValue'
|
||||
mdxJsxTextTagAttribute: 'mdxJsxTextTagAttribute'
|
||||
mdxJsxTextTagAttributeName: 'mdxJsxTextTagAttributeName'
|
||||
mdxJsxTextTagAttributeNamePrimary: 'mdxJsxTextTagAttributeNamePrimary'
|
||||
mdxJsxTextTagAttributeNamePrefixMarker: 'mdxJsxTextTagAttributeNamePrefixMarker'
|
||||
mdxJsxTextTagAttributeNameLocal: 'mdxJsxTextTagAttributeNameLocal'
|
||||
mdxJsxTextTagAttributeInitializerMarker: 'mdxJsxTextTagAttributeInitializerMarker'
|
||||
mdxJsxTextTagAttributeValueLiteral: 'mdxJsxTextTagAttributeValueLiteral'
|
||||
mdxJsxTextTagAttributeValueLiteralMarker: 'mdxJsxTextTagAttributeValueLiteralMarker'
|
||||
mdxJsxTextTagAttributeValueLiteralValue: 'mdxJsxTextTagAttributeValueLiteralValue'
|
||||
mdxJsxTextTagAttributeValueExpression: 'mdxJsxTextTagAttributeValueExpression'
|
||||
mdxJsxTextTagAttributeValueExpressionMarker: 'mdxJsxTextTagAttributeValueExpressionMarker'
|
||||
mdxJsxTextTagAttributeValueExpressionValue: 'mdxJsxTextTagAttributeValueExpressionValue'
|
||||
}
|
||||
}
|
||||
2
node_modules/micromark-extension-mdx-jsx/dev/index.js
generated
vendored
Normal file
2
node_modules/micromark-extension-mdx-jsx/dev/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
// Note: more types exposed from `index.d.ts`.
|
||||
export {mdxJsx} from './lib/syntax.js'
|
||||
80
node_modules/micromark-extension-mdx-jsx/dev/lib/factory-tag.d.ts
generated
vendored
Normal file
80
node_modules/micromark-extension-mdx-jsx/dev/lib/factory-tag.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* @this {TokenizeContext}
|
||||
* @param {Effects} effects
|
||||
* @param {State} ok
|
||||
* @param {State} nok
|
||||
* @param {Acorn | undefined} acorn
|
||||
* @param {AcornOptions | undefined} acornOptions
|
||||
* @param {boolean | undefined} addResult
|
||||
* @param {boolean | undefined} allowLazy
|
||||
* @param {TokenType} tagType
|
||||
* @param {TokenType} tagMarkerType
|
||||
* @param {TokenType} tagClosingMarkerType
|
||||
* @param {TokenType} tagSelfClosingMarker
|
||||
* @param {TokenType} tagNameType
|
||||
* @param {TokenType} tagNamePrimaryType
|
||||
* @param {TokenType} tagNameMemberMarkerType
|
||||
* @param {TokenType} tagNameMemberType
|
||||
* @param {TokenType} tagNamePrefixMarkerType
|
||||
* @param {TokenType} tagNameLocalType
|
||||
* @param {TokenType} tagExpressionAttributeType
|
||||
* @param {TokenType} tagExpressionAttributeMarkerType
|
||||
* @param {TokenType} tagExpressionAttributeValueType
|
||||
* @param {TokenType} tagAttributeType
|
||||
* @param {TokenType} tagAttributeNameType
|
||||
* @param {TokenType} tagAttributeNamePrimaryType
|
||||
* @param {TokenType} tagAttributeNamePrefixMarkerType
|
||||
* @param {TokenType} tagAttributeNameLocalType
|
||||
* @param {TokenType} tagAttributeInitializerMarkerType
|
||||
* @param {TokenType} tagAttributeValueLiteralType
|
||||
* @param {TokenType} tagAttributeValueLiteralMarkerType
|
||||
* @param {TokenType} tagAttributeValueLiteralValueType
|
||||
* @param {TokenType} tagAttributeValueExpressionType
|
||||
* @param {TokenType} tagAttributeValueExpressionMarkerType
|
||||
* @param {TokenType} tagAttributeValueExpressionValueType
|
||||
*/
|
||||
export function factoryTag(
|
||||
this: import('micromark-util-types').TokenizeContext,
|
||||
effects: Effects,
|
||||
ok: State,
|
||||
nok: State,
|
||||
acorn: Acorn | undefined,
|
||||
acornOptions: AcornOptions | undefined,
|
||||
addResult: boolean | undefined,
|
||||
allowLazy: boolean | undefined,
|
||||
tagType: TokenType,
|
||||
tagMarkerType: TokenType,
|
||||
tagClosingMarkerType: TokenType,
|
||||
tagSelfClosingMarker: TokenType,
|
||||
tagNameType: TokenType,
|
||||
tagNamePrimaryType: TokenType,
|
||||
tagNameMemberMarkerType: TokenType,
|
||||
tagNameMemberType: TokenType,
|
||||
tagNamePrefixMarkerType: TokenType,
|
||||
tagNameLocalType: TokenType,
|
||||
tagExpressionAttributeType: TokenType,
|
||||
tagExpressionAttributeMarkerType: TokenType,
|
||||
tagExpressionAttributeValueType: TokenType,
|
||||
tagAttributeType: TokenType,
|
||||
tagAttributeNameType: TokenType,
|
||||
tagAttributeNamePrimaryType: TokenType,
|
||||
tagAttributeNamePrefixMarkerType: TokenType,
|
||||
tagAttributeNameLocalType: TokenType,
|
||||
tagAttributeInitializerMarkerType: TokenType,
|
||||
tagAttributeValueLiteralType: TokenType,
|
||||
tagAttributeValueLiteralMarkerType: TokenType,
|
||||
tagAttributeValueLiteralValueType: TokenType,
|
||||
tagAttributeValueExpressionType: TokenType,
|
||||
tagAttributeValueExpressionMarkerType: TokenType,
|
||||
tagAttributeValueExpressionValueType: TokenType
|
||||
): (
|
||||
code: import('micromark-util-types').Code
|
||||
) => void | import('micromark-util-types').State
|
||||
export type Acorn = import('micromark-factory-mdx-expression').Acorn
|
||||
export type AcornOptions =
|
||||
import('micromark-factory-mdx-expression').AcornOptions
|
||||
export type Code = import('micromark-util-types').Code
|
||||
export type Effects = import('micromark-util-types').Effects
|
||||
export type State = import('micromark-util-types').State
|
||||
export type TokenizeContext = import('micromark-util-types').TokenizeContext
|
||||
export type TokenType = import('micromark-util-types').TokenType
|
||||
1100
node_modules/micromark-extension-mdx-jsx/dev/lib/factory-tag.js
generated
vendored
Normal file
1100
node_modules/micromark-extension-mdx-jsx/dev/lib/factory-tag.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
24
node_modules/micromark-extension-mdx-jsx/dev/lib/jsx-flow.d.ts
generated
vendored
Normal file
24
node_modules/micromark-extension-mdx-jsx/dev/lib/jsx-flow.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Parse JSX (flow).
|
||||
*
|
||||
* @param {Acorn | undefined} acorn
|
||||
* Acorn parser to use (optional).
|
||||
* @param {AcornOptions | undefined} acornOptions
|
||||
* Configuration for acorn.
|
||||
* @param {boolean | undefined} addResult
|
||||
* Whether to add `estree` fields to tokens with results from acorn.
|
||||
* @returns {Construct}
|
||||
* Construct.
|
||||
*/
|
||||
export function jsxFlow(
|
||||
acorn: Acorn | undefined,
|
||||
acornOptions: AcornOptions | undefined,
|
||||
addResult: boolean | undefined
|
||||
): Construct
|
||||
export type Acorn = import('micromark-factory-mdx-expression').Acorn
|
||||
export type AcornOptions =
|
||||
import('micromark-factory-mdx-expression').AcornOptions
|
||||
export type Construct = import('micromark-util-types').Construct
|
||||
export type State = import('micromark-util-types').State
|
||||
export type TokenizeContext = import('micromark-util-types').TokenizeContext
|
||||
export type Tokenizer = import('micromark-util-types').Tokenizer
|
||||
148
node_modules/micromark-extension-mdx-jsx/dev/lib/jsx-flow.js
generated
vendored
Normal file
148
node_modules/micromark-extension-mdx-jsx/dev/lib/jsx-flow.js
generated
vendored
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
/**
|
||||
* @typedef {import('micromark-factory-mdx-expression').Acorn} Acorn
|
||||
* @typedef {import('micromark-factory-mdx-expression').AcornOptions} AcornOptions
|
||||
* @typedef {import('micromark-util-types').Construct} Construct
|
||||
* @typedef {import('micromark-util-types').State} State
|
||||
* @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
|
||||
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
|
||||
*/
|
||||
|
||||
import {markdownLineEnding, markdownSpace} from 'micromark-util-character'
|
||||
import {factorySpace} from 'micromark-factory-space'
|
||||
import {codes} from 'micromark-util-symbol/codes.js'
|
||||
import {types} from 'micromark-util-symbol/types.js'
|
||||
import {ok as assert} from 'uvu/assert'
|
||||
import {factoryTag} from './factory-tag.js'
|
||||
|
||||
/**
|
||||
* Parse JSX (flow).
|
||||
*
|
||||
* @param {Acorn | undefined} acorn
|
||||
* Acorn parser to use (optional).
|
||||
* @param {AcornOptions | undefined} acornOptions
|
||||
* Configuration for acorn.
|
||||
* @param {boolean | undefined} addResult
|
||||
* Whether to add `estree` fields to tokens with results from acorn.
|
||||
* @returns {Construct}
|
||||
* Construct.
|
||||
*/
|
||||
export function jsxFlow(acorn, acornOptions, addResult) {
|
||||
return {tokenize: tokenizeJsxFlow, concrete: true}
|
||||
|
||||
/**
|
||||
* MDX JSX (flow).
|
||||
*
|
||||
* ```markdown
|
||||
* > | <A />
|
||||
* ^^^^^
|
||||
* ```
|
||||
*
|
||||
* @this {TokenizeContext}
|
||||
* @type {Tokenizer}
|
||||
*/
|
||||
function tokenizeJsxFlow(effects, ok, nok) {
|
||||
const self = this
|
||||
|
||||
return start
|
||||
|
||||
/**
|
||||
* Start of MDX: JSX (flow).
|
||||
*
|
||||
* ```markdown
|
||||
* > | <A />
|
||||
* ^
|
||||
* ```
|
||||
*
|
||||
* @type {State}
|
||||
*/
|
||||
function start(code) {
|
||||
// To do: in `markdown-rs`, constructs need to parse the indent themselves.
|
||||
// This should also be introduced in `micromark-js`.
|
||||
assert(code === codes.lessThan, 'expected `<`')
|
||||
return before(code)
|
||||
}
|
||||
|
||||
/**
|
||||
* After optional whitespace, before of MDX JSX (flow).
|
||||
*
|
||||
* ```markdown
|
||||
* > | <A />
|
||||
* ^
|
||||
* ```
|
||||
*
|
||||
* @type {State}
|
||||
*/
|
||||
function before(code) {
|
||||
return factoryTag.call(
|
||||
self,
|
||||
effects,
|
||||
after,
|
||||
nok,
|
||||
acorn,
|
||||
acornOptions,
|
||||
addResult,
|
||||
false,
|
||||
'mdxJsxFlowTag',
|
||||
'mdxJsxFlowTagMarker',
|
||||
'mdxJsxFlowTagClosingMarker',
|
||||
'mdxJsxFlowTagSelfClosingMarker',
|
||||
'mdxJsxFlowTagName',
|
||||
'mdxJsxFlowTagNamePrimary',
|
||||
'mdxJsxFlowTagNameMemberMarker',
|
||||
'mdxJsxFlowTagNameMember',
|
||||
'mdxJsxFlowTagNamePrefixMarker',
|
||||
'mdxJsxFlowTagNameLocal',
|
||||
'mdxJsxFlowTagExpressionAttribute',
|
||||
'mdxJsxFlowTagExpressionAttributeMarker',
|
||||
'mdxJsxFlowTagExpressionAttributeValue',
|
||||
'mdxJsxFlowTagAttribute',
|
||||
'mdxJsxFlowTagAttributeName',
|
||||
'mdxJsxFlowTagAttributeNamePrimary',
|
||||
'mdxJsxFlowTagAttributeNamePrefixMarker',
|
||||
'mdxJsxFlowTagAttributeNameLocal',
|
||||
'mdxJsxFlowTagAttributeInitializerMarker',
|
||||
'mdxJsxFlowTagAttributeValueLiteral',
|
||||
'mdxJsxFlowTagAttributeValueLiteralMarker',
|
||||
'mdxJsxFlowTagAttributeValueLiteralValue',
|
||||
'mdxJsxFlowTagAttributeValueExpression',
|
||||
'mdxJsxFlowTagAttributeValueExpressionMarker',
|
||||
'mdxJsxFlowTagAttributeValueExpressionValue'
|
||||
)(code)
|
||||
}
|
||||
|
||||
/**
|
||||
* After an MDX JSX (flow) tag.
|
||||
*
|
||||
* ```markdown
|
||||
* > | <A>
|
||||
* ^
|
||||
* ```
|
||||
*
|
||||
* @type {State}
|
||||
*/
|
||||
function after(code) {
|
||||
return markdownSpace(code)
|
||||
? factorySpace(effects, end, types.whitespace)(code)
|
||||
: end(code)
|
||||
}
|
||||
|
||||
/**
|
||||
* After an MDX JSX (flow) tag, after optional whitespace.
|
||||
*
|
||||
* ```markdown
|
||||
* > | <A> <B>
|
||||
* ^
|
||||
* ```
|
||||
*
|
||||
* @type {State}
|
||||
*/
|
||||
function end(code) {
|
||||
// Another tag.
|
||||
return code === codes.lessThan
|
||||
? start(code)
|
||||
: code === codes.eof || markdownLineEnding(code)
|
||||
? ok(code)
|
||||
: nok(code)
|
||||
}
|
||||
}
|
||||
}
|
||||
23
node_modules/micromark-extension-mdx-jsx/dev/lib/jsx-text.d.ts
generated
vendored
Normal file
23
node_modules/micromark-extension-mdx-jsx/dev/lib/jsx-text.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* Parse JSX (text).
|
||||
*
|
||||
* @param {Acorn | undefined} acorn
|
||||
* Acorn parser to use (optional).
|
||||
* @param {AcornOptions | undefined} acornOptions
|
||||
* Configuration for acorn.
|
||||
* @param {boolean | undefined} addResult
|
||||
* Whether to add `estree` fields to tokens with results from acorn.
|
||||
* @returns {Construct}
|
||||
* Construct.
|
||||
*/
|
||||
export function jsxText(
|
||||
acorn: Acorn | undefined,
|
||||
acornOptions: AcornOptions | undefined,
|
||||
addResult: boolean | undefined
|
||||
): Construct
|
||||
export type Acorn = import('micromark-factory-mdx-expression').Acorn
|
||||
export type AcornOptions =
|
||||
import('micromark-factory-mdx-expression').AcornOptions
|
||||
export type Construct = import('micromark-util-types').Construct
|
||||
export type TokenizeContext = import('micromark-util-types').TokenizeContext
|
||||
export type Tokenizer = import('micromark-util-types').Tokenizer
|
||||
74
node_modules/micromark-extension-mdx-jsx/dev/lib/jsx-text.js
generated
vendored
Normal file
74
node_modules/micromark-extension-mdx-jsx/dev/lib/jsx-text.js
generated
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/**
|
||||
* @typedef {import('micromark-factory-mdx-expression').Acorn} Acorn
|
||||
* @typedef {import('micromark-factory-mdx-expression').AcornOptions} AcornOptions
|
||||
* @typedef {import('micromark-util-types').Construct} Construct
|
||||
* @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
|
||||
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
|
||||
*/
|
||||
|
||||
import {factoryTag} from './factory-tag.js'
|
||||
|
||||
/**
|
||||
* Parse JSX (text).
|
||||
*
|
||||
* @param {Acorn | undefined} acorn
|
||||
* Acorn parser to use (optional).
|
||||
* @param {AcornOptions | undefined} acornOptions
|
||||
* Configuration for acorn.
|
||||
* @param {boolean | undefined} addResult
|
||||
* Whether to add `estree` fields to tokens with results from acorn.
|
||||
* @returns {Construct}
|
||||
* Construct.
|
||||
*/
|
||||
export function jsxText(acorn, acornOptions, addResult) {
|
||||
return {tokenize: tokenizeJsxText}
|
||||
|
||||
/**
|
||||
* MDX JSX (text).
|
||||
*
|
||||
* ```markdown
|
||||
* > | a <b />.
|
||||
* ^^^^^
|
||||
* ```
|
||||
*
|
||||
* @this {TokenizeContext}
|
||||
* @type {Tokenizer}
|
||||
*/
|
||||
function tokenizeJsxText(effects, ok, nok) {
|
||||
return factoryTag.call(
|
||||
this,
|
||||
effects,
|
||||
ok,
|
||||
nok,
|
||||
acorn,
|
||||
acornOptions,
|
||||
addResult,
|
||||
true,
|
||||
'mdxJsxTextTag',
|
||||
'mdxJsxTextTagMarker',
|
||||
'mdxJsxTextTagClosingMarker',
|
||||
'mdxJsxTextTagSelfClosingMarker',
|
||||
'mdxJsxTextTagName',
|
||||
'mdxJsxTextTagNamePrimary',
|
||||
'mdxJsxTextTagNameMemberMarker',
|
||||
'mdxJsxTextTagNameMember',
|
||||
'mdxJsxTextTagNamePrefixMarker',
|
||||
'mdxJsxTextTagNameLocal',
|
||||
'mdxJsxTextTagExpressionAttribute',
|
||||
'mdxJsxTextTagExpressionAttributeMarker',
|
||||
'mdxJsxTextTagExpressionAttributeValue',
|
||||
'mdxJsxTextTagAttribute',
|
||||
'mdxJsxTextTagAttributeName',
|
||||
'mdxJsxTextTagAttributeNamePrimary',
|
||||
'mdxJsxTextTagAttributeNamePrefixMarker',
|
||||
'mdxJsxTextTagAttributeNameLocal',
|
||||
'mdxJsxTextTagAttributeInitializerMarker',
|
||||
'mdxJsxTextTagAttributeValueLiteral',
|
||||
'mdxJsxTextTagAttributeValueLiteralMarker',
|
||||
'mdxJsxTextTagAttributeValueLiteralValue',
|
||||
'mdxJsxTextTagAttributeValueExpression',
|
||||
'mdxJsxTextTagAttributeValueExpressionMarker',
|
||||
'mdxJsxTextTagAttributeValueExpressionValue'
|
||||
)
|
||||
}
|
||||
}
|
||||
34
node_modules/micromark-extension-mdx-jsx/dev/lib/syntax.d.ts
generated
vendored
Normal file
34
node_modules/micromark-extension-mdx-jsx/dev/lib/syntax.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* 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?: Options | null | undefined): Extension
|
||||
export type Extension = import('micromark-util-types').Extension
|
||||
export type Acorn = import('micromark-factory-mdx-expression').Acorn
|
||||
export type AcornOptions =
|
||||
import('micromark-factory-mdx-expression').AcornOptions
|
||||
/**
|
||||
* Configuration (optional).
|
||||
*/
|
||||
export type Options = {
|
||||
/**
|
||||
* Acorn parser to use (optional).
|
||||
*/
|
||||
acorn?: Acorn | null | undefined
|
||||
/**
|
||||
* Configuration for acorn (default: `{ecmaVersion: 2020, locations: true,
|
||||
* sourceType: 'module'}`).
|
||||
*
|
||||
* All fields except `locations` can be set.
|
||||
*/
|
||||
acornOptions?: AcornOptions | null | undefined
|
||||
/**
|
||||
* Whether to add `estree` fields to tokens with results from acorn.
|
||||
*/
|
||||
addResult?: boolean | null | undefined
|
||||
}
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
67
node_modules/micromark-extension-mdx-jsx/index.d.ts
generated
vendored
Normal file
67
node_modules/micromark-extension-mdx-jsx/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import type {Program} from 'estree'
|
||||
|
||||
export {mdxJsx, type Options} from './lib/syntax.js'
|
||||
|
||||
declare module 'micromark-util-types' {
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
||||
interface Token {
|
||||
estree?: Program
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
||||
interface TokenTypeMap {
|
||||
esWhitespace: 'esWhitespace'
|
||||
|
||||
mdxJsxFlowTag: 'mdxJsxFlowTag'
|
||||
mdxJsxFlowTagMarker: 'mdxJsxFlowTagMarker'
|
||||
mdxJsxFlowTagClosingMarker: 'mdxJsxFlowTagClosingMarker'
|
||||
mdxJsxFlowTagSelfClosingMarker: 'mdxJsxFlowTagSelfClosingMarker'
|
||||
mdxJsxFlowTagName: 'mdxJsxFlowTagName'
|
||||
mdxJsxFlowTagNamePrimary: 'mdxJsxFlowTagNamePrimary'
|
||||
mdxJsxFlowTagNameMemberMarker: 'mdxJsxFlowTagNameMemberMarker'
|
||||
mdxJsxFlowTagNameMember: 'mdxJsxFlowTagNameMember'
|
||||
mdxJsxFlowTagNamePrefixMarker: 'mdxJsxFlowTagNamePrefixMarker'
|
||||
mdxJsxFlowTagNameLocal: 'mdxJsxFlowTagNameLocal'
|
||||
mdxJsxFlowTagExpressionAttribute: 'mdxJsxFlowTagExpressionAttribute'
|
||||
mdxJsxFlowTagExpressionAttributeMarker: 'mdxJsxFlowTagExpressionAttributeMarker'
|
||||
mdxJsxFlowTagExpressionAttributeValue: 'mdxJsxFlowTagExpressionAttributeValue'
|
||||
mdxJsxFlowTagAttribute: 'mdxJsxFlowTagAttribute'
|
||||
mdxJsxFlowTagAttributeName: 'mdxJsxFlowTagAttributeName'
|
||||
mdxJsxFlowTagAttributeNamePrimary: 'mdxJsxFlowTagAttributeNamePrimary'
|
||||
mdxJsxFlowTagAttributeNamePrefixMarker: 'mdxJsxFlowTagAttributeNamePrefixMarker'
|
||||
mdxJsxFlowTagAttributeNameLocal: 'mdxJsxFlowTagAttributeNameLocal'
|
||||
mdxJsxFlowTagAttributeInitializerMarker: 'mdxJsxFlowTagAttributeInitializerMarker'
|
||||
mdxJsxFlowTagAttributeValueLiteral: 'mdxJsxFlowTagAttributeValueLiteral'
|
||||
mdxJsxFlowTagAttributeValueLiteralMarker: 'mdxJsxFlowTagAttributeValueLiteralMarker'
|
||||
mdxJsxFlowTagAttributeValueLiteralValue: 'mdxJsxFlowTagAttributeValueLiteralValue'
|
||||
mdxJsxFlowTagAttributeValueExpression: 'mdxJsxFlowTagAttributeValueExpression'
|
||||
mdxJsxFlowTagAttributeValueExpressionMarker: 'mdxJsxFlowTagAttributeValueExpressionMarker'
|
||||
mdxJsxFlowTagAttributeValueExpressionValue: 'mdxJsxFlowTagAttributeValueExpressionValue'
|
||||
|
||||
mdxJsxTextTag: 'mdxJsxTextTag'
|
||||
mdxJsxTextTagMarker: 'mdxJsxTextTagMarker'
|
||||
mdxJsxTextTagClosingMarker: 'mdxJsxTextTagClosingMarker'
|
||||
mdxJsxTextTagSelfClosingMarker: 'mdxJsxTextTagSelfClosingMarker'
|
||||
mdxJsxTextTagName: 'mdxJsxTextTagName'
|
||||
mdxJsxTextTagNamePrimary: 'mdxJsxTextTagNamePrimary'
|
||||
mdxJsxTextTagNameMemberMarker: 'mdxJsxTextTagNameMemberMarker'
|
||||
mdxJsxTextTagNameMember: 'mdxJsxTextTagNameMember'
|
||||
mdxJsxTextTagNamePrefixMarker: 'mdxJsxTextTagNamePrefixMarker'
|
||||
mdxJsxTextTagNameLocal: 'mdxJsxTextTagNameLocal'
|
||||
mdxJsxTextTagExpressionAttribute: 'mdxJsxTextTagExpressionAttribute'
|
||||
mdxJsxTextTagExpressionAttributeMarker: 'mdxJsxTextTagExpressionAttributeMarker'
|
||||
mdxJsxTextTagExpressionAttributeValue: 'mdxJsxTextTagExpressionAttributeValue'
|
||||
mdxJsxTextTagAttribute: 'mdxJsxTextTagAttribute'
|
||||
mdxJsxTextTagAttributeName: 'mdxJsxTextTagAttributeName'
|
||||
mdxJsxTextTagAttributeNamePrimary: 'mdxJsxTextTagAttributeNamePrimary'
|
||||
mdxJsxTextTagAttributeNamePrefixMarker: 'mdxJsxTextTagAttributeNamePrefixMarker'
|
||||
mdxJsxTextTagAttributeNameLocal: 'mdxJsxTextTagAttributeNameLocal'
|
||||
mdxJsxTextTagAttributeInitializerMarker: 'mdxJsxTextTagAttributeInitializerMarker'
|
||||
mdxJsxTextTagAttributeValueLiteral: 'mdxJsxTextTagAttributeValueLiteral'
|
||||
mdxJsxTextTagAttributeValueLiteralMarker: 'mdxJsxTextTagAttributeValueLiteralMarker'
|
||||
mdxJsxTextTagAttributeValueLiteralValue: 'mdxJsxTextTagAttributeValueLiteralValue'
|
||||
mdxJsxTextTagAttributeValueExpression: 'mdxJsxTextTagAttributeValueExpression'
|
||||
mdxJsxTextTagAttributeValueExpressionMarker: 'mdxJsxTextTagAttributeValueExpressionMarker'
|
||||
mdxJsxTextTagAttributeValueExpressionValue: 'mdxJsxTextTagAttributeValueExpressionValue'
|
||||
}
|
||||
}
|
||||
2
node_modules/micromark-extension-mdx-jsx/index.js
generated
vendored
Normal file
2
node_modules/micromark-extension-mdx-jsx/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
// Note: more types exposed from `index.d.ts`.
|
||||
export {mdxJsx} from './lib/syntax.js'
|
||||
80
node_modules/micromark-extension-mdx-jsx/lib/factory-tag.d.ts
generated
vendored
Normal file
80
node_modules/micromark-extension-mdx-jsx/lib/factory-tag.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* @this {TokenizeContext}
|
||||
* @param {Effects} effects
|
||||
* @param {State} ok
|
||||
* @param {State} nok
|
||||
* @param {Acorn | undefined} acorn
|
||||
* @param {AcornOptions | undefined} acornOptions
|
||||
* @param {boolean | undefined} addResult
|
||||
* @param {boolean | undefined} allowLazy
|
||||
* @param {TokenType} tagType
|
||||
* @param {TokenType} tagMarkerType
|
||||
* @param {TokenType} tagClosingMarkerType
|
||||
* @param {TokenType} tagSelfClosingMarker
|
||||
* @param {TokenType} tagNameType
|
||||
* @param {TokenType} tagNamePrimaryType
|
||||
* @param {TokenType} tagNameMemberMarkerType
|
||||
* @param {TokenType} tagNameMemberType
|
||||
* @param {TokenType} tagNamePrefixMarkerType
|
||||
* @param {TokenType} tagNameLocalType
|
||||
* @param {TokenType} tagExpressionAttributeType
|
||||
* @param {TokenType} tagExpressionAttributeMarkerType
|
||||
* @param {TokenType} tagExpressionAttributeValueType
|
||||
* @param {TokenType} tagAttributeType
|
||||
* @param {TokenType} tagAttributeNameType
|
||||
* @param {TokenType} tagAttributeNamePrimaryType
|
||||
* @param {TokenType} tagAttributeNamePrefixMarkerType
|
||||
* @param {TokenType} tagAttributeNameLocalType
|
||||
* @param {TokenType} tagAttributeInitializerMarkerType
|
||||
* @param {TokenType} tagAttributeValueLiteralType
|
||||
* @param {TokenType} tagAttributeValueLiteralMarkerType
|
||||
* @param {TokenType} tagAttributeValueLiteralValueType
|
||||
* @param {TokenType} tagAttributeValueExpressionType
|
||||
* @param {TokenType} tagAttributeValueExpressionMarkerType
|
||||
* @param {TokenType} tagAttributeValueExpressionValueType
|
||||
*/
|
||||
export function factoryTag(
|
||||
this: import('micromark-util-types').TokenizeContext,
|
||||
effects: Effects,
|
||||
ok: State,
|
||||
nok: State,
|
||||
acorn: Acorn | undefined,
|
||||
acornOptions: AcornOptions | undefined,
|
||||
addResult: boolean | undefined,
|
||||
allowLazy: boolean | undefined,
|
||||
tagType: TokenType,
|
||||
tagMarkerType: TokenType,
|
||||
tagClosingMarkerType: TokenType,
|
||||
tagSelfClosingMarker: TokenType,
|
||||
tagNameType: TokenType,
|
||||
tagNamePrimaryType: TokenType,
|
||||
tagNameMemberMarkerType: TokenType,
|
||||
tagNameMemberType: TokenType,
|
||||
tagNamePrefixMarkerType: TokenType,
|
||||
tagNameLocalType: TokenType,
|
||||
tagExpressionAttributeType: TokenType,
|
||||
tagExpressionAttributeMarkerType: TokenType,
|
||||
tagExpressionAttributeValueType: TokenType,
|
||||
tagAttributeType: TokenType,
|
||||
tagAttributeNameType: TokenType,
|
||||
tagAttributeNamePrimaryType: TokenType,
|
||||
tagAttributeNamePrefixMarkerType: TokenType,
|
||||
tagAttributeNameLocalType: TokenType,
|
||||
tagAttributeInitializerMarkerType: TokenType,
|
||||
tagAttributeValueLiteralType: TokenType,
|
||||
tagAttributeValueLiteralMarkerType: TokenType,
|
||||
tagAttributeValueLiteralValueType: TokenType,
|
||||
tagAttributeValueExpressionType: TokenType,
|
||||
tagAttributeValueExpressionMarkerType: TokenType,
|
||||
tagAttributeValueExpressionValueType: TokenType
|
||||
): (
|
||||
code: import('micromark-util-types').Code
|
||||
) => void | import('micromark-util-types').State
|
||||
export type Acorn = import('micromark-factory-mdx-expression').Acorn
|
||||
export type AcornOptions =
|
||||
import('micromark-factory-mdx-expression').AcornOptions
|
||||
export type Code = import('micromark-util-types').Code
|
||||
export type Effects = import('micromark-util-types').Effects
|
||||
export type State = import('micromark-util-types').State
|
||||
export type TokenizeContext = import('micromark-util-types').TokenizeContext
|
||||
export type TokenType = import('micromark-util-types').TokenType
|
||||
1054
node_modules/micromark-extension-mdx-jsx/lib/factory-tag.js
generated
vendored
Normal file
1054
node_modules/micromark-extension-mdx-jsx/lib/factory-tag.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
24
node_modules/micromark-extension-mdx-jsx/lib/jsx-flow.d.ts
generated
vendored
Normal file
24
node_modules/micromark-extension-mdx-jsx/lib/jsx-flow.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Parse JSX (flow).
|
||||
*
|
||||
* @param {Acorn | undefined} acorn
|
||||
* Acorn parser to use (optional).
|
||||
* @param {AcornOptions | undefined} acornOptions
|
||||
* Configuration for acorn.
|
||||
* @param {boolean | undefined} addResult
|
||||
* Whether to add `estree` fields to tokens with results from acorn.
|
||||
* @returns {Construct}
|
||||
* Construct.
|
||||
*/
|
||||
export function jsxFlow(
|
||||
acorn: Acorn | undefined,
|
||||
acornOptions: AcornOptions | undefined,
|
||||
addResult: boolean | undefined
|
||||
): Construct
|
||||
export type Acorn = import('micromark-factory-mdx-expression').Acorn
|
||||
export type AcornOptions =
|
||||
import('micromark-factory-mdx-expression').AcornOptions
|
||||
export type Construct = import('micromark-util-types').Construct
|
||||
export type State = import('micromark-util-types').State
|
||||
export type TokenizeContext = import('micromark-util-types').TokenizeContext
|
||||
export type Tokenizer = import('micromark-util-types').Tokenizer
|
||||
147
node_modules/micromark-extension-mdx-jsx/lib/jsx-flow.js
generated
vendored
Normal file
147
node_modules/micromark-extension-mdx-jsx/lib/jsx-flow.js
generated
vendored
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
/**
|
||||
* @typedef {import('micromark-factory-mdx-expression').Acorn} Acorn
|
||||
* @typedef {import('micromark-factory-mdx-expression').AcornOptions} AcornOptions
|
||||
* @typedef {import('micromark-util-types').Construct} Construct
|
||||
* @typedef {import('micromark-util-types').State} State
|
||||
* @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
|
||||
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
|
||||
*/
|
||||
|
||||
import {markdownLineEnding, markdownSpace} from 'micromark-util-character'
|
||||
import {factorySpace} from 'micromark-factory-space'
|
||||
import {factoryTag} from './factory-tag.js'
|
||||
|
||||
/**
|
||||
* Parse JSX (flow).
|
||||
*
|
||||
* @param {Acorn | undefined} acorn
|
||||
* Acorn parser to use (optional).
|
||||
* @param {AcornOptions | undefined} acornOptions
|
||||
* Configuration for acorn.
|
||||
* @param {boolean | undefined} addResult
|
||||
* Whether to add `estree` fields to tokens with results from acorn.
|
||||
* @returns {Construct}
|
||||
* Construct.
|
||||
*/
|
||||
export function jsxFlow(acorn, acornOptions, addResult) {
|
||||
return {
|
||||
tokenize: tokenizeJsxFlow,
|
||||
concrete: true
|
||||
}
|
||||
|
||||
/**
|
||||
* MDX JSX (flow).
|
||||
*
|
||||
* ```markdown
|
||||
* > | <A />
|
||||
* ^^^^^
|
||||
* ```
|
||||
*
|
||||
* @this {TokenizeContext}
|
||||
* @type {Tokenizer}
|
||||
*/
|
||||
function tokenizeJsxFlow(effects, ok, nok) {
|
||||
const self = this
|
||||
return start
|
||||
|
||||
/**
|
||||
* Start of MDX: JSX (flow).
|
||||
*
|
||||
* ```markdown
|
||||
* > | <A />
|
||||
* ^
|
||||
* ```
|
||||
*
|
||||
* @type {State}
|
||||
*/
|
||||
function start(code) {
|
||||
// To do: in `markdown-rs`, constructs need to parse the indent themselves.
|
||||
// This should also be introduced in `micromark-js`.
|
||||
|
||||
return before(code)
|
||||
}
|
||||
|
||||
/**
|
||||
* After optional whitespace, before of MDX JSX (flow).
|
||||
*
|
||||
* ```markdown
|
||||
* > | <A />
|
||||
* ^
|
||||
* ```
|
||||
*
|
||||
* @type {State}
|
||||
*/
|
||||
function before(code) {
|
||||
return factoryTag.call(
|
||||
self,
|
||||
effects,
|
||||
after,
|
||||
nok,
|
||||
acorn,
|
||||
acornOptions,
|
||||
addResult,
|
||||
false,
|
||||
'mdxJsxFlowTag',
|
||||
'mdxJsxFlowTagMarker',
|
||||
'mdxJsxFlowTagClosingMarker',
|
||||
'mdxJsxFlowTagSelfClosingMarker',
|
||||
'mdxJsxFlowTagName',
|
||||
'mdxJsxFlowTagNamePrimary',
|
||||
'mdxJsxFlowTagNameMemberMarker',
|
||||
'mdxJsxFlowTagNameMember',
|
||||
'mdxJsxFlowTagNamePrefixMarker',
|
||||
'mdxJsxFlowTagNameLocal',
|
||||
'mdxJsxFlowTagExpressionAttribute',
|
||||
'mdxJsxFlowTagExpressionAttributeMarker',
|
||||
'mdxJsxFlowTagExpressionAttributeValue',
|
||||
'mdxJsxFlowTagAttribute',
|
||||
'mdxJsxFlowTagAttributeName',
|
||||
'mdxJsxFlowTagAttributeNamePrimary',
|
||||
'mdxJsxFlowTagAttributeNamePrefixMarker',
|
||||
'mdxJsxFlowTagAttributeNameLocal',
|
||||
'mdxJsxFlowTagAttributeInitializerMarker',
|
||||
'mdxJsxFlowTagAttributeValueLiteral',
|
||||
'mdxJsxFlowTagAttributeValueLiteralMarker',
|
||||
'mdxJsxFlowTagAttributeValueLiteralValue',
|
||||
'mdxJsxFlowTagAttributeValueExpression',
|
||||
'mdxJsxFlowTagAttributeValueExpressionMarker',
|
||||
'mdxJsxFlowTagAttributeValueExpressionValue'
|
||||
)(code)
|
||||
}
|
||||
|
||||
/**
|
||||
* After an MDX JSX (flow) tag.
|
||||
*
|
||||
* ```markdown
|
||||
* > | <A>
|
||||
* ^
|
||||
* ```
|
||||
*
|
||||
* @type {State}
|
||||
*/
|
||||
function after(code) {
|
||||
return markdownSpace(code)
|
||||
? factorySpace(effects, end, 'whitespace')(code)
|
||||
: end(code)
|
||||
}
|
||||
|
||||
/**
|
||||
* After an MDX JSX (flow) tag, after optional whitespace.
|
||||
*
|
||||
* ```markdown
|
||||
* > | <A> <B>
|
||||
* ^
|
||||
* ```
|
||||
*
|
||||
* @type {State}
|
||||
*/
|
||||
function end(code) {
|
||||
// Another tag.
|
||||
return code === 60
|
||||
? start(code)
|
||||
: code === null || markdownLineEnding(code)
|
||||
? ok(code)
|
||||
: nok(code)
|
||||
}
|
||||
}
|
||||
}
|
||||
23
node_modules/micromark-extension-mdx-jsx/lib/jsx-text.d.ts
generated
vendored
Normal file
23
node_modules/micromark-extension-mdx-jsx/lib/jsx-text.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* Parse JSX (text).
|
||||
*
|
||||
* @param {Acorn | undefined} acorn
|
||||
* Acorn parser to use (optional).
|
||||
* @param {AcornOptions | undefined} acornOptions
|
||||
* Configuration for acorn.
|
||||
* @param {boolean | undefined} addResult
|
||||
* Whether to add `estree` fields to tokens with results from acorn.
|
||||
* @returns {Construct}
|
||||
* Construct.
|
||||
*/
|
||||
export function jsxText(
|
||||
acorn: Acorn | undefined,
|
||||
acornOptions: AcornOptions | undefined,
|
||||
addResult: boolean | undefined
|
||||
): Construct
|
||||
export type Acorn = import('micromark-factory-mdx-expression').Acorn
|
||||
export type AcornOptions =
|
||||
import('micromark-factory-mdx-expression').AcornOptions
|
||||
export type Construct = import('micromark-util-types').Construct
|
||||
export type TokenizeContext = import('micromark-util-types').TokenizeContext
|
||||
export type Tokenizer = import('micromark-util-types').Tokenizer
|
||||
76
node_modules/micromark-extension-mdx-jsx/lib/jsx-text.js
generated
vendored
Normal file
76
node_modules/micromark-extension-mdx-jsx/lib/jsx-text.js
generated
vendored
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/**
|
||||
* @typedef {import('micromark-factory-mdx-expression').Acorn} Acorn
|
||||
* @typedef {import('micromark-factory-mdx-expression').AcornOptions} AcornOptions
|
||||
* @typedef {import('micromark-util-types').Construct} Construct
|
||||
* @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
|
||||
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
|
||||
*/
|
||||
|
||||
import {factoryTag} from './factory-tag.js'
|
||||
|
||||
/**
|
||||
* Parse JSX (text).
|
||||
*
|
||||
* @param {Acorn | undefined} acorn
|
||||
* Acorn parser to use (optional).
|
||||
* @param {AcornOptions | undefined} acornOptions
|
||||
* Configuration for acorn.
|
||||
* @param {boolean | undefined} addResult
|
||||
* Whether to add `estree` fields to tokens with results from acorn.
|
||||
* @returns {Construct}
|
||||
* Construct.
|
||||
*/
|
||||
export function jsxText(acorn, acornOptions, addResult) {
|
||||
return {
|
||||
tokenize: tokenizeJsxText
|
||||
}
|
||||
|
||||
/**
|
||||
* MDX JSX (text).
|
||||
*
|
||||
* ```markdown
|
||||
* > | a <b />.
|
||||
* ^^^^^
|
||||
* ```
|
||||
*
|
||||
* @this {TokenizeContext}
|
||||
* @type {Tokenizer}
|
||||
*/
|
||||
function tokenizeJsxText(effects, ok, nok) {
|
||||
return factoryTag.call(
|
||||
this,
|
||||
effects,
|
||||
ok,
|
||||
nok,
|
||||
acorn,
|
||||
acornOptions,
|
||||
addResult,
|
||||
true,
|
||||
'mdxJsxTextTag',
|
||||
'mdxJsxTextTagMarker',
|
||||
'mdxJsxTextTagClosingMarker',
|
||||
'mdxJsxTextTagSelfClosingMarker',
|
||||
'mdxJsxTextTagName',
|
||||
'mdxJsxTextTagNamePrimary',
|
||||
'mdxJsxTextTagNameMemberMarker',
|
||||
'mdxJsxTextTagNameMember',
|
||||
'mdxJsxTextTagNamePrefixMarker',
|
||||
'mdxJsxTextTagNameLocal',
|
||||
'mdxJsxTextTagExpressionAttribute',
|
||||
'mdxJsxTextTagExpressionAttributeMarker',
|
||||
'mdxJsxTextTagExpressionAttributeValue',
|
||||
'mdxJsxTextTagAttribute',
|
||||
'mdxJsxTextTagAttributeName',
|
||||
'mdxJsxTextTagAttributeNamePrimary',
|
||||
'mdxJsxTextTagAttributeNamePrefixMarker',
|
||||
'mdxJsxTextTagAttributeNameLocal',
|
||||
'mdxJsxTextTagAttributeInitializerMarker',
|
||||
'mdxJsxTextTagAttributeValueLiteral',
|
||||
'mdxJsxTextTagAttributeValueLiteralMarker',
|
||||
'mdxJsxTextTagAttributeValueLiteralValue',
|
||||
'mdxJsxTextTagAttributeValueExpression',
|
||||
'mdxJsxTextTagAttributeValueExpressionMarker',
|
||||
'mdxJsxTextTagAttributeValueExpressionValue'
|
||||
)
|
||||
}
|
||||
}
|
||||
34
node_modules/micromark-extension-mdx-jsx/lib/syntax.d.ts
generated
vendored
Normal file
34
node_modules/micromark-extension-mdx-jsx/lib/syntax.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* 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?: Options | null | undefined): Extension
|
||||
export type Extension = import('micromark-util-types').Extension
|
||||
export type Acorn = import('micromark-factory-mdx-expression').Acorn
|
||||
export type AcornOptions =
|
||||
import('micromark-factory-mdx-expression').AcornOptions
|
||||
/**
|
||||
* Configuration (optional).
|
||||
*/
|
||||
export type Options = {
|
||||
/**
|
||||
* Acorn parser to use (optional).
|
||||
*/
|
||||
acorn?: Acorn | null | undefined
|
||||
/**
|
||||
* Configuration for acorn (default: `{ecmaVersion: 2020, locations: true,
|
||||
* sourceType: 'module'}`).
|
||||
*
|
||||
* All fields except `locations` can be set.
|
||||
*/
|
||||
acornOptions?: AcornOptions | null | undefined
|
||||
/**
|
||||
* Whether to add `estree` fields to tokens with results from acorn.
|
||||
*/
|
||||
addResult?: boolean | null | undefined
|
||||
}
|
||||
73
node_modules/micromark-extension-mdx-jsx/lib/syntax.js
generated
vendored
Normal file
73
node_modules/micromark-extension-mdx-jsx/lib/syntax.js
generated
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/**
|
||||
* @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 {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: {
|
||||
[60]: jsxFlow(
|
||||
acorn || undefined,
|
||||
acornOptions,
|
||||
settings.addResult || false
|
||||
)
|
||||
},
|
||||
text: {
|
||||
[60]: jsxText(
|
||||
acorn || undefined,
|
||||
acornOptions,
|
||||
settings.addResult || false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
22
node_modules/micromark-extension-mdx-jsx/license
generated
vendored
Normal file
22
node_modules/micromark-extension-mdx-jsx/license
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2020 Titus Wormer <tituswormer@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
1
node_modules/micromark-extension-mdx-jsx/node_modules/.bin/uvu
generated
vendored
Symbolic link
1
node_modules/micromark-extension-mdx-jsx/node_modules/.bin/uvu
generated
vendored
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../uvu/bin.js
|
||||
111
node_modules/micromark-extension-mdx-jsx/package.json
generated
vendored
Normal file
111
node_modules/micromark-extension-mdx-jsx/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
{
|
||||
"name": "micromark-extension-mdx-jsx",
|
||||
"version": "1.0.5",
|
||||
"description": "micromark extension to support MDX or MDX.js JSX",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"micromark",
|
||||
"micromark-extension",
|
||||
"mdx",
|
||||
"mdxjs",
|
||||
"jsx",
|
||||
"js",
|
||||
"javascript",
|
||||
"es",
|
||||
"ecmascript",
|
||||
"markdown",
|
||||
"unified"
|
||||
],
|
||||
"repository": "micromark/micromark-extension-mdx-jsx",
|
||||
"bugs": "https://github.com/micromark/micromark-extension-mdx-jsx/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"files": [
|
||||
"dev/",
|
||||
"lib/",
|
||||
"index.d.ts",
|
||||
"index.js"
|
||||
],
|
||||
"exports": {
|
||||
"development": "./dev/index.js",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/acorn": "^4.0.0",
|
||||
"@types/estree": "^1.0.0",
|
||||
"estree-util-is-identifier-name": "^2.0.0",
|
||||
"micromark-factory-mdx-expression": "^1.0.0",
|
||||
"micromark-factory-space": "^1.0.0",
|
||||
"micromark-util-character": "^1.0.0",
|
||||
"micromark-util-symbol": "^1.0.0",
|
||||
"micromark-util-types": "^1.0.0",
|
||||
"uvu": "^0.5.0",
|
||||
"vfile-message": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/estree": "^1.0.0",
|
||||
"@types/estree-jsx": "^1.0.0",
|
||||
"@types/mdast": "^3.0.0",
|
||||
"@types/node": "^20.0.0",
|
||||
"acorn": "^8.0.0",
|
||||
"acorn-jsx": "^5.0.0",
|
||||
"c8": "^7.0.0",
|
||||
"estree-util-visit": "^1.0.0",
|
||||
"mdast-zone": "^5.0.0",
|
||||
"micromark": "^3.0.0",
|
||||
"micromark-build": "^1.0.0",
|
||||
"prettier": "^2.0.0",
|
||||
"remark-cli": "^11.0.0",
|
||||
"remark-preset-wooorm": "^9.0.0",
|
||||
"type-coverage": "^2.0.0",
|
||||
"typescript": "^5.0.0",
|
||||
"xo": "^0.54.0"
|
||||
},
|
||||
"scripts": {
|
||||
"prepack": "npm run build && npm run format",
|
||||
"build": "tsc --build --clean && tsc --build && type-coverage && micromark-build",
|
||||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
|
||||
"test-api-prod": "node --conditions production test/index.js",
|
||||
"test-api-dev": "node --conditions development test/index.js",
|
||||
"test-api": "npm run test-api-dev && npm run test-api-prod",
|
||||
"test-coverage": "c8 --100 --reporter lcov npm run test-api",
|
||||
"test": "npm run build && npm run format && npm run test-coverage"
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"singleQuote": true,
|
||||
"bracketSpacing": false,
|
||||
"semi": false,
|
||||
"trailingComma": "none"
|
||||
},
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"rules": {
|
||||
"n/file-extension-in-import": "off",
|
||||
"unicorn/no-this-assignment": "off"
|
||||
}
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"preset-wooorm",
|
||||
"./script/grammar.js"
|
||||
]
|
||||
},
|
||||
"typeCoverage": {
|
||||
"atLeast": 100,
|
||||
"detail": true,
|
||||
"strict": true,
|
||||
"ignoreCatch": true
|
||||
}
|
||||
}
|
||||
522
node_modules/micromark-extension-mdx-jsx/readme.md
generated
vendored
Normal file
522
node_modules/micromark-extension-mdx-jsx/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,522 @@
|
|||
# micromark-extension-mdx-jsx
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
|
||||
[micromark][] extension to support [MDX][mdxjs] JSX (`<Component />`).
|
||||
|
||||
## Contents
|
||||
|
||||
* [What is this?](#what-is-this)
|
||||
* [When to use this](#when-to-use-this)
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`mdxJsx(options?)`](#mdxjsxoptions)
|
||||
* [`Options`](#options)
|
||||
* [Authoring](#authoring)
|
||||
* [Syntax](#syntax)
|
||||
* [Errors](#errors)
|
||||
* [Unexpected end of file $at, expected $expect](#unexpected-end-of-file-at-expected-expect)
|
||||
* [Unexpected character $at, expected $expect](#unexpected-character-at-expected-expect)
|
||||
* [Tokens](#tokens)
|
||||
* [Types](#types)
|
||||
* [Compatibility](#compatibility)
|
||||
* [Security](#security)
|
||||
* [Related](#related)
|
||||
* [Contribute](#contribute)
|
||||
* [License](#license)
|
||||
|
||||
## What is this?
|
||||
|
||||
This package contains an extension that adds support for the JSX syntax enabled
|
||||
by [MDX][mdxjs] to [`micromark`][micromark].
|
||||
These extensions are used inside MDX.
|
||||
It mostly matches how JSX works in most places that support it (TypeScript,
|
||||
Babel, esbuild, SWC, etc).
|
||||
|
||||
This package can be made aware or unaware of JavaScript syntax.
|
||||
When unaware, expressions could include Rust or variables or whatnot.
|
||||
|
||||
## When to use this
|
||||
|
||||
This project is useful when you want to support JSX in markdown.
|
||||
|
||||
You can use this extension when you are working with [`micromark`][micromark].
|
||||
To support all MDX features, use
|
||||
[`micromark-extension-mdxjs`][micromark-extension-mdxjs] instead.
|
||||
|
||||
When you need a syntax tree, combine this package with
|
||||
[`mdast-util-mdx-jsx`][mdast-util-mdx-jsx].
|
||||
|
||||
All these packages are used in [`remark-mdx`][remark-mdx], which focusses on
|
||||
making it easier to transform content by abstracting these internals away.
|
||||
|
||||
When you are using [`mdx-js/mdx`][mdxjs], all of this is already included.
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 16+), install with [npm][]:
|
||||
|
||||
```sh
|
||||
npm install micromark-extension-mdx-jsx
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
|
||||
```js
|
||||
import {mdxJsx} from 'https://esm.sh/micromark-extension-mdx-jsx@1'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import {mdxJsx} from 'https://esm.sh/micromark-extension-mdx-jsx@1?bundle'
|
||||
</script>
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
```js
|
||||
import {micromark} from 'micromark'
|
||||
import {mdxJsx} from 'micromark-extension-mdx-jsx'
|
||||
|
||||
const output = micromark('a <b c d="e" /> f', {extensions: [mdxJsx()]})
|
||||
|
||||
console.log(output)
|
||||
```
|
||||
|
||||
Yields:
|
||||
|
||||
```html
|
||||
<p>a f</p>
|
||||
```
|
||||
|
||||
…which is useless: go to a syntax tree with
|
||||
[`mdast-util-from-markdown`][mdast-util-from-markdown] and
|
||||
[`mdast-util-mdx-jsx`][mdast-util-mdx-jsx] instead.
|
||||
|
||||
## API
|
||||
|
||||
This package exports the identifier [`mdxJsx`][api-mdx-jsx].
|
||||
There is no default export.
|
||||
|
||||
The export map supports the [`development` condition][development].
|
||||
Run `node --conditions development module.js` to get instrumented dev code.
|
||||
Without this condition, production code is loaded.
|
||||
|
||||
### `mdxJsx(options?)`
|
||||
|
||||
Create an extension for `micromark` to enable MDX JSX syntax.
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `options` ([`Options`][api-options], optional)
|
||||
— configuration
|
||||
|
||||
###### Returns
|
||||
|
||||
Extension for `micromark` that can be passed in `extensions` to enable MDX
|
||||
JSX syntax ([`Extension`][micromark-extension]).
|
||||
|
||||
### `Options`
|
||||
|
||||
Configuration (TypeScript type).
|
||||
|
||||
###### Fields
|
||||
|
||||
* `acorn` ([`Acorn`][acorn], optional)
|
||||
— acorn parser to use
|
||||
* `acornOptions` ([`AcornOptions`][acorn-options], default:
|
||||
`{ecmaVersion: 2020, locations: true, sourceType: 'module'}`)
|
||||
— configuration for acorn; all fields except `locations` can be set
|
||||
* `addResult` (`boolean`, default: `false`)
|
||||
— whether to add `estree` fields to tokens with results from acorn
|
||||
|
||||
## Authoring
|
||||
|
||||
When authoring markdown with JSX, keep in mind that MDX is a whitespace
|
||||
sensitive and line-based language, while JavaScript is insensitive to
|
||||
whitespace.
|
||||
This affects how markdown and JSX interleave with eachother in MDX.
|
||||
For more info on how it works, see [§ Interleaving][mdxjs-interleaving] on the
|
||||
MDX site.
|
||||
|
||||
###### Comments inside tags
|
||||
|
||||
JavaScript comments in JSX are not supported.
|
||||
|
||||
Incorrect:
|
||||
|
||||
```jsx
|
||||
<hi/*comment!*//>
|
||||
<hello// comment!
|
||||
/>
|
||||
```
|
||||
|
||||
Correct:
|
||||
|
||||
```jsx
|
||||
<hi/>
|
||||
<hello
|
||||
/>
|
||||
```
|
||||
|
||||
A PR that adds support for them would be accepted.
|
||||
|
||||
###### Element or fragment attribute values
|
||||
|
||||
JSX elements or JSX fragments as attribute values are not supported.
|
||||
The reason for this change is that it would be confusing whether markdown
|
||||
would work.
|
||||
|
||||
Incorrect:
|
||||
|
||||
```jsx
|
||||
<welcome name=<>Venus</> />
|
||||
<welcome name=<span>Pluto</span> />
|
||||
```
|
||||
|
||||
Correct:
|
||||
|
||||
```jsx
|
||||
<welcome name='Mars' />
|
||||
<welcome name={<span>Jupiter</span>} />
|
||||
```
|
||||
|
||||
###### Greater than (`>`) and right curly brace (`}`)
|
||||
|
||||
JSX does not allow U+003E GREATER THAN (`>`) or U+007D RIGHT CURLY BRACE
|
||||
(`}`) literally in text, they need to be encoded as character references
|
||||
(or expressions).
|
||||
There is no good reason for this (some JSX parsers agree with us and don’t
|
||||
crash either).
|
||||
Therefore, in MDX, U+003E GREATER THAN (`>`) and U+007D RIGHT CURLY BRACE
|
||||
(`}`) are fine literally and don’t need to be encoded.
|
||||
|
||||
## Syntax
|
||||
|
||||
JSX forms with the following BNF:
|
||||
|
||||
<!--grammar start-->
|
||||
|
||||
<pre><code><a id=x-mdx-jsx-flow href=#x-mdx-jsx-flow>mdx_jsx_flow</a> ::= <a href=#x-mdx-jsx>mdx_jsx</a> *<a href=#x-space-or-tab>space_or_tab</a> [<a href=#x-mdx-jsx>mdx_jsx</a> *<a href=#x-space-or-tab>space_or_tab</a>]
|
||||
<a id=x-mdx-jsx-text href=#x-mdx-jsx-text>mdx_jsx_text</a> ::= <a href=#x-mdx-jsx>mdx_jsx</a>
|
||||
|
||||
; constraint: markdown whitespace (`<a href=#x-space-or-tab>space_or_tab</a> | <a href=#x-eol>eol</a>`) is NOT
|
||||
; allowed directly after `<` in order to allow `1 < 3` in markdown.
|
||||
<a id=x-mdx-jsx href=#x-mdx-jsx>mdx_jsx</a> ::=
|
||||
'<' [<a href=#x-closing>closing</a>]
|
||||
[*<a href=#x-whitespace>whitespace</a> <a href=#x-name>name</a> [<a href=#x-attributes-after-identifier>attributes_after_identifier</a>] [<a href=#x-closing>closing</a>]]
|
||||
*<a href=#x-whitespace>whitespace</a> '>'
|
||||
|
||||
<a id=x-attributes-after-identifier href=#x-attributes-after-identifier>attributes_after_identifier</a> ::=
|
||||
1*<a href=#x-whitespace>whitespace</a> (<a href=#x-attributes-boolean>attributes_boolean</a> | <a href=#x-attributes-value>attributes_value</a>) |
|
||||
*<a href=#x-whitespace>whitespace</a> <a href=#x-attributes-expression>attributes_expression</a> |
|
||||
<a id=x-attributes-after-value href=#x-attributes-after-value>attributes_after_value</a> ::=
|
||||
*<a href=#x-whitespace>whitespace</a> (<a href=#x-attributes-boolean>attributes_boolean</a> | <a href=#x-attributes-expression>attributes_expression</a> | <a href=#x-attributes-value>attributes_value</a>)
|
||||
<a id=x-attributes-boolean href=#x-attributes-boolean>attributes_boolean</a> ::= <a href=#x-key>key</a> [<a href=#x-attributes-after-identifier>attributes_after_identifier</a>]
|
||||
; Note: in gnostic mode the value of the expression must instead be a single valid ES spread
|
||||
; expression
|
||||
<a id=x-attributes-expression href=#x-attributes-expression>attributes_expression</a> ::= <a href=#x-expression>expression</a> [<a href=#x-attributes-after-value>attributes_after_value</a>]
|
||||
<a id=x-attributes-value href=#x-attributes-value>attributes_value</a> ::= <a href=#x-key>key</a> <a href=#x-initializer>initializer</a> [<a href=#x-attributes-after-value>attributes_after_value</a>]
|
||||
|
||||
<a id=x-closing href=#x-closing>closing</a> ::= *<a href=#x-whitespace>whitespace</a> '/'
|
||||
|
||||
<a id=x-name href=#x-name>name</a> ::= <a href=#x-identifier>identifier</a> [<a href=#x-local>local</a> | <a href=#x-members>members</a>]
|
||||
<a id=x-key href=#x-key>key</a> ::= <a href=#x-identifier>identifier</a> [<a href=#x-local>local</a>]
|
||||
<a id=x-local href=#x-local>local</a> ::= *<a href=#x-whitespace>whitespace</a> ':' *<a href=#x-whitespace>whitespace</a> <a href=#x-identifier>identifier</a>
|
||||
<a id=x-members href=#x-members>members</a> ::= <a href=#x-member>member</a> *<a href=#x-member>member</a>
|
||||
<a id=x-member href=#x-member>member</a> ::= *<a href=#x-whitespace>whitespace</a> '.' *<a href=#x-whitespace>whitespace</a> <a href=#x-identifier>identifier</a>
|
||||
|
||||
<a id=x-identifier href=#x-identifier>identifier</a> ::= <a href=#x-identifier-start>identifier_start</a> *<a href=#x-identifier-part>identifier_part</a>
|
||||
<a id=x-initializer href=#x-initializer>initializer</a> ::= *<a href=#x-whitespace>whitespace</a> '=' *<a href=#x-whitespace>whitespace</a> <a href=#x-value>value</a>
|
||||
<a id=x-value href=#x-value>value</a> ::= <a href=#x-double-quoted>double_quoted</a> | <a href=#x-single-quoted>single_quoted</a> | <a href=#x-expression>expression</a>
|
||||
; Note: in gnostic mode the value must instead be a single valid ES expression
|
||||
<a id=x-expression href=#x-expression>expression</a> ::= '{' *(<a href=#x-expression-text>expression_text</a> | <a href=#x-expression>expression</a>) '}'
|
||||
|
||||
<a id=x-double-quoted href=#x-double-quoted>double_quoted</a> ::= '"' *<a href=#x-double-quoted-text>double_quoted_text</a> '"'
|
||||
<a id=x-single-quoted href=#x-single-quoted>single_quoted</a> ::= "'" *<a href=#x-single-quoted-text>single_quoted_text</a> "'"
|
||||
|
||||
<a id=x-whitespace href=#x-whitespace>whitespace</a> ::= <a href=#x-es-whitespace>es_whitespace</a>
|
||||
<a id=x-double-quoted-text href=#x-double-quoted-text>double_quoted_text</a> ::= char - '"'
|
||||
<a id=x-single-quoted-text href=#x-single-quoted-text>single_quoted_text</a> ::= char - "'"
|
||||
<a id=x-expression-text href=#x-expression-text>expression_text</a> ::= char - '{' - '}'
|
||||
<a id=x-identifier-start href=#x-identifier-start>identifier_start</a> ::= <a href=#x-es-identifier-start>es_identifier_start</a>
|
||||
<a id=x-identifier-part href=#x-identifier-part>identifier_part</a> ::= <a href=#x-es-identifier-part>es_identifier_part</a> | '-'
|
||||
|
||||
<a id=x-space-or-tab href=#x-space-or-tab>space_or_tab</a> ::= '\t' | ' '
|
||||
<a id=x-eol href=#x-eol>eol</a> ::= '\n' | '\r' | '\r\n'
|
||||
|
||||
; ECMAScript
|
||||
; See “IdentifierStart”: <<a href=https://tc39.es/ecma262/#prod-IdentifierStart>https://tc39.es/ecma262/#prod-IdentifierStart</a>>
|
||||
<a id=x-es-identifier-start href=#x-es-identifier-start>es_identifier_start</a> ::= ?
|
||||
; See “IdentifierPart”: <<a href=https://tc39.es/ecma262/#prod-IdentifierPart>https://tc39.es/ecma262/#prod-IdentifierPart</a>>
|
||||
<a id=x-es-identifier-part href=#x-es-identifier-part>es_identifier_part</a> ::= ?
|
||||
; See “Whitespace”: <<a href=https://tc39.es/ecma262/#prod-WhiteSpace>https://tc39.es/ecma262/#prod-WhiteSpace</a>>
|
||||
<a id=x-es-whitespace href=#x-es-whitespace>es_whitespace</a> ::= ?
|
||||
</code></pre>
|
||||
|
||||
<!--grammar end-->
|
||||
|
||||
As the flow construct occurs in flow, like all flow constructs, it must be
|
||||
followed by an eol (line ending) or eof (end of file).
|
||||
|
||||
The grammar for JSX in markdown is much stricter than that of HTML in
|
||||
markdown.
|
||||
The primary benefit of this is that tags are parsed into tokens, and thus
|
||||
can be processed.
|
||||
Another, arguable, benefit of this is that it comes with syntax errors: if
|
||||
an author types something that is nonsensical, an error is thrown with
|
||||
information about where it happened, what occurred, and what was expected
|
||||
instead.
|
||||
|
||||
This extension supports expressions both aware and unaware to JavaScript
|
||||
(respectively gnostic and agnostic).
|
||||
Depending on whether acorn is passed, either valid JavaScript must be used in
|
||||
expressions, or arbitrary text (such as Rust code or so) can be used.
|
||||
|
||||
More on this can be found in
|
||||
[§ Syntax of `micromark-extension-mdx-expression`][expression-syntax].
|
||||
|
||||
## Errors
|
||||
|
||||
In aware (gnostic) mode, expressions are parsed with
|
||||
[`micromark-extension-mdx-expression`][micromark-extension-mdx-expression],
|
||||
which throws some more errors.
|
||||
|
||||
### Unexpected end of file $at, expected $expect
|
||||
|
||||
This error occurs for many different reasons if something was opened but not
|
||||
closed (source: `micromark-extension-mdx-jsx`, rule id: `unexpected-eof`).
|
||||
|
||||
Some examples are:
|
||||
|
||||
```markdown
|
||||
<
|
||||
</
|
||||
<a
|
||||
<a:
|
||||
<a.
|
||||
<a b
|
||||
<a b:
|
||||
<a b=
|
||||
<a b="
|
||||
<a b='
|
||||
<a b={
|
||||
<a/
|
||||
```
|
||||
|
||||
### Unexpected character $at, expected $expect
|
||||
|
||||
This error occurs for many different reasons if an unexpected character is seen
|
||||
(source: `micromark-extension-mdx-jsx`, rule id: `unexpected-character`).
|
||||
|
||||
Some examples are:
|
||||
|
||||
```markdown
|
||||
<.>
|
||||
</.>
|
||||
<a?>
|
||||
<a:+>
|
||||
<a./>
|
||||
<a b!>
|
||||
<a b:1>
|
||||
<a b=>
|
||||
<a/->
|
||||
```
|
||||
|
||||
## Tokens
|
||||
|
||||
Many tokens are used:
|
||||
|
||||
* `mdxJsxFlowTag` for the whole JSX tag (`<a>`)
|
||||
* `mdxJsxTextTag` ^
|
||||
* `mdxJsxFlowTagMarker` for the tag markers (`<`, `>`)
|
||||
* `mdxJsxTextTagMarker` ^
|
||||
* `mdxJsxFlowTagClosingMarker` for the `/` marking a closing tag (`</a>`)
|
||||
* `mdxJsxTextTagClosingMarker` ^
|
||||
* `mdxJsxFlowTagSelfClosingMarker` for the `/` marking a self-closing tag
|
||||
(`<a/>`)
|
||||
* `mdxJsxTextTagSelfClosingMarker` ^
|
||||
* `mdxJsxFlowTagName` for the whole tag name (`a:b` in `<a:b>`)
|
||||
* `mdxJsxTextTagName` ^
|
||||
* `mdxJsxFlowTagNamePrimary` for the first name (`a` in `<a:b>`)
|
||||
* `mdxJsxTextTagNamePrimary` ^
|
||||
* `mdxJsxFlowTagNameMemberMarker` for the `.` marking in members (`<a.b>`)
|
||||
* `mdxJsxTextTagNameMemberMarker` ^
|
||||
* `mdxJsxFlowTagNameMember` for member names (`b` in `<a:b>`)
|
||||
* `mdxJsxTextTagNameMember` ^
|
||||
* `mdxJsxFlowTagNamePrefixMarker` for the `:` between primary and local
|
||||
(`<a:b>`)
|
||||
* `mdxJsxTextTagNamePrefixMarker` ^
|
||||
* `mdxJsxFlowTagNameLocal` for the local name (`b` in `<a:b>`)
|
||||
* `mdxJsxTextTagNameLocal` ^
|
||||
* `mdxJsxFlowTagExpressionAttribute` for whole expression attributes
|
||||
(`<a {...b}>`)
|
||||
* `mdxJsxTextTagExpressionAttribute` ^
|
||||
* `mdxJsxFlowTagExpressionAttributeMarker` for `{`, `}` in expression
|
||||
attributes
|
||||
* `mdxJsxTextTagExpressionAttributeMarker` ^
|
||||
* `mdxJsxFlowTagExpressionAttributeValue` for chunks of what’s inside
|
||||
expression attributes
|
||||
* `mdxJsxTextTagExpressionAttributeValue` ^
|
||||
* `mdxJsxFlowTagAttribute` for a whole normal attribute (`<a b>`)
|
||||
* `mdxJsxTextTagAttribute` ^
|
||||
* `mdxJsxFlowTagAttributeName` for the whole name of an attribute (`b:c` in
|
||||
`<a b:c>`)
|
||||
* `mdxJsxTextTagAttributeName` ^
|
||||
* `mdxJsxFlowTagAttributeNamePrimary` for the first name of an attribute (`b`
|
||||
in `<a b:c>`)
|
||||
* `mdxJsxTextTagAttributeNamePrimary` ^
|
||||
* `mdxJsxFlowTagAttributeNamePrefixMarker` for the `:` between primary and
|
||||
local (`<a b:c>`)
|
||||
* `mdxJsxTextTagAttributeNamePrefixMarker` ^
|
||||
* `mdxJsxFlowTagAttributeNameLocal` for the local name of an attribute (`c`
|
||||
in `<a b:c>`)
|
||||
* `mdxJsxTextTagAttributeNameLocal` ^
|
||||
* `mdxJsxFlowTagAttributeInitializerMarker` for the `=` between an attribute
|
||||
name and value
|
||||
* `mdxJsxTextTagAttributeInitializerMarker` ^
|
||||
* `mdxJsxFlowTagAttributeValueLiteral` for a string attribute value
|
||||
(`<a b="">`)
|
||||
* `mdxJsxTextTagAttributeValueLiteral` ^
|
||||
* `mdxJsxFlowTagAttributeValueLiteralMarker` for the quotes around a string
|
||||
attribute value (`"` or `'`)
|
||||
* `mdxJsxTextTagAttributeValueLiteralMarker` ^
|
||||
* `mdxJsxFlowTagAttributeValueLiteralValue` for chunks of what’s inside
|
||||
string attribute values
|
||||
* `mdxJsxTextTagAttributeValueLiteralValue` ^
|
||||
* `mdxJsxFlowTagAttributeValueExpression` for an expression attribute value
|
||||
(`<a b={1}>`)
|
||||
* `mdxJsxTextTagAttributeValueExpression` ^
|
||||
* `mdxJsxFlowTagAttributeValueExpressionMarker` for the `{` and `}` of
|
||||
expression attribute values
|
||||
* `mdxJsxTextTagAttributeValueExpressionMarker` ^
|
||||
* `mdxJsxFlowTagAttributeValueExpressionValue` for chunks of what’s inside
|
||||
expression attribute values
|
||||
* `mdxJsxTextTagAttributeValueExpressionValue` ^
|
||||
|
||||
## Types
|
||||
|
||||
This package is fully typed with [TypeScript][].
|
||||
It exports the additional type [`Options`][api-options].
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 16+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
These extensions work with `micromark` version 3+.
|
||||
|
||||
## Security
|
||||
|
||||
This package is safe.
|
||||
|
||||
## Related
|
||||
|
||||
* [`micromark-extension-mdxjs`][micromark-extension-mdxjs]
|
||||
— support all MDX syntax
|
||||
* [`mdast-util-mdx-jsx`][mdast-util-mdx-jsx]
|
||||
— support MDX JSX in mdast
|
||||
* [`remark-mdx`][remark-mdx]
|
||||
— support all MDX syntax in remark
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md` in `micromark/.github`][contributing] for ways to get
|
||||
started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definitions -->
|
||||
|
||||
[build-badge]: https://github.com/micromark/micromark-extension-mdx-jsx/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/micromark/micromark-extension-mdx-jsx/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/micromark/micromark-extension-mdx-jsx.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/micromark/micromark-extension-mdx-jsx
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/micromark-extension-mdx-jsx.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/micromark-extension-mdx-jsx
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/micromark-extension-mdx-jsx.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=micromark-extension-mdx-jsx
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/micromark/micromark/discussions
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[license]: license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[contributing]: https://github.com/micromark/.github/blob/HEAD/contributing.md
|
||||
|
||||
[support]: https://github.com/micromark/.github/blob/HEAD/support.md
|
||||
|
||||
[coc]: https://github.com/micromark/.github/blob/HEAD/code-of-conduct.md
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
||||
[development]: https://nodejs.org/api/packages.html#packages_resolving_user_conditions
|
||||
|
||||
[micromark]: https://github.com/micromark/micromark
|
||||
|
||||
[micromark-extension]: https://github.com/micromark/micromark#syntaxextension
|
||||
|
||||
[micromark-extension-mdxjs]: https://github.com/micromark/micromark-extension-mdxjs
|
||||
|
||||
[micromark-extension-mdx-expression]: https://github.com/micromark/micromark-extension-mdx-expression
|
||||
|
||||
[expression-syntax]: https://github.com/micromark/micromark-extension-mdx-expression/blob/main/packages/micromark-extension-mdx-expression/readme.md#syntax
|
||||
|
||||
[mdast-util-mdx-jsx]: https://github.com/syntax-tree/mdast-util-mdx-jsx
|
||||
|
||||
[mdast-util-from-markdown]: https://github.com/syntax-tree/mdast-util-from-markdown
|
||||
|
||||
[remark-mdx]: https://mdxjs.com/packages/remark-mdx/
|
||||
|
||||
[mdxjs]: https://mdxjs.com
|
||||
|
||||
[mdxjs-interleaving]: https://mdxjs.com/docs/what-is-mdx/#interleaving
|
||||
|
||||
[acorn]: https://github.com/acornjs/acorn
|
||||
|
||||
[acorn-options]: https://github.com/acornjs/acorn/blob/96c721dbf89d0ccc3a8c7f39e69ef2a6a3c04dfa/acorn/dist/acorn.d.ts#L16
|
||||
|
||||
[api-mdx-jsx]: #mdxjsxoptions
|
||||
|
||||
[api-options]: #options
|
||||
Loading…
Add table
Add a link
Reference in a new issue