Skip to content

[v4+/Breaking Change] Make space and newline always interchangeable between Chinese/Japanese letter and non-Chinese-or-Japanese character in Markdown#16805

Open
tats-u wants to merge 19 commits intoprettier:nextfrom
tats-u:markdown-newline-handling
Open

[v4+/Breaking Change] Make space and newline always interchangeable between Chinese/Japanese letter and non-Chinese-or-Japanese character in Markdown#16805
tats-u wants to merge 19 commits intoprettier:nextfrom
tats-u:markdown-newline-handling

Conversation

@tats-u
Copy link
Contributor

@tats-u tats-u commented Oct 29, 2024

Description

A part of #15081
Fixes #14936
Blocked by #16816 (Merged)

Always convert \n between han (including Japanese kana) and non-han to a space and allow line breaking at a space between han and non-han again (banned by #16691)

I'll rebase this to next after next merges main one more time. next doesn't include the change by #16691 and this PR depends on it.

Question

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.

Try the playground for this PR

@tats-u tats-u force-pushed the markdown-newline-handling branch from 4376cfd to e8c10f3 Compare November 4, 2024 11:58
@tats-u tats-u changed the base branch from main to next January 16, 2026 03:38
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 16, 2026

Open in StackBlitz

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

commit: c7b50c0

@netlify
Copy link

netlify bot commented Jan 16, 2026

Deploy Preview for prettier ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit c7b50c0
🔍 Latest deploy log https://app.netlify.com/projects/prettier/deploys/696cb7ac66c7aa000867f478
😎 Deploy Preview https://deploy-preview-16805--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
Copy link
Contributor Author

tats-u commented Jan 16, 2026

Once I tidy up the changelog a bit more, it'll be done.

@tats-u tats-u changed the title [next/Breaking Change] Make Markdown's newline handling compatible with browsers' behavior [next/Breaking Change] Make Markdown's newline handling more compatible with the behavior of browsers/CSS Jan 17, 2026
@tats-u tats-u changed the title [next/Breaking Change] Make Markdown's newline handling more compatible with the behavior of browsers/CSS [next/Breaking Change] Make Markdown's newline handling nearly compatible with the behavior of browsers/CSS Jan 17, 2026
@tats-u tats-u marked this pull request as ready for review January 17, 2026 12:05
@tats-u
Copy link
Contributor Author

tats-u commented Jan 18, 2026

Cherry-picked from #18656

autofix-ci bot and others added 2 commits January 18, 2026 02:33
.replace with g flag regex is automatically replaced with .replaceAll probably because Node 14 has already been dropped
@tats-u tats-u changed the title [next/Breaking Change] Make Markdown's newline handling nearly compatible with the behavior of browsers/CSS [next/Breaking Change] Always insert a space between Chinese/Japanese letter and non-Chinese-or-Japanese character Jan 18, 2026
@tats-u tats-u changed the title [next/Breaking Change] Always insert a space between Chinese/Japanese letter and non-Chinese-or-Japanese character [next/Breaking Change] Always insert a space between Chinese/Japanese letter and non-Chinese-or-Japanese character in Markdown Jan 18, 2026
@tats-u tats-u changed the title [next/Breaking Change] Always insert a space between Chinese/Japanese letter and non-Chinese-or-Japanese character in Markdown [next/Breaking Change] Always treat a space and newline interchangeable between Chinese/Japanese letter and non-Chinese-or-Japanese character in Markdown Jan 18, 2026
@tats-u tats-u changed the title [next/Breaking Change] Always treat a space and newline interchangeable between Chinese/Japanese letter and non-Chinese-or-Japanese character in Markdown [next/Breaking Change] Always make space and newline interchangeable between Chinese/Japanese letter and non-Chinese-or-Japanese character in Markdown Jan 18, 2026
@tats-u tats-u changed the title [next/Breaking Change] Always make space and newline interchangeable between Chinese/Japanese letter and non-Chinese-or-Japanese character in Markdown [next/Breaking Change] Make space and newline always interchangeable between Chinese/Japanese letter and non-Chinese-or-Japanese character in Markdown Jan 18, 2026
@tats-u tats-u changed the title [next/Breaking Change] Make space and newline always interchangeable between Chinese/Japanese letter and non-Chinese-or-Japanese character in Markdown [v4+/Breaking Change] Make space and newline always interchangeable between Chinese/Japanese letter and non-Chinese-or-Japanese character in Markdown Jan 18, 2026
@tats-u
Copy link
Contributor Author

tats-u commented Jan 18, 2026

@fisker This is now ready for review.

@tats-u
Copy link
Contributor Author

tats-u commented Jan 18, 2026

K_REGEXP and KIND_K_LETTER in src/language-markdown/utilities.js is now unused anywhere (=can be knipped). May I delete it in this PR or should I create a new PR for it? We will have change CJK_REGEXP to CJ_REGEXP and might use v flag in regex (Node 20+ required) to exclude \p{sc=Hangul} (workaround: use (?!\p{sc=Hang}) instead)

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.

[v4+ / breaking change] Always treat newline between non-punctuation han/kana and alphanumeric as space when proseWrap is always

2 participants