diff --git a/changelog_unreleased/mdx/pr-6398.md b/changelog_unreleased/mdx/pr-6398.md new file mode 100644 index 000000000..8d04c8294 --- /dev/null +++ b/changelog_unreleased/mdx/pr-6398.md @@ -0,0 +1,21 @@ +#### MDX: fix JSX Fragment format incorrectly ([#6398](https://github.com/prettier/prettier/pull/6398) by [@JounQin](https://github.com/JounQin)) + +Previous versions format JSX Fragment incorrectly in mdx, this has been fixed in this version. + + +```md + +<> + test test + 123 + + +<> +test test + 123 + + +<> + test test + 123 +``` diff --git a/src/language-markdown/mdx.js b/src/language-markdown/mdx.js index a72597777..f8bab299d 100644 --- a/src/language-markdown/mdx.js +++ b/src/language-markdown/mdx.js @@ -26,7 +26,7 @@ const IMPORT_REGEX = /^import\s/; const EXPORT_REGEX = /^export\s/; -const BLOCKS_REGEX = "[a-z\\.]*(\\.){0,1}[a-z][a-z0-9\\.]*"; +const BLOCKS_REGEX = "[a-z][a-z0-9]*(\\.[a-z][a-z0-9]*)*|"; const COMMENT_REGEX = "|"; const EMPTY_NEWLINE = "\n\n"; diff --git a/tests/mdx/__snapshots__/jsfmt.spec.js.snap b/tests/mdx/__snapshots__/jsfmt.spec.js.snap index f5dc83bc8..d15f9aed2 100644 --- a/tests/mdx/__snapshots__/jsfmt.spec.js.snap +++ b/tests/mdx/__snapshots__/jsfmt.spec.js.snap @@ -265,6 +265,12 @@ printWidth: 80 --- +<> + test test + 123 + +--- + | Column 1 | Column 2 | |---|---| | Text | Text | @@ -299,6 +305,12 @@ printWidth: 80 --- +<> + test test + 123 + +--- + | Column 1 | Column 2 | | -------- | ------------------- | | Text | Text | @@ -342,6 +354,12 @@ semi: false --- +<> + test test + 123 + +--- + | Column 1 | Column 2 | |---|---| | Text | Text | @@ -376,6 +394,12 @@ semi: false --- +<> + test test + 123 + +--- + | Column 1 | Column 2 | | -------- | ------------------- | | Text | Text | diff --git a/tests/mdx/jsx.mdx b/tests/mdx/jsx.mdx index 47b911be6..85961c373 100644 --- a/tests/mdx/jsx.mdx +++ b/tests/mdx/jsx.mdx @@ -27,6 +27,12 @@ --- +<> + test test + 123 + +--- + | Column 1 | Column 2 | |---|---| | Text | Text |