Files
Tatsunori Uchinoandfisker Cheung 5927216227
Internal ESLint Plugin Test / Test (push) Canceled after 0s
Lint / Lint (push) Canceled after 0s
Build / Build (push) Canceled after 0s
Prod / Lint (push) Canceled after 0s
Prod / Node.js 14 on MacOS (push) Canceled after 0s
Prod / Node.js 14 on Linux (push) Canceled after 0s
Prod / Node.js 14 on Windows (push) Canceled after 0s
Prod / Node.js 16 on Linux (push) Canceled after 0s
Prod / Node.js 18 on Linux (push) Canceled after 0s
Prod / Node.js 20 on Linux (push) Canceled after 0s
Prod / Node.js 22 on Linux (push) Canceled after 0s
Prod / Node.js 24 on Linux (push) Canceled after 0s
Prod / Node.js 26 on MacOS (push) Canceled after 0s
Prod / Node.js 26 on Windows (push) Canceled after 0s
Prod / [Full Test] Node.js 26 on Linux (push) Canceled after 0s
Prod / Browser(firefox) on Linux (push) Canceled after 0s
Prod / Browser(firefox) on Windows (push) Canceled after 0s
Prod / [Full Test] Browser(chrome) on Linux (push) Canceled after 0s
Prod / CLI (push) Canceled after 0s
Prod / Preview release (push) Canceled after 0s
Release Script Test / Test (push) Canceled after 0s
Dev / Node.js 22 on MacOS (push) Canceled after 0s
Dev / Node.js 22 on Linux (push) Canceled after 0s
Dev / Node.js 22 on Windows (push) Canceled after 0s
Dev / Node.js 26 on MacOS (push) Canceled after 0s
Dev / Node.js 26 on Windows (push) Canceled after 0s
Dev / [Full Test] Node.js 26 on Linux (push) Canceled after 0s
Prod / Build (push) Canceled after 0s
fix(markdown): preserve newline around Chinese/Japanese characters not around Korean letters in all proseWrap settings (#20143)
Co-authored-by: fisker Cheung <lionkay@gmail.com>
2026-10-04 11:20:28 +08:00

60 lines
2.0 KiB
JavaScript

const snippets = [
{
name: "Should ignore single trailing space after han before New Line before han",
code: Array.from(
{ length: 6 },
// less "文" <= [..., "文...文 ", "文...文", ...] => more "文"
(_, i) => ["文".repeat(39 + (i >> 1)), i & 1 ? "" : " "],
)
// ["<Line #1>", "<L2>", ...]
.reduce(
(previousInputLines, [base, space]) => [
...previousInputLines,
`${base}${space}\n`,
],
[],
)
.join(""),
// (39 + 40 + 41) * 2 === 40 * 3 * 2 === 40 * 6
// lineWidth is 80 and "文" is double-width
// This is being saved for after Chrome and Safari bug is fixed.
get output() {
/* `${"文".repeat(40)}\n`.repeat(6) */
return this.code.replace(/ (?=\n)/g, "");
},
},
];
{
// Switches to insert-space (2.x-style) mode
const afterword = "测试 Test テスト Test";
const punctuationLike = [
0x3000, // Fullwidth Space but should be treated like punctuation
0x301c, // Genuine CJ(K) punctuation
0xff5e, // Nearly equivalent to U+301C but its Unicode category is "Sm"
0x1f221, // "end" symbol. Should be placed at end
];
const code = `${punctuationLike.map((cp) => `U+${cp.toString(16).toUpperCase()}${String.fromCodePoint(cp)}`).join("\n")} ${afterword}\n`;
snippets.push({
name: "Should remove newline around CJ(K) punctuation(-like)",
code,
// Note: replaceAll is not supported in Node 14.
// In CSS, a line break between a CJK and a non-CJK character is always interchangeable
// with a space, but Prettier v3 made a design mistake where, in some cases,
// it was treated as equivalent to being deleted
// (see https://github.com/prettier/prettier/issues/14936).
// Therefore, .replace is disabled until it gets fixed in
// https://github.com/prettier/prettier/pull/16805.
output: code, // `${code.replace(/\n/g, "")}\n`,
});
}
runFormatTest(
{
importMeta: import.meta,
snippets,
},
["markdown"],
{ proseWrap: "always" },
);