diff --git a/src/util.js b/src/util.js index 069c2d591..a4ec8f024 100644 --- a/src/util.js +++ b/src/util.js @@ -683,8 +683,7 @@ function splitText(text) { text .replace(new RegExp(`(${cjkPattern})\n(${cjkPattern})`, "g"), "$1$2") - // `\s` but exclude full-width whitspace (`\u3000`) - .split(/([^\S\u3000]+)/) + .split(/([ \t\n]+)/) .forEach((token, index, tokens) => { // whitespace if (index % 2 === 1) { diff --git a/tests/markdown_paragraph/__snapshots__/jsfmt.spec.js.snap b/tests/markdown_paragraph/__snapshots__/jsfmt.spec.js.snap index baa312bce..1307e9f0a 100644 --- a/tests/markdown_paragraph/__snapshots__/jsfmt.spec.js.snap +++ b/tests/markdown_paragraph/__snapshots__/jsfmt.spec.js.snap @@ -185,3 +185,42 @@ abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc * [valid-expect](/packages/eslint-plugin-jest/docs/rules/valid-expect.md) - ensure expect is called correctly. `; + +exports[`whitespace.md 1`] = ` + + +keep these words together keep these words together keep these words together keep these words together + + + +keep these words together keep these words together keep these words together keep these words together +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +keep these words together keep these words together keep these words together keep these words together + + + +keep these words together keep these words together keep these words together +keep these words together + +`; + +exports[`whitespace.md 2`] = ` + + +keep these words together keep these words together keep these words together keep these words together + + + +keep these words together keep these words together keep these words together keep these words together +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +keep these words together keep these words together keep these words together keep these words together + + + +keep these words together keep these words together keep these words together keep these words together + +`; diff --git a/tests/markdown_paragraph/whitespace.md b/tests/markdown_paragraph/whitespace.md new file mode 100644 index 000000000..6177e0375 --- /dev/null +++ b/tests/markdown_paragraph/whitespace.md @@ -0,0 +1,7 @@ + + +keep these words together keep these words together keep these words together keep these words together + + + +keep these words together keep these words together keep these words together keep these words together diff --git a/tests/markdown_spec/__snapshots__/jsfmt.spec.js.snap b/tests/markdown_spec/__snapshots__/jsfmt.spec.js.snap index 8236588af..01d94deb7 100644 --- a/tests/markdown_spec/__snapshots__/jsfmt.spec.js.snap +++ b/tests/markdown_spec/__snapshots__/jsfmt.spec.js.snap @@ -3635,7 +3635,7 @@ a*"foo"* exports[`example-328.md 1`] = ` * a * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -_ a _ +_ a _ `;