Description
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:
- https://issues.chromium.org/issues/40774934
- https://issues.chromium.org/issues/40069685
- https://bugs.webkit.org/show_bug.cgi?id=260857
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:
' '
in'字' ' ' '字'
should not be converted to'\n'
but kept as is'\n'
in'字' '\n' '字'
should be forcibly trimmed' '
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:
- Markdown: Disable breaking a line at the place around Chinese or Japanese characters even when
proseWrap
isalways
prettier/prettier#16710 - [For v3+ / breaking change] Should we change how to handle line breaking surrounded by han/kana when
proseWrap
isalways
prettier/prettier#14936 - Markdown: Don't break a line at the place around Chinese or Japanese characters prettier/prettier#16691
- [Frozen] Make Markdown's newline & space handling conform to web-platform-tests & Firefox's behavior prettier/prettier#15081
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