MDX: fix JSX format (#9267)
This commit is contained in:
1 parent
ff0a886e16
commit
50eeaadeca
6 files changed
+78
-8
No files matched your search
@@ -0,0 +1,35 @@
|
||||
#### Fix JSX format (#9267 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```markdown
|
||||
<!-- Input -->
|
||||
# title
|
||||
|
||||
<Jsx>
|
||||
|
||||
text
|
||||
|
||||
</Jsx>
|
||||
|
||||
<!-- Prettier stable -->
|
||||
# title
|
||||
|
||||
<Jsx>
|
||||
|
||||
|
||||
text
|
||||
|
||||
</Jsx>
|
||||
|
||||
|
||||
(Extra empty lines added after `<Jsx>` and `</Jsx>`)
|
||||
|
||||
<!-- Prettier master -->
|
||||
# title
|
||||
|
||||
<Jsx>
|
||||
|
||||
text
|
||||
|
||||
</Jsx>
|
||||
```
|
||||
@@ -431,11 +431,12 @@ function genericPrint(path, options, print) {
|
||||
case "liquidNode":
|
||||
return concat(replaceEndOfLineWith(node.value, hardline));
|
||||
// MDX
|
||||
// fallback to the original text if multiparser failed
|
||||
// or `embeddedLanguageFormatting: "off"`
|
||||
case "importExport":
|
||||
case "jsx":
|
||||
// fallback to the original text if multiparser failed
|
||||
// or `embeddedLanguageFormatting: "off"`
|
||||
return concat([node.value, hardline]);
|
||||
case "jsx":
|
||||
return node.value;
|
||||
case "math":
|
||||
return concat([
|
||||
"$$",
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`issue-9260.mdx - {"embeddedLanguageFormatting":"off"} format 1`] = `
|
||||
====================================options=====================================
|
||||
embeddedLanguageFormatting: "off"
|
||||
parsers: ["mdx"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
# title
|
||||
|
||||
<Parenthesis>
|
||||
|
||||
CR: Carriage Return, \\r
|
||||
LF: Line Feed, \\n
|
||||
|
||||
</Parenthesis>
|
||||
|
||||
=====================================output=====================================
|
||||
# title
|
||||
|
||||
<Parenthesis>
|
||||
|
||||
CR: Carriage Return, \\r
|
||||
LF: Line Feed, \\n
|
||||
|
||||
</Parenthesis>
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -0,0 +1,8 @@
|
||||
# title
|
||||
|
||||
<Parenthesis>
|
||||
|
||||
CR: Carriage Return, \r
|
||||
LF: Line Feed, \n
|
||||
|
||||
</Parenthesis>
|
||||
@@ -0,0 +1 @@
|
||||
run_spec(__dirname, ["mdx"], { embeddedLanguageFormatting: "off" });
|
||||
@@ -127,14 +127,12 @@ printWidth: 80
|
||||
<Heading hi='there'>Hello, world!
|
||||
</Heading>
|
||||
|
||||
|
||||
---
|
||||
|
||||
<Hello>
|
||||
test <World /> test
|
||||
</Hello>123
|
||||
|
||||
|
||||
---
|
||||
|
||||
<Hello>
|
||||
@@ -144,7 +142,6 @@ printWidth: 80
|
||||
test <World /> test
|
||||
</Hello>123
|
||||
|
||||
|
||||
---
|
||||
|
||||
<Hello>
|
||||
@@ -154,14 +151,12 @@ printWidth: 80
|
||||
test <World /> test
|
||||
</Hello> 234
|
||||
|
||||
|
||||
---
|
||||
|
||||
<>
|
||||
test <World /> test
|
||||
</> 123
|
||||
|
||||
|
||||
---
|
||||
|
||||
| Column 1 | Column 2 |
|
||||
|
||||
Reference in new issue
Block a user