Skip to content

Commit

Permalink
remove all function changes, keep only doc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
egnor committed Jan 31, 2025
1 parent dbb513f commit d98775c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 35 deletions.
2 changes: 1 addition & 1 deletion docs/docs/extending-mdx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ See also the [list of remark plugins][remark-plugins],
Where to pass plugins is encoded in their name:
remark plugins go in `remarkPlugins`,
rehype plugins go in `rehypePlugins`,
and recma plugins go in `recmaPlugins` (or `recmaJsxPlugins`) of
and recma plugins go in `recmaPlugins` of
[`ProcessorOptions`][processor-options].
Those fields expect lists of plugins and/or of `[plugin, options]`:

Expand Down
29 changes: 12 additions & 17 deletions packages/mdx/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,22 @@
* `mdx/types.js`).
* @property {PluggableList | null | undefined} [recmaPlugins]
* List of [recma plugins](https://github.com/mdx-js/recma#readme) (optional)
* to apply to the final Javascript syntax tree about to be output. Unless
* `jsx: true` is set, these plugins see vanilla JS with JSX rewritten.
* @property {PluggableList | null | undefined} [recmaJsxPlugins]
* List of [recma plugins](https://github.com/mdx-js/recma#readme) (optional)
* to apply to the Javascript-with-JSX tree before JSX tags are rewritten.
* to apply to the final Javascript syntax tree about to be output
* (with JSX exceptions if `jsx: true` is set).
* @property {PluggableList | null | undefined} [remarkPlugins]
* List of [remark plugins](https://github.com/remarkjs/remark#readme)
* (optional) to apply to the parsed markdown-with-JSX (aka MDX) tree just
* before conversion to HTML-with-JSX.
* (optional) to apply to the parsed markdown tree (with MDX extensions)
* just before conversion to HTML.
* @property {PluggableList | null | undefined} [rehypePlugins]
* List of [rehype plugins](https://github.com/rehypejs/rehype#readme)
* (optional) to apply to the HTML-with-JSX tree just before conversion to
* Javascript-with-JSX.
* (optional) to apply to the HTML tree (with MDX extensions) just before
* conversion to Javascript.
* @property {Readonly<RemarkRehypeOptions> | null | undefined} [remarkRehypeOptions]
* Options to pass to `remark-rehype`, which converts
* markdown-with-JSX to HTML-with-JSX (optional); the option
* `allowDangerousHtml` will always be set to `true` and MDX nodes
* (see `nodeTypes`) are passed through; in particular, you might want to
* pass configuration for footnotes if your content is not in English.
* Options to pass to `remark-rehype` (optional) to control conversion of
* markdown to HTML; the option `allowDangerousHtml` will always be
* overridden to `true`, and MDX extension nodes (see `nodeTypes`) are always
* passed through. In particular, you might want to adjust footnote
* configuration here if your content is not in English.
* @property {RehypeRecmaOptions['stylePropertyNameCase']} [stylePropertyNameCase='dom']
* Casing to use for property names in `style` objects (default: `'dom'`);
* CSS casing is for example `background-color` and `-webkit-line-clamp`;
Expand Down Expand Up @@ -222,7 +219,6 @@ export function createProcessor(options) {
.use(settings.rehypePlugins || [])

if (settings.format === 'md') {
// Should this come before rehypePlugins?
pipeline.use(rehypeRemoveRaw)
}

Expand All @@ -238,9 +234,8 @@ export function createProcessor(options) {
}

pipeline
.use(settings.recmaJsxPlugins || [])
.use(recmaJsx)
.use(recmaStringify, settings) // Move recmaStringify after recmaPlugins?
.use(recmaStringify, settings)
.use(settings.recmaPlugins || [])

// @ts-expect-error: TS doesn’t get the plugins we added with if-statements.
Expand Down
28 changes: 11 additions & 17 deletions packages/mdx/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -918,15 +918,10 @@ Configuration for `createProcessor` (TypeScript type).

</details>

* `recmaJsxPlugins` ([`PluggableList` from `unified`][unified-pluggable-list],
optional)
— list of [recma plugins][recma] to apply to the Javascript-with-JSX syntax
tree before JSX tags are rewritten to vanilla JS.

* `rehypePlugins` ([`PluggableList` from `unified`][unified-pluggable-list],
optional)
— list of [rehype plugins][rehype-plugins] to apply to the HTML-with-JSX
syntax tree just before conversion to Javascript-with-JSX.
— list of [rehype plugins][rehype-plugins] to apply to the HTML syntax tree
(with MDX extensions) just before conversion to Javascript.

<details><summary>Expand example</summary>

Expand All @@ -948,8 +943,7 @@ Configuration for `createProcessor` (TypeScript type).
* `remarkPlugins` ([`PluggableList` from `unified`][unified-pluggable-list],
optional)
— list of [remark plugins][remark-plugins] to apply to the
markdown-with-JSX (aka MDX) syntax tree just before conversion to
HTML-with-JSX.
markdown syntax tree (with MDX extensions) just before conversion to HTML.

<details><summary>Expand example</summary>

Expand All @@ -967,11 +961,11 @@ Configuration for `createProcessor` (TypeScript type).

* `remarkRehypeOptions` ([`Options` from
`remark-rehype`][remark-rehype-options], optional)
— options to pass to `remark-rehype`, which converts markdown-with-JSX to
HTML-with-JSX; the option `allowDangerousHtml` will always be set to `true`
and MDX nodes (see [`nodeTypes`][api-node-types]) are passed through;
in particular, you might want to pass configuration for footnotes if your
content is not in English
— options to pass to `remark-rehype` to control conversion of markdown
to HTML; the option `allowDangerousHtml` will always be overriden to `true`,
and MDX extension nodes (see [`nodeTypes`][api-node-types]) are always
passed through. in particular, you might want to adjust footnote
configuration if your content is not in English

<details><summary>Expand example</summary>

Expand Down Expand Up @@ -1142,10 +1136,10 @@ Then we go to JavaScript: [esast][] (JS; an
AST which is compatible with estree but looks a bit more like other unist ASTs).
This transformation is done by
[`rehype-recma`][rehype-recma].
This is a new ecosystem that does not have many utilities or plugins yet.
This is a new ecosystem that does not have utilities or plugins yet.
But it’s where `@mdx-js/mdx` does its thing: where it adds imports/exports,
where it compiles JSX away into `_jsx()` calls, and where it does the other
cool things that it provides.
where it compiles JSX away into `_jsx()` calls, and where it does the other cool
things that it provides.

Finally, The output is serialized JavaScript.
That final step is done by [astring][], a
Expand Down

0 comments on commit d98775c

Please sign in to comment.