|
1 | 1 | /**
|
2 | 2 | * @import {Program} from 'estree-jsx'
|
3 |
| - * @import {ElementAttributeNameCase, StylePropertyNameCase} from 'hast-util-to-estree' |
4 | 3 | * @import {Root} from 'mdast'
|
| 4 | + * @import {Options as RehypeRecmaOptions} from 'rehype-recma' |
5 | 5 | * @import {Options as RemarkRehypeOptions} from 'remark-rehype'
|
6 | 6 | * @import {SourceMapGenerator} from 'source-map'
|
7 | 7 | * @import {PluggableList, Processor} from 'unified'
|
8 |
| - * @import {Node} from 'unist' |
9 | 8 | */
|
10 | 9 |
|
11 | 10 | /**
|
|
24 | 23 | * when using the webpack loader (`@mdx-js/loader`) or the Rollup integration
|
25 | 24 | * (`@mdx-js/rollup`) through Vite, this is automatically inferred from how
|
26 | 25 | * you configure those tools.
|
27 |
| - * @property {ElementAttributeNameCase | null | undefined} [elementAttributeNameCase='react'] |
| 26 | + * @property {RehypeRecmaOptions['elementAttributeNameCase']} [elementAttributeNameCase='react'] |
28 | 27 | * Casing to use for attribute names (default: `'react'`);
|
29 | 28 | * HTML casing is for example `class`, `stroke-linecap`, `xml:lang`;
|
30 | 29 | * React casing is for example `className`, `strokeLinecap`, `xmlLang`;
|
|
112 | 111 | * nodes (see `nodeTypes`) are passed through;
|
113 | 112 | * In particular, you might want to pass configuration for footnotes if your
|
114 | 113 | * content is not in English.
|
115 |
| - * @property {StylePropertyNameCase | null | undefined} [stylePropertyNameCase='dom'] |
| 114 | + * @property {RehypeRecmaOptions['stylePropertyNameCase']} [stylePropertyNameCase='dom'] |
116 | 115 | * Casing to use for property names in `style` objects (default: `'dom'`);
|
117 | 116 | * CSS casing is for example `background-color` and `-webkit-line-clamp`;
|
118 | 117 | * DOM casing is for example `backgroundColor` and `WebkitLineClamp`;
|
|
125 | 124 | */
|
126 | 125 |
|
127 | 126 | import {unreachable} from 'devlop'
|
| 127 | +import recmaBuildJsx from 'recma-build-jsx' |
| 128 | +import recmaJsx from 'recma-jsx' |
| 129 | +import recmaStringify from 'recma-stringify' |
| 130 | +import rehypeRecma from 'rehype-recma' |
128 | 131 | import remarkMdx from 'remark-mdx'
|
129 | 132 | import remarkParse from 'remark-parse'
|
130 | 133 | import remarkRehype from 'remark-rehype'
|
131 | 134 | import {unified} from 'unified'
|
| 135 | +import {recmaBuildJsxTransform} from './plugin/recma-build-jsx-transform.js' |
132 | 136 | import {recmaDocument} from './plugin/recma-document.js'
|
133 |
| -import {recmaJsxBuild} from './plugin/recma-jsx-build.js' |
134 | 137 | import {recmaJsxRewrite} from './plugin/recma-jsx-rewrite.js'
|
135 |
| -import {recmaStringify} from './plugin/recma-stringify.js' |
136 |
| -import {rehypeRecma} from './plugin/rehype-recma.js' |
137 | 138 | import {rehypeRemoveRaw} from './plugin/rehype-remove-raw.js'
|
138 | 139 | import {remarkMarkAndUnravel} from './plugin/remark-mark-and-unravel.js'
|
139 | 140 | import {nodeTypes} from './node-types.js'
|
@@ -225,12 +226,13 @@ export function createProcessor(options) {
|
225 | 226 | .use(recmaJsxRewrite, settings)
|
226 | 227 |
|
227 | 228 | if (!settings.jsx) {
|
228 |
| - pipeline.use(recmaJsxBuild, settings) |
| 229 | + pipeline.use(recmaBuildJsx, settings).use(recmaBuildJsxTransform, settings) |
229 | 230 | }
|
230 | 231 |
|
231 |
| - // @ts-expect-error: `Program` is close enough to a `Node`, |
232 |
| - // but type inference has trouble with it and bridges. |
233 |
| - pipeline.use(recmaStringify, settings).use(settings.recmaPlugins || []) |
| 232 | + pipeline |
| 233 | + .use(recmaJsx) |
| 234 | + .use(recmaStringify, settings) |
| 235 | + .use(settings.recmaPlugins || []) |
234 | 236 |
|
235 | 237 | // @ts-expect-error: TS doesn’t get the plugins we added with if-statements.
|
236 | 238 | return pipeline
|
|
0 commit comments