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

master
Ika 2017-11-27 16:37:52 +08:00 committed by Lucas Azzola
parent 1c9ee6c5a7
commit 9b4ecec183
4 changed files with 48 additions and 3 deletions

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) {

View File

@ -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
`;

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

View File

@ -3635,7 +3635,7 @@ a*"foo"*
exports[`example-328.md 1`] = `
* a *
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_ a _
_ a _
`;