🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
40
node_modules/mdast-util-mdx/index.d.ts
generated
vendored
Normal file
40
node_modules/mdast-util-mdx/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/**
|
||||
* Create an extension for `mdast-util-from-markdown` to enable MDX (ESM, JSX,
|
||||
* expressions).
|
||||
*
|
||||
* @returns {Array<FromMarkdownExtension>}
|
||||
* Extension for `mdast-util-from-markdown` to enable MDX (ESM, JSX,
|
||||
* expressions).
|
||||
*
|
||||
* When using the syntax extensions with `addResult`, ESM and expression
|
||||
* nodes will have `data.estree` fields set to ESTree `Program` node.
|
||||
*/
|
||||
export function mdxFromMarkdown(): Array<FromMarkdownExtension>
|
||||
/**
|
||||
* Create an extension for `mdast-util-to-markdown` to enable MDX (ESM, JSX,
|
||||
* expressions).
|
||||
*
|
||||
* @param {ToMarkdownOptions | null | undefined} [options]
|
||||
* Configuration.
|
||||
* @returns {ToMarkdownExtension}
|
||||
* Extension for `mdast-util-to-markdown` to enable MDX (ESM, JSX,
|
||||
* expressions).
|
||||
*/
|
||||
export function mdxToMarkdown(
|
||||
options?: ToMarkdownOptions | null | undefined
|
||||
): ToMarkdownExtension
|
||||
export type FromMarkdownExtension = import('mdast-util-from-markdown').Extension
|
||||
export type ToMarkdownExtension = import('mdast-util-to-markdown').Options
|
||||
export type MdxFlowExpression =
|
||||
import('mdast-util-mdx-expression').MdxFlowExpression
|
||||
export type MdxTextExpression =
|
||||
import('mdast-util-mdx-expression').MdxTextExpression
|
||||
export type MdxjsEsm = import('mdast-util-mdxjs-esm').MdxjsEsm
|
||||
export type MdxJsxAttributeValueExpression =
|
||||
import('mdast-util-mdx-jsx').MdxJsxAttributeValueExpression
|
||||
export type MdxJsxAttribute = import('mdast-util-mdx-jsx').MdxJsxAttribute
|
||||
export type MdxJsxExpressionAttribute =
|
||||
import('mdast-util-mdx-jsx').MdxJsxExpressionAttribute
|
||||
export type MdxJsxFlowElement = import('mdast-util-mdx-jsx').MdxJsxFlowElement
|
||||
export type MdxJsxTextElement = import('mdast-util-mdx-jsx').MdxJsxTextElement
|
||||
export type ToMarkdownOptions = import('mdast-util-mdx-jsx').ToMarkdownOptions
|
||||
56
node_modules/mdast-util-mdx/index.js
generated
vendored
Normal file
56
node_modules/mdast-util-mdx/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
* @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension
|
||||
* @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension
|
||||
*
|
||||
* @typedef {import('mdast-util-mdx-expression').MdxFlowExpression} MdxFlowExpression
|
||||
* @typedef {import('mdast-util-mdx-expression').MdxTextExpression} MdxTextExpression
|
||||
* @typedef {import('mdast-util-mdxjs-esm').MdxjsEsm} MdxjsEsm
|
||||
* @typedef {import('mdast-util-mdx-jsx').MdxJsxAttributeValueExpression} MdxJsxAttributeValueExpression
|
||||
* @typedef {import('mdast-util-mdx-jsx').MdxJsxAttribute} MdxJsxAttribute
|
||||
* @typedef {import('mdast-util-mdx-jsx').MdxJsxExpressionAttribute} MdxJsxExpressionAttribute
|
||||
* @typedef {import('mdast-util-mdx-jsx').MdxJsxFlowElement} MdxJsxFlowElement
|
||||
* @typedef {import('mdast-util-mdx-jsx').MdxJsxTextElement} MdxJsxTextElement
|
||||
* @typedef {import('mdast-util-mdx-jsx').ToMarkdownOptions} ToMarkdownOptions
|
||||
*/
|
||||
|
||||
import {
|
||||
mdxExpressionFromMarkdown,
|
||||
mdxExpressionToMarkdown
|
||||
} from 'mdast-util-mdx-expression'
|
||||
import {mdxJsxFromMarkdown, mdxJsxToMarkdown} from 'mdast-util-mdx-jsx'
|
||||
import {mdxjsEsmFromMarkdown, mdxjsEsmToMarkdown} from 'mdast-util-mdxjs-esm'
|
||||
|
||||
/**
|
||||
* Create an extension for `mdast-util-from-markdown` to enable MDX (ESM, JSX,
|
||||
* expressions).
|
||||
*
|
||||
* @returns {Array<FromMarkdownExtension>}
|
||||
* Extension for `mdast-util-from-markdown` to enable MDX (ESM, JSX,
|
||||
* expressions).
|
||||
*
|
||||
* When using the syntax extensions with `addResult`, ESM and expression
|
||||
* nodes will have `data.estree` fields set to ESTree `Program` node.
|
||||
*/
|
||||
export function mdxFromMarkdown() {
|
||||
return [mdxExpressionFromMarkdown, mdxJsxFromMarkdown(), mdxjsEsmFromMarkdown]
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an extension for `mdast-util-to-markdown` to enable MDX (ESM, JSX,
|
||||
* expressions).
|
||||
*
|
||||
* @param {ToMarkdownOptions | null | undefined} [options]
|
||||
* Configuration.
|
||||
* @returns {ToMarkdownExtension}
|
||||
* Extension for `mdast-util-to-markdown` to enable MDX (ESM, JSX,
|
||||
* expressions).
|
||||
*/
|
||||
export function mdxToMarkdown(options) {
|
||||
return {
|
||||
extensions: [
|
||||
mdxExpressionToMarkdown,
|
||||
mdxJsxToMarkdown(options),
|
||||
mdxjsEsmToMarkdown
|
||||
]
|
||||
}
|
||||
}
|
||||
22
node_modules/mdast-util-mdx/license
generated
vendored
Normal file
22
node_modules/mdast-util-mdx/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.
|
||||
87
node_modules/mdast-util-mdx/package.json
generated
vendored
Normal file
87
node_modules/mdast-util-mdx/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
{
|
||||
"name": "mdast-util-mdx",
|
||||
"version": "2.0.1",
|
||||
"description": "mdast extension to parse and serialize MDX (or MDX.js)",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"unist",
|
||||
"mdast",
|
||||
"mdast-util",
|
||||
"util",
|
||||
"utility",
|
||||
"markdown",
|
||||
"markup",
|
||||
"mdx",
|
||||
"mdxjs",
|
||||
"esm",
|
||||
"expression",
|
||||
"jsx"
|
||||
],
|
||||
"repository": "syntax-tree/mdast-util-mdx",
|
||||
"bugs": "https://github.com/syntax-tree/mdast-util-mdx/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": [
|
||||
"index.d.ts",
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"mdast-util-from-markdown": "^1.0.0",
|
||||
"mdast-util-mdx-expression": "^1.0.0",
|
||||
"mdast-util-mdx-jsx": "^2.0.0",
|
||||
"mdast-util-mdxjs-esm": "^1.0.0",
|
||||
"mdast-util-to-markdown": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.0.0",
|
||||
"c8": "^7.0.0",
|
||||
"micromark-extension-mdx": "^1.0.0",
|
||||
"micromark-extension-mdxjs": "^1.0.0",
|
||||
"prettier": "^2.0.0",
|
||||
"remark-cli": "^11.0.0",
|
||||
"remark-preset-wooorm": "^9.0.0",
|
||||
"type-coverage": "^2.0.0",
|
||||
"typescript": "^4.0.0",
|
||||
"xo": "^0.53.0"
|
||||
},
|
||||
"scripts": {
|
||||
"prepack": "npm run build && npm run format",
|
||||
"build": "tsc --build --clean && tsc --build && type-coverage",
|
||||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
|
||||
"test-api": "node --conditions development test.js",
|
||||
"test-coverage": "c8 --check-coverage --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
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"preset-wooorm"
|
||||
]
|
||||
},
|
||||
"typeCoverage": {
|
||||
"atLeast": 100,
|
||||
"detail": true,
|
||||
"strict": true,
|
||||
"ignoreCatch": true
|
||||
}
|
||||
}
|
||||
482
node_modules/mdast-util-mdx/readme.md
generated
vendored
Normal file
482
node_modules/mdast-util-mdx/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,482 @@
|
|||
# mdast-util-mdx
|
||||
|
||||
[![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]
|
||||
|
||||
[mdast][] extensions to parse and serialize [MDX][]: ESM, JSX, and expressions.
|
||||
|
||||
## Contents
|
||||
|
||||
* [What is this?](#what-is-this)
|
||||
* [When to use this](#when-to-use-this)
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`mdxFromMarkdown()`](#mdxfrommarkdown)
|
||||
* [`mdxToMarkdown(options?)`](#mdxtomarkdownoptions)
|
||||
* [`ToMarkdownOptions`](#tomarkdownoptions)
|
||||
* [HTML](#html)
|
||||
* [Syntax](#syntax)
|
||||
* [Syntax tree](#syntax-tree)
|
||||
* [Types](#types)
|
||||
* [Compatibility](#compatibility)
|
||||
* [Related](#related)
|
||||
* [Contribute](#contribute)
|
||||
* [License](#license)
|
||||
|
||||
## What is this?
|
||||
|
||||
This package contains two extensions that add support for MDX syntax in
|
||||
markdown to [mdast][]: ESM (`import x from 'y'`), JSX (`<a />`), and
|
||||
expressions (`{Math.PI}`).
|
||||
These extensions plug into
|
||||
[`mdast-util-from-markdown`][mdast-util-from-markdown] (to support parsing
|
||||
MDX in markdown into a syntax tree) and
|
||||
[`mdast-util-to-markdown`][mdast-util-to-markdown] (to support serializing
|
||||
MDX in syntax trees to markdown).
|
||||
|
||||
## When to use this
|
||||
|
||||
You can use these extensions when you are working with
|
||||
`mdast-util-from-markdown` and `mdast-util-to-markdown` already.
|
||||
|
||||
When working with `mdast-util-from-markdown`, you must combine this package
|
||||
with [`micromark-extension-mdx`][mdx] or [`micromark-extension-mdxjs`][mdxjs].
|
||||
|
||||
Instead of this package, you can also use the extensions separately:
|
||||
|
||||
* [`mdast-util-mdx-expression`](https://github.com/syntax-tree/mdast-util-mdx-expression)
|
||||
— support MDX expressions
|
||||
* [`mdast-util-mdx-jsx`](https://github.com/syntax-tree/mdast-util-mdx-jsx)
|
||||
— support MDX JSX
|
||||
* [`mdast-util-mdxjs-esm`](https://github.com/syntax-tree/mdast-util-mdxjs-esm)
|
||||
— support MDX ESM
|
||||
|
||||
All these packages are used in [`remark-mdx`][remark-mdx], which
|
||||
focusses on making it easier to transform content by abstracting these
|
||||
internals away.
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 14.14+ and 16.0+), install with [npm][]:
|
||||
|
||||
```sh
|
||||
npm install mdast-util-mdx
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
|
||||
```js
|
||||
import {mdxFromMarkdown, mdxToMarkdown} from 'https://esm.sh/mdast-util-mdx@2'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import {mdxFromMarkdown, mdxToMarkdown} from 'https://esm.sh/mdast-util-mdx@2?bundle'
|
||||
</script>
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
Say our document `example.mdx` contains:
|
||||
|
||||
```markdown
|
||||
import Box from "place"
|
||||
|
||||
Here’s an expression:
|
||||
|
||||
{
|
||||
1 + 1 /* } */
|
||||
}
|
||||
|
||||
Which you can also put inline: {1+1}.
|
||||
|
||||
<Box>
|
||||
<SmallerBox>
|
||||
- Lists, which can be indented.
|
||||
</SmallerBox>
|
||||
</Box>
|
||||
```
|
||||
|
||||
…and our module `example.js` looks as follows:
|
||||
|
||||
```js
|
||||
import fs from 'node:fs/promises'
|
||||
import {fromMarkdown} from 'mdast-util-from-markdown'
|
||||
import {toMarkdown} from 'mdast-util-to-markdown'
|
||||
import {mdxjs} from 'micromark-extension-mdxjs'
|
||||
import {mdxFromMarkdown, mdxToMarkdown} from 'mdast-util-mdx'
|
||||
|
||||
const doc = await fs.readFile('example.mdx')
|
||||
|
||||
const tree = fromMarkdown(doc, {
|
||||
extensions: [mdxjs()],
|
||||
mdastExtensions: [mdxFromMarkdown()]
|
||||
})
|
||||
|
||||
console.log(tree)
|
||||
|
||||
const out = toMarkdown(tree, {extensions: [mdxToMarkdown()]})
|
||||
|
||||
console.log(out)
|
||||
```
|
||||
|
||||
…now running `node example.js` yields (positional info removed for brevity):
|
||||
|
||||
```js
|
||||
{
|
||||
type: 'root',
|
||||
children: [
|
||||
{
|
||||
type: 'mdxjsEsm',
|
||||
value: 'import Box from "place"',
|
||||
data: {
|
||||
estree: {
|
||||
type: 'Program',
|
||||
body: [
|
||||
{
|
||||
type: 'ImportDeclaration',
|
||||
specifiers: [
|
||||
{
|
||||
type: 'ImportDefaultSpecifier',
|
||||
local: {type: 'Identifier', name: 'Box'}
|
||||
}
|
||||
],
|
||||
source: {type: 'Literal', value: 'place', raw: '"place"'}
|
||||
}
|
||||
],
|
||||
sourceType: 'module'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'paragraph',
|
||||
children: [{type: 'text', value: 'Here’s an expression:'}]
|
||||
},
|
||||
{
|
||||
type: 'mdxFlowExpression',
|
||||
value: '\n1 + 1 /* } */\n',
|
||||
data: {
|
||||
estree: {
|
||||
type: 'Program',
|
||||
body: [
|
||||
{
|
||||
type: 'ExpressionStatement',
|
||||
expression: {
|
||||
type: 'BinaryExpression',
|
||||
left: {type: 'Literal', value: 1, raw: '1'},
|
||||
operator: '+',
|
||||
right: {type: 'Literal', value: 1, raw: '1'}
|
||||
}
|
||||
}
|
||||
],
|
||||
sourceType: 'module'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'paragraph',
|
||||
children: [
|
||||
{type: 'text', value: 'Which you can also put inline: '},
|
||||
{
|
||||
type: 'mdxTextExpression',
|
||||
value: '1+1',
|
||||
data: {
|
||||
estree: {
|
||||
type: 'Program',
|
||||
body: [
|
||||
{
|
||||
type: 'ExpressionStatement',
|
||||
expression: {
|
||||
type: 'BinaryExpression',
|
||||
left: {type: 'Literal', value: 1, raw: '1'},
|
||||
operator: '+',
|
||||
right: {type: 'Literal', value: 1, raw: '1'}
|
||||
}
|
||||
}
|
||||
],
|
||||
sourceType: 'module'
|
||||
}
|
||||
}
|
||||
},
|
||||
{type: 'text', value: '.'}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'mdxJsxFlowElement',
|
||||
name: 'Box',
|
||||
attributes: [],
|
||||
children: [
|
||||
{
|
||||
type: 'mdxJsxFlowElement',
|
||||
name: 'SmallerBox',
|
||||
attributes: [],
|
||||
children: [
|
||||
{
|
||||
type: 'list',
|
||||
ordered: false,
|
||||
start: null,
|
||||
spread: false,
|
||||
children: [
|
||||
{
|
||||
type: 'listItem',
|
||||
spread: false,
|
||||
checked: null,
|
||||
children: [
|
||||
{
|
||||
type: 'paragraph',
|
||||
children: [
|
||||
{type: 'text', value: 'Lists, which can be indented.'}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
```markdown
|
||||
import Box from "place"
|
||||
|
||||
Here’s an expression:
|
||||
|
||||
{
|
||||
1 + 1 /* } */
|
||||
}
|
||||
|
||||
Which you can also put inline: {1+1}.
|
||||
|
||||
<Box>
|
||||
<SmallerBox>
|
||||
* Lists, which can be indented.
|
||||
</SmallerBox>
|
||||
</Box>
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
This package exports the identifiers [`mdxFromMarkdown`][api-mdx-from-markdown]
|
||||
and [`mdxToMarkdown`][api-mdx-to-markdown].
|
||||
There is no default export.
|
||||
|
||||
### `mdxFromMarkdown()`
|
||||
|
||||
Create an extension for [`mdast-util-from-markdown`][mdast-util-from-markdown]
|
||||
to enable MDX (ESM, JSX, expressions).
|
||||
|
||||
###### Returns
|
||||
|
||||
Extension for `mdast-util-from-markdown` to enable MDX
|
||||
([`FromMarkdownExtension`][from-markdown-extension]).
|
||||
|
||||
When using the [syntax extensions with `addResult`][mdxjs], ESM and expression
|
||||
nodes will have `data.estree` fields set to ESTree [`Program`][program] node.
|
||||
|
||||
### `mdxToMarkdown(options?)`
|
||||
|
||||
Create an extension for [`mdast-util-to-markdown`][mdast-util-to-markdown]
|
||||
to enable MDX (ESM, JSX, expressions).
|
||||
|
||||
Extension for [`mdast-util-to-markdown`][mdast-util-to-markdown].
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `options` ([`ToMarkdownOptions`][api-to-markdown-options])
|
||||
— configuration
|
||||
|
||||
###### Returns
|
||||
|
||||
Extension for `mdast-util-to-markdown` to enable MDX
|
||||
([`FromMarkdownExtension`][to-markdown-extension]).
|
||||
|
||||
### `ToMarkdownOptions`
|
||||
|
||||
Configuration (TypeScript type).
|
||||
|
||||
###### Fields
|
||||
|
||||
* `quote` (`'"'` or `"'"`, default: `'"'`)
|
||||
— preferred quote to use around attribute values
|
||||
* `quoteSmart` (`boolean`, default: `false`)
|
||||
— use the other quote if that results in less bytes
|
||||
* `tightSelfClosing` (`boolean`, default: `false`)
|
||||
— do not use an extra space when closing self-closing elements: `<img/>`
|
||||
instead of `<img />`
|
||||
* `printWidth` (`number`, default: `Infinity`)
|
||||
— try and wrap syntax at this width.
|
||||
When set to a finite number (say, `80`), the formatter will print
|
||||
attributes on separate lines when a tag doesn’t fit on one line.
|
||||
The normal behavior is to print attributes with spaces between them instead
|
||||
of line endings
|
||||
|
||||
## HTML
|
||||
|
||||
MDX has no representation in HTML.
|
||||
Though, when you are dealing with MDX, you will likely go *through* hast.
|
||||
You can enable passing MDX through to hast by configuring
|
||||
[`mdast-util-to-hast`][mdast-util-to-hast] with `passThrough: ['mdxjsEsm',
|
||||
'mdxFlowExpression', 'mdxJsxFlowElement', 'mdxJsxTextElement', 'mdxTextExpression']`.
|
||||
|
||||
## Syntax
|
||||
|
||||
See [Syntax in `micromark-extension-mdxjs`][mdxjs].
|
||||
|
||||
## Syntax tree
|
||||
|
||||
This utility combines several mdast utilities.
|
||||
See their readmes for the node types supported in the tree:
|
||||
|
||||
* [`mdast-util-mdx-expression`](https://github.com/syntax-tree/mdast-util-mdx-expression#syntax-tree)
|
||||
— support MDX expressions
|
||||
* [`mdast-util-mdx-jsx`](https://github.com/syntax-tree/mdast-util-mdx-jsx#syntax-tree)
|
||||
— support MDX JSX
|
||||
* [`mdast-util-mdxjs-esm`](https://github.com/syntax-tree/mdast-util-mdxjs-esm#syntax-tree)
|
||||
— support MDX ESM
|
||||
|
||||
## Types
|
||||
|
||||
This package is fully typed with [TypeScript][].
|
||||
It exports the additional types `MdxFlowExpression`, `MdxTextExpression`,
|
||||
`MdxjsEsm`, `MdxJsxAttributeValueExpression`, `MdxJsxAttribute`,
|
||||
`MdxJsxExpressionAttribute`, `MdxJsxFlowElement`,
|
||||
`MdxJsxTextElement`, and [`ToMarkdownOptions`][api-to-markdown-options].
|
||||
|
||||
It also registers the node types with `@types/mdast` and `@types/hast`.
|
||||
If you’re working with the syntax tree, make sure to import this utility
|
||||
somewhere in your types, as that registers the new node types in the tree.
|
||||
|
||||
```js
|
||||
/**
|
||||
* @typedef {import('mdast-util-mdx')}
|
||||
*/
|
||||
|
||||
import {visit} from 'unist-util-visit'
|
||||
|
||||
/** @type {import('mdast').Root} */
|
||||
const tree = getMdastNodeSomeHow()
|
||||
|
||||
visit(tree, (node) => {
|
||||
// `node` can now be an expression, JSX, or ESM node.
|
||||
})
|
||||
```
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 14.14+ and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
This utility works with `mdast-util-from-markdown` version 1+ and
|
||||
`mdast-util-to-markdown` version 1+.
|
||||
|
||||
## Related
|
||||
|
||||
* [`remark-mdx`][remark-mdx]
|
||||
— remark plugin to support MDX
|
||||
* [`micromark-extension-mdx`][mdx]
|
||||
— micromark extension to parse MDX
|
||||
* [`micromark-extension-mdxjs`][mdxjs]
|
||||
— micromark extension to parse JavaScript-aware MDX
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] 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/syntax-tree/mdast-util-mdx/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/syntax-tree/mdast-util-mdx/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-mdx.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/syntax-tree/mdast-util-mdx
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/mdast-util-mdx.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/mdast-util-mdx
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/mdast-util-mdx.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=mdast-util-mdx
|
||||
|
||||
[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/syntax-tree/unist/discussions
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
||||
[license]: license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[health]: https://github.com/syntax-tree/.github
|
||||
|
||||
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[mdast]: https://github.com/syntax-tree/mdast
|
||||
|
||||
[mdast-util-from-markdown]: https://github.com/syntax-tree/mdast-util-from-markdown
|
||||
|
||||
[from-markdown-extension]: https://github.com/syntax-tree/mdast-util-from-markdown#extension
|
||||
|
||||
[mdast-util-to-markdown]: https://github.com/syntax-tree/mdast-util-to-markdown
|
||||
|
||||
[to-markdown-extension]: https://github.com/syntax-tree/mdast-util-to-markdown#options
|
||||
|
||||
[mdast-util-to-hast]: https://github.com/syntax-tree/mdast-util-to-hast
|
||||
|
||||
[mdx]: https://github.com/micromark/micromark-extension-mdx
|
||||
|
||||
[mdxjs]: https://github.com/micromark/micromark-extension-mdxjs
|
||||
|
||||
[remark-mdx]: https://github.com/mdx-js/mdx/tree/next/packages/remark-mdx
|
||||
|
||||
[program]: https://github.com/estree/estree/blob/master/es2015.md#programs
|
||||
|
||||
[api-mdx-from-markdown]: #mdxfrommarkdown
|
||||
|
||||
[api-mdx-to-markdown]: #mdxtomarkdownoptions
|
||||
|
||||
[api-to-markdown-options]: #tomarkdownoptions
|
||||
Loading…
Add table
Add a link
Reference in a new issue