Repository navigation
Remove the stray spaces that line breaks put into the Chinese copy - #9
Conversation
JSX trims each line of a text block and joins the lines with one space.
The Chinese copy is wrapped across source lines throughout the course, so
it rendered with spaces between Chinese characters and around full-width
punctuation: 1,572 of them in 36 files.
- 1,548 line breaks are joined by a script that walks the TypeScript
syntax tree and touches only JSX text and JSX attribute strings, never
code samples, template literals or comments. Breaks next to Latin
letters, digits, expressions, "——" or operators keep their space.
- 24 more spaces go: 20 after full-width punctuation, 3 between Chinese
text and a tag whose text is Chinese, and one {" "} between a
full-width mark and Chinese text.
- test/zh-copy-spacing.test.ts, the check DataData and AlgoAlgo use,
scans every TSX file and fails on any new stray space; CLAUDE.md states
the rule.
Apart from the one {" "}, the diff changes nothing but whitespace. The
text every edited file renders differs from master only by deleted
spaces, each next to Chinese text, so the English copy is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2148ad8427
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| for (const m of raw.matchAll(/(\S)( +)(\S)/g)) { | ||
| const a = m[1], b = m[3]; | ||
| const stray = (PUNCT.test(a) || (a === "…" && closesChinese(raw, m.index!))) && ZH.test(b) && b !== "—"; |
There was a problem hiding this comment.
Reject spaces between Han characters
When an unwanted space is written on the same source line between two Chinese characters, this condition never reports it because it only treats punctuation or an ellipsis as the left-hand trigger. For example, app/type-magic/page.tsx currently contains 模板字面量类型 的, which renders the stray gap yet passes this new regression test. Include the Han-to-Han case so the test actually enforces the stated no-extra-spaces convention.
Useful? React with 👍 / 👎.
Summary
JSX trims each line of a text block and joins the lines with one space. The Chinese copy is wrapped across source lines throughout the course, so the Chinese pages rendered spaces between Chinese characters and around full-width punctuation, for example 「贴着标签: 「珍珠」 and 「这叫 推断」. DataData (renrenmimi/DataData#39) and AlgoAlgo (renrenmimi/AlgoAlgo#39) had the same defect and fixed it the same way.
The site's convention keeps one space between Chinese and Latin words, digits or inline code, and around 「——」 and operators. It keeps no space anywhere else. The changes follow that rule.
Changes
, : ; ? !before a Chinese character;{" "}between a full-width mark and Chinese text.test/zh-copy-spacing.test.tsis taken unchanged from AlgoAlgo. It scans every TSX file underapp/andlib/and fails on any new stray space. Onmasterit reports about 1,570 problems; on this branch it reports none.Verification
{" "}, every edited file equalsmasteronce whitespace is stripped.npx tsc --noEmit --incremental falsepasses, andnpm testpasses: 6 files, 38 tests.Note for the rest of this round
The other fix PRs of this audit round branch from this one, because they edit the same files. They can be merged in any order. Until this PR is merged, their diffs also show these whitespace changes.
🤖 Generated with Claude Code