Skip to content

Remove the stray spaces that line breaks put into the Chinese copy - #9

Merged
renrenmimi merged 1 commit into
masterfrom
fix/zh-line-break-spaces
Oct 10, 2026
Merged

renrenmimi merged 1 commit into
masterfrom
fix/zh-line-break-spaces

Conversation

@renrenmimi

Copy link
Copy Markdown
Owner

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

  • 1,548 line breaks joined. A script walks the TypeScript syntax tree and touches only JSX text and JSX attribute strings, never code samples, template literals or comments. It joins a break that sits:
    • between Chinese characters;
    • after or before full-width punctuation;
    • before 「(」 or a curly quote after a Chinese character;
    • after half-width , : ; ? ! before a Chinese character;
    • after the 「)」 of a Chinese parenthetical.
  • 24 more spaces removed:
    • 20 after full-width punctuation;
    • 3 between Chinese text and a tag whose text is Chinese;
    • one {" "} between a full-width mark and Chinese text.
  • A regression test. test/zh-copy-spacing.test.ts is taken unchanged from AlgoAlgo. It scans every TSX file under app/ and lib/ and fails on any new stray space. On master it reports about 1,570 problems; on this branch it reports none.
  • CLAUDE.md states the rule under 文案风格.

Verification

  • Rendered text compared, file by file. For each of the 36 edited files, the text JSX renders was compared before and after. The only differences are 1,572 deleted spaces, each next to Chinese text; nothing else changes. The English copy is therefore identical.
  • Whitespace only. Apart from the one {" "}, every edited file equals master once whitespace is stripped.
  • Idempotent. A second run of the script changes nothing.
  • Checks. npx tsc --noEmit --incremental false passes, and npm test passes: 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

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>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 23:07
@vercel

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
tser Ready Ready Preview Oct 9, 2026 11:08pm UTC

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T23:09:40.500374Z 2148ad8 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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 !== "—";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@renrenmimi
renrenmimi merged commit 6d3f59c into master Oct 10, 2026
3 checks passed
@renrenmimi
renrenmimi deleted the fix/zh-line-break-spaces branch October 10, 2026 06:21

This branch was successfully deployed

1 active deployment
Preview — 2148ad84 Deployed Oct 9, 2026 by vercel[bot]
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.

2 participants