Skip to content

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

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

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

Conversation

@renrenmimi

@renrenmimi renrenmimi commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

A defect found during the audit, outside its numbered findings.

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 after full-width punctuation. There were 1434 such spaces on the 15 Chinese pages, for example "算。 建议", "一章一个结构, 看见它" and "个、大小一致、 从 0 开始".

Changes

The site's convention keeps a space between Chinese and Latin letters, digits or expressions ("第 3 章", "O(1) 随机访问"), around "——" and around math operators, and nowhere else. The changes follow that rule.

  • 1910 line breaks joined. A script that walks the TypeScript syntax tree touches only JSX text and JSX attribute strings, never code snippets or comments. It joins a line break when it sits:

    • between Han characters;
    • after full-width punctuation or a Chinese ellipsis;
    • before full-width punctuation;
    • before "(" or a curly quote after Han;
    • after half-width , : ; ? ! before Han;
    • after the ")" of a Chinese parenthetical.

    Breaks next to Latin letters, digits, expressions, "——" or operators keep their space.

  • 37 spaces written after full-width punctuation removed. These are:

    • a leading space inside a bold label after a full stop (。<b> 暴力:</b>);
    • one {" "};
    • spaces after "……".

    The English branches need those spaces and are untouched; the rule only fires with Chinese on both sides.

  • 3 spaces around bold terms in the graph chapter, to match the rest of the course (只对<b>有向无环图</b>成立).

  • Whitespace only. Apart from that one {" "}, the diff changes nothing but whitespace: every edited file equals the original with whitespace stripped.

  • A regression test. test/unit/zh-copy-spacing.test.ts scans every TSX file with the same rules and fails on a new stray break or space. It fails on main.

  • CLAUDE.md states the rule under the language convention.

Result

The 15 Chinese pages, with every problem expanded, now show 7 such spaces. All 7 are intended:

  • around the formulas "地址 = 首地址" and "一维下标 = …";
  • around "父 ≤ 子" and the mapping arrows "值 → 下标" and "freq → 桶";
  • after a step label ("第一步 哈希计数");
  • in the atlas title.

Test plan

  • A rendered count on all 15 Chinese pages, outside code, with problems expanded: 1434 before, 7 after (the intended ones).
  • A whitespace-stripped comparison of every edited file against main: identical except one removed {" "}.
  • The rendered text of all 15 English pages (488,465 characters, problems expanded) is identical on main and on this branch.
  • test/unit/zh-copy-spacing.test.ts passes here and fails on main.
  • npm run typecheck, npm test (104 passed), npm run build, npx playwright test (55 passed).

🤖 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 lines all over the course, so it rendered with
spaces between Chinese characters and after full-width punctuation: 1434 of
them on the fifteen Chinese pages ("算。 建议", "一章一个结构, 看见它").

- 1910 line breaks inside JSX text are joined where the site's convention has
  no space: between Han characters, after full-width punctuation or a Chinese
  ellipsis, before full-width punctuation, before "(" or a curly quote after
  Han, after half-width , : ; ? ! before Han, and after the ")" of a Chinese
  parenthetical. Breaks next to Latin letters, digits, expressions such as
  O(1), "——" and math operators keep their space, as the convention asks
  ("第 3 章", "O(1) 随机访问").
- 37 spaces written after full-width punctuation are removed: a leading
  space inside a bold label after a full stop ("。<b> 暴力:</b>"), one
  {" "}, and spaces after "……". Three spaces around bold terms in the graph
  chapter are removed to match the rest of the course.
- Only whitespace changes, apart from the one {" "}: every edited file is
  identical to the original with whitespace stripped.

The fifteen Chinese pages now show 7 such spaces, all intended (around
formulas such as "地址 = 首地址", mapping arrows, a step label and the atlas
title). test/unit/zh-copy-spacing.test.ts scans every TSX file with the same
rules and fails on a new stray break or space; it fails on the previous
tree. CLAUDE.md states the rule under the language convention.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 00:03
@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
data-data Ready Ready Preview Oct 9, 2026 12:04am UTC

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

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-09T00:06:05.446816Z 032aa17 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.

@renrenmimi
renrenmimi merged commit 915ef7e into main Oct 9, 2026
3 checks passed
@renrenmimi
renrenmimi deleted the fix/zh-line-break-spaces branch October 9, 2026 00:06

This branch was successfully deployed

1 active deployment
Preview — 032aa174 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