-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
[Frozen] Make Markdown's newline & space handling conform to web-platform-tests & Firefox's behavior #15081
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
base: main
Are you sure you want to change the base?
Conversation
92276e4
to
01d93c6
Compare
894c31f
to
01eb21b
Compare
24e63a7
to
65182d7
Compare
Shoud I add |
Can you send a separate PR for this first?
And we can use this module to do the html trim. |
@fisker In CommonMark spec, the form feed https://spec.commonmark.org/0.30/#unicode-whitespace-character Either way, it is destined to be removed at the stage where the converted HTML is processed, so it may as well be removed at the stage of conversion in Prettier. https://codepen.io/tats-u/pen/bGQjrvM
Trailing form feeds don't seem always to be removed. |
Interesting, https://bugs.webkit.org/show_bug.cgi?id=13159 seems we already made mistake in HTML/Handlebars printer. |
Anyway, I think we should reuse |
@fisker Your change has just been applied. |
90de55f
to
304b1de
Compare
I found an interesting description in https://drafts.csswg.org/css-text-3/#line-break-transform
What sucks is not the HTML or CSS specs but browsers' implementations. |
if (isLink) { | ||
return true; | ||
} | ||
function lineBreakCanBeConvertedToSpace() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we should remove this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends on whether we'll have to add it again.
I can't predict when all browsers will change their behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result looks good, thank you!
@fisker I'll change the behavior. I looked into the detailed behavior of Firefox. Table: Is a newline between the followings converted to a space in Firefox?
A newline between [Chinese & Japanese & CJK punctuations] should not be converted to a space.
↓ OK
↓ STOP!
This will improve the compatibility with the conventional behavior to some extend and reduce browser-defined behaviors. A space around Chinese (& Japanese) is going not to be converted to a newline. It's not compatible with Firefox. |
Didn't get it. |
These seem to be treated as a single group in Firefox. |
Should't we only need make sure the output equivalence in html? Ah, maybe you are right, in markdown one single new line doesn't generate a space. But should not related to languages. |
Does it mean it's better to always treat a newline in Markdown as a space even if surrounded only by han or kana? |
@fisker @sosukesuzuki Recently I have noticed the plan for the release of v4. |
Current v4 is published for the new CLI test. |
I see. I'll create a new PR based on this, but reducing the change. This force push is just for following the latest content of
|
21bff02
to
e7ad613
Compare
open-telemetry/opentelemetry.io#4341 I read this and decided to stop Prettier from wrapping lines even between Chinese / Japanese for a while. #16691's title and behavior will be changed. This PR will be kept opened to be worked on after the following browsers' bugs are fixed: |
e7ad613
to
10b2725
Compare
10b2725
to
a7d84bb
Compare
a7d84bb
to
10b2725
Compare
I found #16691 hasn't been merged into |
This behavior should be improved in Firefox or CSS WG
577f652
to
feda80b
Compare
Description
Closes #16819
Make the lline wrap between Chinese/Japanese and other compatible with browsers→ Markdown: Don't break a line at the place around Chinese or Japanese characters #16691Don't wrap even Chinese & Japanese when→ Markdown: Don't break a line at the place around Chinese or Japanese characters #16691proseWrap
isalways
Make newline and whitespace interchangeable even between (Chinese or Japanese) and another character when→ [next/Breaking Change] Make Markdown's newline handling compatible with browsers' behavior #16805proseWrap
isalways
ornever
([For v3+ / breaking change] Should we change how to handle line breaking surrounded by han/kana whenproseWrap
isalways
#14936)Treat U+30A0 & U+30FB in Kataka Block as CJK (False-negative: Katakana Middle Dot (・ / U+30FB) & Katakana-Hiragana Double Hyphen (゠ / U+30A0) ikatyang-collab/cjk-regex#189)→ Treat U+30A0 & U+30FB in Katakana Block as CJK #16796proseWrap
isalways
Don't trim spaces other than ASCII whitespace at the beginning or end of paragraphs→ Markdown: preserve non-ASCII whitespaces at the end of the line and beginning of the next line #16619Waiting for:
Checklist
docs/
directory).changelog_unreleased/*/XXXX.md
file followingchangelog_unreleased/TEMPLATE.md
.✨Try the playground for this PR✨