Skip to content

Commit a5daaad

Browse files
authored
Update mdast-util-mdx (#1925)
Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com>
1 parent 9ca9d40 commit a5daaad

File tree

12 files changed

+1097
-970
lines changed

12 files changed

+1097
-970
lines changed

β€Ždocs/blog/conf.server.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ MDXConf is a free and online conference for the MDX community.
1818
Whether you’re just learning about MDX or an expert, there’ll be something for
1919
you! {/* more */}
2020

21-
August 24th, 2020 at 8am PDT/3pm UST <br/> Online β€’ Free
21+
August 24th, 2020 at 8am PDT/3pm UST <br /> Online β€’ Free
2222

2323
## Watch
2424

β€Ždocs/docs/getting-started.server.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ See:
107107
<https://www.gatsbyjs.com/plugins/gatsby-plugin-mdx/#related>
108108
*/}
109109

110-
<a name="mdxprovider"/>
110+
<a name="mdxprovider" />
111111

112112
### JSX
113113

β€Ždocs/index.server.mdx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,7 @@ This makes writing long-form content with components a blast. {/* more */}
113113
It was followed by a warm spring which caused flood conditions in many of
114114
the nearby rivers.
115115

116-
<Chart
117-
year={year}
118-
color="#fcb32c"
119-
/>
116+
<Chart year={year} color="#fcb32c" />
120117
</div>
121118

122119
{/* lint enable */}

β€Ždocs/playground.server.mdx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ export const info = {
99
published: new Date('2021-09-13'),
1010
modified: new Date('2021-11-01')
1111
}
12+
export const playgroundSource = `Hello, world!
13+
Below is an example of markdown in JSX.
14+
15+
<div style={{padding: '1rem', backgroundColor: 'violet'}}>
16+
Try and change the background color to \`tomato\`.`
1217

1318
<Note type="important">
1419
**Note**: V2 is around the corner.
@@ -31,13 +36,7 @@ This can be helpful for debugging or exploring.
3136
To read about how the MDX format works, we recommend that you start with
3237
[Β§ What is MDX][what].
3338

34-
<Editor children={`Hello, world!
35-
Below is an example of markdown in JSX.
36-
37-
<div style={{padding: '1rem', backgroundColor: 'violet'}}>
38-
Try and change the background color to \`tomato\`.
39-
</div>
40-
`}/>
39+
<Editor children={playgroundSource} />
4140

4241
[what]: /docs/what-is-mdx/
4342

β€Žpackage-lock.json

Lines changed: 1066 additions & 938 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žpackage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"eslint-plugin-react-hooks": "^4.0.0",
4949
"eslint-plugin-security": "^1.0.0",
5050
"estree-util-value-to-estree": "^1.0.0",
51-
"globby": "^12.0.0",
51+
"globby": "^13.0.0",
5252
"hast-to-hyperscript": "^10.0.0",
5353
"hast-util-select": "^5.0.0",
5454
"hast-util-to-text": "^3.0.0",

β€Žpackages/esbuild/test/files/mdx-file-importing-markdown.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ import Content from './md-file.md'
55

66
A <Pill>little pill</Pill>.
77

8-
<Content/>
8+
<Content />

β€Žpackages/esbuild/test/index.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* @typedef {import('hast').Root} Root
55
* @typedef {import('vfile').VFile} VFile
66
* @typedef {import('mdx/types').MDXContent} MDXContent
7+
*
8+
* @typedef {import('remark-mdx')}
79
*/
810

911
import {promises as fs} from 'fs'
@@ -241,7 +243,6 @@ test('@mdx-js/esbuild', async () => {
241243
*/
242244
(tree, file) => {
243245
const esm = tree.children[0] // Export
244-
// @ts-expect-error To do: mdast-util-mdx should probably also extend hast?
245246
assert.ok(esm && esm.type === 'mdxjsEsm')
246247
const eol = tree.children[1] // EOL between both, no position.
247248
assert.ok(eol && eol.type === 'text')
@@ -252,7 +253,6 @@ test('@mdx-js/esbuild', async () => {
252253
const text = head.children[0] // Text in heading
253254
assert.ok(text && text.type === 'text')
254255
const jsx = head.children[1] // JSX in heading
255-
// @ts-expect-error To do: mdast-util-mdx should probably also extend hast?
256256
assert.ok(jsx && jsx.type === 'mdxJsxTextElement')
257257
console.log(head)
258258
file.message('1')

β€Žpackages/mdx/test/compile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,13 +696,13 @@ test('compile', async () => {
696696
remarkPlugins: [
697697
() => (/** @type {Root} */ tree) => {
698698
tree.children.unshift({
699-
// @ts-expect-error To do: mdast-util-mdx should probably also extend hast?
700699
type: 'mdxjsEsm',
701700
value: '',
702701
data: {
703702
estree: {
704703
type: 'Program',
705704
comments: [],
705+
sourceType: 'module',
706706
body: [
707707
{
708708
type: 'VariableDeclaration',

β€Žpackages/remark-mdx/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/**
22
* @typedef {import('mdast').Root} Root
3-
* @typedef {import('micromark-extension-mdxjs').Options} Options
3+
* @typedef {import('micromark-extension-mdxjs').Options} MicromarkOptions
4+
* @typedef {import('mdast-util-mdx').ToMarkdownOptions} ToMarkdownOptions
5+
* @typedef {MicromarkOptions & ToMarkdownOptions} Options
6+
*
47
* @typedef {import('mdast-util-mdx')} DoNotTouchAsThisImportItIncludesMdxInTree
58
*/
69

@@ -17,8 +20,8 @@ export default function remarkMdx(options = {}) {
1720
const data = this.data()
1821

1922
add('micromarkExtensions', mdxjs(options))
20-
add('fromMarkdownExtensions', mdxFromMarkdown)
21-
add('toMarkdownExtensions', mdxToMarkdown)
23+
add('fromMarkdownExtensions', mdxFromMarkdown())
24+
add('toMarkdownExtensions', mdxToMarkdown(options))
2225

2326
/**
2427
* @param {string} field

0 commit comments

Comments
 (0)