From ac46a4f16eaaf73c1ba82b7cdec6d10ab18ad38a Mon Sep 17 00:00:00 2001 From: Tatsunori Uchino Date: Wed, 27 Nov 2024 00:52:53 +0900 Subject: [PATCH] Treat U+30A0 & U+30FB in Katakana Block as CJK (#16796) --- changelog_unreleased/markdown/16796.md | 25 +++++++++++++++++++ cspell.json | 1 + src/language-markdown/constants.evaluate.js | 9 ++++++- .../__snapshots__/format.test.js.snap | 12 +++++++++ .../splitCjkText/symbolSpaceNewLine.md | 10 ++++++++ 5 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 changelog_unreleased/markdown/16796.md diff --git a/changelog_unreleased/markdown/16796.md b/changelog_unreleased/markdown/16796.md new file mode 100644 index 000000000..3e6612d00 --- /dev/null +++ b/changelog_unreleased/markdown/16796.md @@ -0,0 +1,25 @@ +#### Treat U+30A0 & U+30FB in Katakana Block as CJK (#16796 by @tats-u) + +Prettier doesn't treat U+30A0 & U+30FB as Japanese. U+30FB is commonly used in Japanese to represent the delimitation of first and last names of non-Japanese people or “and”. The following “C言語・C++・Go・Rust” means “C language & C++ & Go & Rust” in Japanese. + + +```md + + +C言 +語 +・ +C++ +・ +Go +・ +Rust + + +C言語・ C++ ・ Go ・ Rust + + +C言語・C++・Go・Rust +``` + +U+30A0 can be used as the replacement of the `-` in non-Japanese names (e.g. “Saint-Saëns” (Charles Camille Saint-Saëns) can be represented as “サン゠サーンス” in Japanese), but substituted by ASCII hyphen (U+002D) or U+FF1D (full width hyphen) in many cases (e.g. “サン=サーンス” or “サン=サーンス”). diff --git a/cspell.json b/cspell.json index 5d888bc73..c35b8b1b1 100644 --- a/cspell.json +++ b/cspell.json @@ -241,6 +241,7 @@ "Rubocop", "ruleset", "rulesets", + "Saëns", "sandhose", "Sapegin", "sbdchd", diff --git a/src/language-markdown/constants.evaluate.js b/src/language-markdown/constants.evaluate.js index 24ee2e31e..816ce3c5f 100644 --- a/src/language-markdown/constants.evaluate.js +++ b/src/language-markdown/constants.evaluate.js @@ -14,7 +14,14 @@ const cjkCharset = new Charset( "Modifier_Symbol", "Nonspacing_Mark", ], - }), + // .union below makes the next Block condition "OR" + // If it is merged into this object definition, it will be "AND" instead + }).union( + // Firefox treats some symbols (U+30A0, U+30FB) in the Katakana block as CJK + unicodeRegex({ + Block: ["Katakana"], + }), + ), ); const variationSelectorsCharset = unicodeRegex({ Block: ["Variation_Selectors", "Variation_Selectors_Supplement"], diff --git a/tests/format/markdown/splitCjkText/__snapshots__/format.test.js.snap b/tests/format/markdown/splitCjkText/__snapshots__/format.test.js.snap index 4b9b76376..e587af369 100644 --- a/tests/format/markdown/splitCjkText/__snapshots__/format.test.js.snap +++ b/tests/format/markdown/splitCjkText/__snapshots__/format.test.js.snap @@ -283,6 +283,16 @@ English [ウ ィキペディア]: https://ja.wikipedia.org/ + +C言 +語 +・ +C++ +・ +Go +・ +Rust + =====================================output===================================== 日本語、にほんご。汉语, 中文. 日本語,にほんご.English words!? 漢字!汉字?「セリフ」(括弧) 文字(括弧)文字【括弧】日本語English @@ -297,5 +307,7 @@ words!? 漢字!汉字?「セリフ」(括弧) 文字(括弧)文字【括 [ウ ィキペディア]: https://ja.wikipedia.org/ +C言語・C++・Go・Rust + ================================================================================ `; diff --git a/tests/format/markdown/splitCjkText/symbolSpaceNewLine.md b/tests/format/markdown/splitCjkText/symbolSpaceNewLine.md index f46aaee81..013ca9ba4 100644 --- a/tests/format/markdown/splitCjkText/symbolSpaceNewLine.md +++ b/tests/format/markdown/splitCjkText/symbolSpaceNewLine.md @@ -57,3 +57,13 @@ English [ウ ィキペディア]: https://ja.wikipedia.org/ + + +C言 +語 +・ +C++ +・ +Go +・ +Rust