Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't treat space and newline between Japanese/Chinese characters interchangeable #127

Open
tats-u opened this issue Oct 21, 2024 · 0 comments

Comments

@tats-u
Copy link

tats-u commented Oct 21, 2024

Describe the bug

dprint-plugin-markdown version: 0.17.8

CSS requires line breaks in Japanese/Chinese text should be trimmed instead of converted to spaces.

https://drafts.csswg.org/css-text-4/#line-break-transform

EXAMPLE 16

這個段落是那麼長,
在一行寫不行。最好
用三行寫。

In languages that have no word separators, such as Chinese, “unbreaking” a line requires joining the two lines with no intervening space.

這個段落是那麼長,在一行寫不行。最好用三行寫。

Only Firefox follows this rule today.

https://wpt.fyi/results/css/css-text/line-breaking?label=master&label=experimental&aligned&q=segment-break-transformation-
https://drafts.csswg.org/css-text-4/#line-break-transform

Chrome & Safari's behavior is treated as a bug:

Symbols for the following description:

  • '字': Japanese or Chinese character (e.g. kanji/han, hiragana, and katakana)
  • 'A': One of other characters (e.g. English and Korean)
  • '\n': LF
  • ' ': ASCII Space

Claims:

  1. ' ' in '字' ' ' '字' should not be converted to '\n' but kept as is
  2. '\n' in '字' '\n' '字' should be forcibly trimmed
  3. ' ' or '\n' between '字' and 'A' can be processed by the current way (Prettier is going to forcibly convert it to ' ' but it's just due to the backward compatibility and dprint don't need to follow it)

You might want to see the following related issues/PRs in Prettier for details of backgrounds:

Input Code

日本語 日本語
日本語 日本語
日本語 日本語
English English
日本語 日本語
日本語 日本語
日本語 日本語
English English
日本語 日本語
日本語 日本語
日本語 日本語
English English

textWrap = always

Expected Output

日本語 日本語日本語 日本語日本語 日本語
English English
日本語 日本語日本語 日本語日本語 日本語
English English
日本語 日本語日本語 日本語日本語 日本語
English English

Actual Output

日本語 日本語 日本語 日本語 日本語 日本語 English English 日本語 日本語 日本語
日本語 日本語 日本語 English English 日本語 日本語 日本語 日本語 日本語 日本語
English English

https://dprint.dev/playground/#code/qemhpzR5UQBKYLAFDSuejrwKIDsDmAbAlgM4AWEWeRxK4SsCNa9kj5BJZObVTt1zyPFp0ocKJIA/config/N4KABGBEA2CWB2BTA6rAJgFwBaQFxgA4AGAGnCiQHcAZBRAaQTTymgDNIyJINEAPDMgBOAQwAOLSCOiURATwDOncpEQBbMVhELYCxvGb5IAVwOIhCgMYB7IYiVcoCjEOvwA5vsNRtvIboBrBxVYd3hbRAARWDtLDFgAN0RJNDF-eAwAWlDwu2VuHIiAMVhoKJjEOMTko1T0rMK7TLZS5MdIRsQAZQwRIQxo2PiklLSEBrCIzOc+jHyoToBRA0HK4ZqoOvHsyabEA0gQAF8QIA/plugin/markdown

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

No branches or pull requests

1 participant