fix(markdown): preserve non-breakable whitespaces (#3327)

This commit is contained in:
Ika authored and Lucas Azzola committed 2017-11-27 19:37:52 +11:00
1 parent 1c9ee6c5a7
commit 9b4ecec183
4 files changed
+48 -3

No files matched your search

+1 -2
View File
@@ -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) {
@@ -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`] = `
<!-- 0xA0 non-breaking whitespace -->
keep these words together keep these words together keep these words together keep these words together
<!-- 0x20 standard whitespace -->
keep these words together keep these words together keep these words together keep these words together
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<!-- 0xA0 non-breaking whitespace -->
keep these words together keep these words together keep these words together keep these words together
<!-- 0x20 standard whitespace -->
keep these words together keep these words together keep these words together
keep these words together
`;
exports[`whitespace.md 2`] = `
<!-- 0xA0 non-breaking whitespace -->
keep these words together keep these words together keep these words together keep these words together
<!-- 0x20 standard whitespace -->
keep these words together keep these words together keep these words together keep these words together
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<!-- 0xA0 non-breaking whitespace -->
keep these words together keep these words together keep these words together keep these words together
<!-- 0x20 standard whitespace -->
keep these words together keep these words together keep these words together keep these words together
`;
+7
View File
@@ -0,0 +1,7 @@
<!-- 0xA0 non-breaking whitespace -->
keep these words together keep these words together keep these words together keep these words together
<!-- 0x20 standard whitespace -->
keep these words together keep these words together keep these words together keep these words together
@@ -3635,7 +3635,7 @@ a*"foo"*
exports[`example-328.md 1`] = `
* a *
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_ a _
_ a _
`;