Skip to content

Treat U+3000 as CJK punctuation-equivalent and make sure to recognize U+FF5E as CJK punctuation again in Markdown prose wrap#18656

Merged
fisker merged 19 commits intoprettier:mainfrom
tats-u:ff5e-punct-2
Jan 18, 2026
Merged

Treat U+3000 as CJK punctuation-equivalent and make sure to recognize U+FF5E as CJK punctuation again in Markdown prose wrap#18656
fisker merged 19 commits intoprettier:mainfrom
tats-u:ff5e-punct-2

Conversation

@tats-u
Copy link
Copy Markdown
Contributor

@tats-u tats-u commented Jan 16, 2026

Description

Cherry-picked from #16805 (U+FF5E)

U+FF5E
U+3000

I noticed that U+FF5E ~ is not treated as a punctuation unlike U+301C 〜 (both are used in the same way in Japanese) in current Prettier by a failing test there. I should have fixed it in #16832, but a regression seems to have occurred.

https://prettier.io/playground/#N4Igxg9gdgLgprEAuEhpW0KvRACAKnAzjJoGMMgnQyATDDvjADpQCqA1AMwAMAjAMKA4DLYwGJ8ArAFFAev+8GbPgCZpbQDwbgQj3aIADQgIABxgBLaHmSgAhgCcTEAO4AFUwgMojAGwtGAngfUAjE0bABrOBgAZSMAWzgAGR0oOGQAMyc8OHUITwArODAYAHUfTWQQTRN8OBMAN1ivH39AoM1faIBzZBgTAFdkkCTQnRb2zrgAD01SnXDYJwB5EZ8YCBMrCDwdXWgChAATNRAhmbGEGCdcEyhTHXx4xM7lqEbHOABFNoh4S8ck9TS8QaCm+6eXrEkAl3p0AI7PeBWcyaewgIx4AC0MTgG1R21aRh0jiaHAgoVCRgKTkc2xudzgAEEYK0dJ42lDSlEYm8PiAABYwUKObLslb4epgOBBOwrHRlFauApgPAeEBlDoASSgaNgQTAJh02kpKqCMFc91ZnSKSzguSM+Qczjccs2kzizKBIEccW20SSJhg0KMjUJRvU9RMHoKhJMfg2lig2yK0RyOg2MHZyAAHCx1MUITpit7fUTgVd1IdPNl44nkNJ1G0ktgjJ57CC2XBQp5UWiNhEjLc2j64Hx5oSaU1iQyICAAL5joA

Recent FIrefox added U+3000 to the CJ(K) punctuation list. I will add it to Prettier as a bonus, too.

<!-- Input (--prose-wrap=never) -->
测试 Test テスト Test
U+3000 
U+301C〜
U+FF5E~
U+1F221🈡

<!-- Prettier stable -->
测试 Test テスト Test U+3000  U+301C〜U+FF5E~ U+1F221🈡

<!-- Prettier main -->
测试 Test テスト Test U+3000 U+301C〜U+FF5E~U+1F221🈡

Firefox preview for HTML (ja or zh is mandatory to trim spaces around these characters):

{23612626-1FB5-4AE7-840E-7FEC231BF057}

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

@tats-u tats-u changed the title Make sure to recognize U+FF5E as punctuation Make sure to recognize U+FF5E as punctuation again Jan 16, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jan 16, 2026

Open in StackBlitz

yarn add https://pkg.pr.new/@prettier/[email protected]
yarn add https://pkg.pr.new/@prettier/[email protected]
yarn add https://pkg.pr.new/[email protected]

commit: 84a92ad

@netlify
Copy link
Copy Markdown

netlify Bot commented Jan 16, 2026

Deploy Preview for prettier ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 84a92ad
🔍 Latest deploy log https://app.netlify.com/projects/prettier/deploys/696c36e29d19e900084844b4
😎 Deploy Preview https://deploy-preview-18656--prettier.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@tats-u tats-u changed the title Make sure to recognize U+FF5E as punctuation again Treat U+3000 as punctuation and make sure to recognize U+FF5E as punctuation again Jan 16, 2026
@fisker
Copy link
Copy Markdown
Member

fisker commented Jan 16, 2026

Can you post an example, what will change?

If I'm not wrong, this will effect how sentence splits? In my experience, at least in Chinese, no one use U+3000 as punctuation, it's only used in one place, which is make alignment.

@tats-u
Copy link
Copy Markdown
Contributor Author

tats-u commented Jan 16, 2026

no one use U+3000 as punctuation

Right, but if the line is ended with it, isn't it superfluous that an extra ASCII space is inserted after it when they are aggregated into one line?

  Markdown初学者写的第一个Paragraph
  Markdown初学者写的下一个段落。

❌️  Markdown初学者写的第一个Paragraph   Markdown初学者写的下一个段落。
✅️  Markdown初学者写的第一个Paragraph  Markdown初学者写的下一个段落。

Current Firefox's rule: biomejs/biome#7304 (comment)

@fisker
Copy link
Copy Markdown
Member

fisker commented Jan 16, 2026

Right, but if the line is ended with it, isn't it superfluous that an extra ASCII space is inserted after it when they are aggregated into one line?

So, this change means, only if u+3000 at end, it will not insert space when merge with next line? (I'm really sorry that I don't know enough about our markdown printer)

