Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mdx): treat jsx codeblock same as in markdown #5391

Merged
merged 2 commits into from Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/language-js/printer-estree.js
Expand Up @@ -6259,7 +6259,7 @@ function isUnitTestSetUp(n) {
}

function isTheOnlyJSXElementInMarkdown(options, path) {
if (options.parentParser !== "markdown") {
if (options.parentParser !== "markdown" && options.parentParser !== "mdx") {
return false;
}

Expand Down
42 changes: 42 additions & 0 deletions tests/mdx/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -198,6 +198,48 @@ exports[`jsx.mdx - mdx-verify 2`] = `

`;

exports[`jsx-codeblock.mdx - mdx-verify 1`] = `
\`\`\`jsx
<div>foo</div>
\`\`\`

\`\`\`jsx
const a = 1;
<div>foo</div>;
\`\`\`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\`\`\`jsx
<div>foo</div>
\`\`\`

\`\`\`jsx
const a = 1;
<div>foo</div>;
\`\`\`

`;

exports[`jsx-codeblock.mdx - mdx-verify 2`] = `
\`\`\`jsx
<div>foo</div>
\`\`\`

\`\`\`jsx
const a = 1;
<div>foo</div>;
\`\`\`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\`\`\`jsx
<div>foo</div>
\`\`\`

\`\`\`jsx
const a = 1
;<div>foo</div>
\`\`\`

`;

exports[`mixed.mdx - mdx-verify 1`] = `
import { Baz } from './Fixture'
import { Buz } from './Fixture'
Expand Down
8 changes: 8 additions & 0 deletions tests/mdx/jsx-codeblock.mdx
@@ -0,0 +1,8 @@
```jsx
<div>foo</div>
```

```jsx
const a = 1;
<div>foo</div>;
```