Skip to content

Commit a5daaad

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

12 files changed

+1097
-970
lines changed
 

Diff for: ‎docs/blog/conf.server.mdx

+1-1
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

Diff for: ‎docs/docs/getting-started.server.mdx

+1-1
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

Diff for: ‎docs/index.server.mdx

+1-4
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 */}

Diff for: ‎docs/playground.server.mdx

+6-7
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

Diff for: ‎package-lock.json

+1,066-938
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎package.json

+1-1
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",

Diff for: ‎packages/esbuild/test/files/mdx-file-importing-markdown.mdx

+1-1
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 />

Diff for: ‎packages/esbuild/test/index.test.js

+2-2
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')

Diff for: ‎packages/mdx/test/compile.js

+1-1
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',

Diff for: ‎packages/remark-mdx/index.js

+6-3
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

Diff for: ‎packages/remark-mdx/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"index.js"
4141
],
4242
"dependencies": {
43-
"mdast-util-mdx": "^1.0.0",
43+
"mdast-util-mdx": "^2.0.0",
4444
"micromark-extension-mdxjs": "^1.0.0"
4545
},
4646
"devDependencies": {

Diff for: ‎packages/remark-mdx/test/index.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
22
* @typedef {import('mdast').Root} Root
33
* @typedef {import('mdast').Content} Content
4-
* @typedef {import('mdast-util-mdx').MDXJsxAttribute} MDXJsxAttribute
5-
* @typedef {import('mdast-util-mdx').MDXJsxAttributeValueExpression} MDXJsxAttributeValueExpression
6-
* @typedef {import('mdast-util-mdx').MDXJsxExpressionAttribute} MDXJsxExpressionAttribute
4+
* @typedef {import('mdast-util-mdx').MdxJsxAttribute} MdxJsxAttribute
5+
* @typedef {import('mdast-util-mdx').MdxJsxAttributeValueExpression} MdxJsxAttributeValueExpression
6+
* @typedef {import('mdast-util-mdx').MdxJsxExpressionAttribute} MdxJsxExpressionAttribute
77
*/
88

99
import {test} from 'uvu'
@@ -109,7 +109,7 @@ test('stringify', () => {
109109
])
110110
])
111111
),
112-
'Alpha <b/> charlie.\n',
112+
'Alpha <b /> charlie.\n',
113113
'should serialize a tag with a name'
114114
)
115115

@@ -127,7 +127,7 @@ test('stringify', () => {
127127
])
128128
])
129129
),
130-
'Alpha <b bravo/> charlie.\n',
130+
'Alpha <b bravo /> charlie.\n',
131131
'should serialize a boolean attribute (element)'
132132
)
133133

@@ -148,7 +148,7 @@ test('stringify', () => {
148148
])
149149
])
150150
),
151-
'Alpha <b bravo="bravo"/> charlie.\n',
151+
'Alpha <b bravo="bravo" /> charlie.\n',
152152
'should serialize an attribute (element)'
153153
)
154154

@@ -169,7 +169,7 @@ test('stringify', () => {
169169
])
170170
])
171171
),
172-
'Alpha <b br:avo="bravo"/> charlie.\n',
172+
'Alpha <b br:avo="bravo" /> charlie.\n',
173173
'should serialize a prefixed attribute (element)'
174174
)
175175

@@ -190,7 +190,7 @@ test('stringify', () => {
190190
])
191191
])
192192
),
193-
'Alpha <b {...props}/> charlie.\n',
193+
'Alpha <b {...props} /> charlie.\n',
194194
'should serialize a attribute expression (element)'
195195
)
196196

@@ -220,7 +220,7 @@ test('stringify', () => {
220220
])
221221
])
222222
),
223-
'Alpha <b b={1 + 1}/> charlie.\n',
223+
'Alpha <b b={1 + 1} /> charlie.\n',
224224
'should serialize an expression attribute (element)'
225225
)
226226

@@ -317,7 +317,7 @@ function cleanEstree(tree) {
317317
visit(tree, onvisit)
318318

319319
/**
320-
* @param {Root|Content|MDXJsxAttribute|MDXJsxExpressionAttribute|MDXJsxAttributeValueExpression} node
320+
* @param {Root|Content|MdxJsxAttribute|MdxJsxExpressionAttribute|MdxJsxAttributeValueExpression} node
321321
*/
322322
function onvisit(node) {
323323
if (

1 commit comments

Comments
 (1)

vercel[bot] commented on Feb 1, 2022

@vercel[bot]

Successfully deployed to the following URLs:

Please sign in to comment.