[unicode] Fix trailing nbsp (#5165)

I don't know why I added all the unicode whitespaces instead of just space and tabs, but it's not only unecessary but also wrong.

Fixes #5077
master
Christopher Chedeau 2018-09-29 15:22:13 -07:00 committed by GitHub
parent 80c22d8e39
commit 9910536b58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 2 deletions

View File

@ -476,14 +476,14 @@ function printDocToString(doc, options) {
while (
out.length > 0 &&
typeof out[out.length - 1] === "string" &&
out[out.length - 1].match(/^[^\S\n]*$/)
out[out.length - 1].match(/^[ \t]*$/)
) {
out.pop();
}
if (out.length && typeof out[out.length - 1] === "string") {
out[out.length - 1] = out[out.length - 1].replace(
/[^\S\n]*$/,
/[ \t]*$/,
""
);
}

View File

@ -23,6 +23,12 @@ non_breaking_spaces = <div>]   [</div>
em_space = <div>][</div>
hair_space = <div>][</div>
zero_width_space = <div>][</div>
real_world_non_breaking_spaces = <p>
Supprimer lobjectif « {goal.name} » ?
</p>
real_world_non_breaking_spaces2 = <p>
Supprimer lobjectif padding padding padding padding padding padding « {goal.name} » ?
</p>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Treated as whitespace in JSX
spaces = <div>] [</div>;
@ -39,5 +45,12 @@ non_breaking_spaces = <div>]   [</div>;
em_space = <div>][</div>;
hair_space = <div>][</div>;
zero_width_space = <div>][</div>;
real_world_non_breaking_spaces = <p>Supprimer lobjectif « {goal.name} » ?</p>;
real_world_non_breaking_spaces2 = (
<p>
Supprimer lobjectif padding padding padding padding padding padding « 
{goal.name} » ?
</p>
);
`;

View File

@ -20,3 +20,9 @@ non_breaking_spaces = <div>]   [</div>
em_space = <div>][</div>
hair_space = <div>][</div>
zero_width_space = <div>][</div>
real_world_non_breaking_spaces = <p>
Supprimer lobjectif « {goal.name} » ?
</p>
real_world_non_breaking_spaces2 = <p>
Supprimer lobjectif padding padding padding padding padding padding « {goal.name} » ?
</p>

View File

@ -17,3 +17,16 @@ exports[`keys.js - flow-verify 1`] = `
({ この事はつもり素晴らしいことさ: "35jL9V" });
`;
exports[`nbsp-jsx.js - flow-verify 1`] = `
// Note: there are non breaking spaces in the JSX text
x = <p> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa </p>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Note: there are non breaking spaces in the JSX text
x = (
<p>
 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 
</p>
);
`;

View File

@ -0,0 +1,2 @@
// Note: there are non breaking spaces in the JSX text
x = <p> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa </p>;