Skip to content

Commit

Permalink
Add support for formatting options
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jan 31, 2022
1 parent b6896e8 commit 8b3dd9e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 8 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* @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 {
Expand All @@ -19,19 +21,21 @@ import {mdxJsxFromMarkdown, mdxJsxToMarkdown} from 'mdast-util-mdx-jsx'
import {mdxjsEsmFromMarkdown, mdxjsEsmToMarkdown} from 'mdast-util-mdxjs-esm'

/**
*
* @return {Array<FromMarkdownExtension>}
*/
export function mdxFromMarkdown() {
return [mdxExpressionFromMarkdown, mdxJsxFromMarkdown(), mdxjsEsmFromMarkdown]
}

/** @return {ToMarkdownExtension} */
export function mdxToMarkdown() {
/**
* @param {ToMarkdownOptions} [options]
* @return {ToMarkdownExtension}
*/
export function mdxToMarkdown(options) {
return {
extensions: [
mdxExpressionToMarkdown,
mdxJsxToMarkdown(),
mdxJsxToMarkdown(options),
mdxjsEsmToMarkdown
]
}
Expand Down
6 changes: 4 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,14 @@ There is no default export.

### `mdxFromMarkdown()`

### `mdxToMarkdown()`
### `mdxToMarkdown(options?)`

Support MDX (or MDX.js).
The exports are functions that can be called to respectively get an extension
for [`mdast-util-from-markdown`][from-markdown] and
[`mdast-util-to-markdown`][to-markdown].

There are no options.
The options to `mdxToMarkdown` are [passed to `mdxJsxToMarkdown`][options].

## Related

Expand Down Expand Up @@ -323,3 +323,5 @@ abide by its terms.
[mdxjs]: https://github.com/micromark/micromark-extension-mdxjs

[remark-mdx]: https://github.com/mdx-js/mdx/tree/next/packages/remark-mdx

[options]: https://github.com/syntax-tree/mdast-util-mdx-jsx#mdxjsxtomarkdownoptions

0 comments on commit 8b3dd9e

Please sign in to comment.