Skip to content

Add tests for NO-BREAK SPACE next to CJK in Markdown - #20321

Merged
fisker merged 1 commit into
prettier:mainfrom
b84330808:test-markdown-nbsp-cjk
Oct 20, 2026
Merged

fisker merged 1 commit into
prettier:mainfrom
b84330808:test-markdown-nbsp-cjk

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

Description

Closes #8701.

The extra space reported in #8701 (Prettier 2.0.5) no longer happens. On 3.9.10 and on main, a<U+00A0>是 is printed unchanged with every proseWrap value.

This adds tests so it stays that way:

  • NO-BREAK SPACE before Chinese (the input from the issue)
  • NO-BREAK SPACE between Chinese and Latin
  • NO-BREAK SPACE between Chinese characters

Each case runs with proseWrap set to always, preserve and never. The tests are in JS with \u{a0}, like splitCjkText/non-bmp, so the character is visible in review.

I checked that the test fails when the expected output has the extra space from the issue. FULL_TEST=1 jest passes for the new tests, and ESLint, Prettier and cSpell pass on the new file.

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.
  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

This only adds tests, so there is no changelog entry. I used Claude Code for this PR and reviewed the change and the test results.

The extra space reported in prettier#8701 no longer happens. Add tests so that
U+00A0 next to Chinese stays unchanged with every proseWrap value.

Closes prettier#8701

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@agentscanapp

agentscanapp Bot commented Oct 18, 2026

Copy link
Copy Markdown

@netlify

netlify Bot commented Oct 18, 2026

Copy link
Copy Markdown

✅ Deploy Preview for prettier ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1b52b72
🔍 Latest deploy log https://app.netlify.com/projects/prettier/deploys/6ad509e0cc5940d699014316
😎 Deploy Preview https://deploy-preview-20321--prettier.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@b84330808

Copy link
Copy Markdown
Contributor Author

About the AgentScan note: I write my changes with Claude Code as an assistant, and it also runs the git and gh commands, which is why the fork, push and PR came seconds apart. I went through the tests and the results below before opening the PR.

This PR only adds tests/format/markdown/splitCjkText/nbsp/format.test.js. It formats three snippets where a no-break space (U+00A0) sits next to Chinese characters, with proseWrap set to always, preserve and never, and checks that the output equals the input: the no-break space is kept and no space is added next to it.

On this branch (1b52b72), FULL_TEST=1 yarn test tests/format/markdown/splitCjkText passes: 3 suites, 72 tests and 8 snapshots.

@fisker

fisker commented Oct 19, 2026

Copy link
Copy Markdown
Member

Do you know which commit fixed it?

@pkg-pr-new

pkg-pr-new Bot commented Oct 19, 2026

Copy link
Copy Markdown

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/@prettier/[email protected]
yarn add https://pkg.pr.new/[email protected]

commit: 1b52b72

@b84330808

Copy link
Copy Markdown
Contributor Author

It was #11597 (ebb8e13, "Markdown: improve whitespace handling in CJK"), released in 3.0.0. With the input from #8701, 3.0.0-alpha.2 still prints a 是 / a 是, and 3.0.0-alpha.3 keeps the input unchanged. Between those two tags, the only commits that touch src/language-markdown are #11597 and #13590 (multiple spaces in inline code), and #11597 is the one that stopped inserting spaces between CJK and Latin characters.

@fisker fisker left a comment

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.

Thank you!

@fisker
fisker merged commit 2113dc7 into prettier:main Oct 20, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Markdown: Extra space added between 'NO-BREAK SPACE' (U+00A0) and Chinese

2 participants