@tats-u tats-u changed the title Treat U+3000 as punctuation and make sure to recognize U+FF5E as punctuation again Treat U+3000 as punctuation and make sure to recognize U+FF5E as punctuation again in Markdown prose wrap Jan 16, 2026
@tats-u tats-u changed the title Treat U+3000 as punctuation and make sure to recognize U+FF5E as punctuation again in Markdown prose wrap Treat U+3000 as CJK punctuation and make sure to recognize U+FF5E as CJK punctuation again in Markdown prose wrap Jan 16, 2026
@tats-u
Copy link
Copy Markdown
Contributor Author

tats-u commented Jan 16, 2026

it will not insert space when merge with next line?

Currently (without #16805), the writer must prefer to add a space between a han and an alphanumeric (applies to many Chinese and some Japanese; i.e. Prettier 2.x before #11597) to notify the change. Prettier (without #16805) will not insert a space even when it detects that style in (probably) a paragraph.

This change affects on the condition where proseWrap is other than preserve.

if u+3000 at end

\n → newline, [H] → han (or kana), [E] → non Han, [ ] → U+3000, → U+0020

This change (for U+3000) only applies to the patterns when they are tried to be squashed into one line when Prettier detects the pre-#11597 style:

Pattern Current Changed to
[ ]\n[E] [ ]␣[E] [ ][E]
[E]\n[ ] [E]␣[ ] [E][ ]

They do not affect:

Pattern Current Changed to
[ ]\n[H] [ ][H] [ ][H]
[H]\n[ ] [H][ ] [H][ ]
[ ]\n[ ] [ ][ ] [ ][ ]

@tats-u tats-u changed the title Treat U+3000 as CJK punctuation and make sure to recognize U+FF5E as CJK punctuation again in Markdown prose wrap Treat U+3000 as CJK punctuation-equivalent and make sure to recognize U+FF5E as CJK punctuation again in Markdown prose wrap Jan 16, 2026
@tats-u tats-u marked this pull request as draft January 16, 2026 15:46
Comment thread tests/format/markdown/splitCjkText/symbolSpaceNewLine.md Outdated
@tats-u tats-u marked this pull request as ready for review January 17, 2026 11:38
@tats-u tats-u requested a review from fisker January 17, 2026 11:39
Comment thread changelog_unreleased/markdown/18656.md
Comment thread changelog_unreleased/markdown/18656.md
@tats-u tats-u requested a review from fisker January 17, 2026 14:28
Comment thread changelog_unreleased/markdown/18656.md Outdated
await require('prettier').format('测试 Test テスト Test\nU+3000\u{3000}\nU+301C\u{301C}\nU+FF5E\u{FF5E}\nU+1F221\u{1F221}\n', {parser: 'markdown', proseWrap: 'always'});

# Prettier stable
// -> '测试 Test テスト Test\nU+3000\u{3000} \nU+301C\u{301C}\nU+FF5E\u{FF5E} \nU+1F221\u{1F221}\n'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// -> '测试 Test テスト Test\nU+3000\u{3000} \nU+301C\u{301C}\nU+FF5E\u{FF5E} \nU+1F221\u{1F221}\n'
// -> '测试 Test テスト Test\nU+3000\u{3000} \nU+301C\u{301C}\nU+FF5E\u{FF5E} \nU+1F221\u{1F221}\n'
// ^ extra space

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, this is not the real output, please actually run the code above and copy the print.

Since U+3000 is not visible, you can use this script

const output = await require('prettier').format('测试 Test テスト Test\nU+3000\u{3000}\nU+301C\u{301C}\nU+FF5E\u{FF5E}\nU+1F221\u{1F221}\n', {parser: 'markdown', proseWrap: 'always'});
[...output.slice(23, 26)].map(character => `\\u${character.codePointAt(0).toString(16)}`);

Comment thread changelog_unreleased/markdown/18656.md Outdated
Comment thread changelog_unreleased/markdown/18656.md Outdated
@tats-u
Copy link
Copy Markdown
Contributor Author

tats-u commented Jan 18, 2026

image

Other than "测试" is https://github.com/yuru7/udev-gothic (Japanese font). The dotted squares are U+3000.

Copy link
Copy Markdown
Member

@fisker fisker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tats-u tats-u marked this pull request as draft January 18, 2026 01:13
@tats-u
Copy link
Copy Markdown
Contributor Author

tats-u commented Jan 18, 2026

Do we need <!-- prettier-ignore --> in the code block in the changelog Markdown?
The code await require('prettier').format('U+3000\u{3000}\nU+301C\u{301C}\nU+FF5E\u{FF5E}\nU+1F221\u{1F221} 测试 Test テスト\n', {parser: 'markdown', proseWrap: 'always'}); will be multi lines without it.

@fisker
Copy link
Copy Markdown
Member

fisker commented Jan 18, 2026

Do we need in the code block in the changelog Markdown?

No, since it's pure JS code.

@tats-u
Copy link
Copy Markdown
Contributor Author

tats-u commented Jan 18, 2026

image

Comment thread changelog_unreleased/markdown/18656.md Outdated
```js
await prettier.format(
"测试 Test テスト Test\nU+3000\u{3000}\nU+301C\u{301C}\nU+FF5E\u{FF5E}\nU+1F221\u{1F221}\n",
await require("prettier").format(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use prettier instead of require("prettier").

Copy link
Copy Markdown
Contributor Author

@tats-u tats-u Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, but you will have to run prettier = require("prettier").default in advance.

@tats-u tats-u marked this pull request as ready for review January 18, 2026 01:26
@fisker fisker merged commit 1f678ab into prettier:main Jan 18, 2026
39 checks passed
@fisker
Copy link
Copy Markdown
Member

fisker commented Jan 18, 2026

Thank you as always.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants