fix: CJK–MyST spacing rule and target-label blank-line cleanup#49
Merged
Conversation
Address feedback from PR #6 on lecture-python-programming.zh-cn: 1. Add zh-cn language-config rule: always insert a space between Chinese characters and inline MyST directives ({doc}, {ref}, etc.) or Markdown links. Prevents rendering failures like "请参阅{doc}" where the directive isn't recognized. 2. Strip blank lines between MyST target labels ((label)=) and headings in reconstructFromComponents post-processing. The section separator logic was inserting blank lines that break MyST target-to-heading attachment. - Update language-config test to expect 2 rules for zh-cn - Add component-reconstruction test for target-label cleanup - Update CHANGELOG and test count (934 → 935)
There was a problem hiding this comment.
Pull request overview
This PR updates the translation prompt rules and reconstruction output to prevent MyST rendering issues in zh-cn translations, based on feedback from a downstream translation PR.
Changes:
- Add a zh-cn prompt rule requiring spacing between Chinese text and inline MyST directives / Markdown links.
- Post-process reconstructed documents to remove blank lines between MyST target labels
(label)=and the immediately following heading. - Update/add unit tests and document the changes in the changelog/instructions.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/language-config.ts |
Adds a zh-cn-specific additional rule for CJK↔MyST/link spacing to improve rendering correctness. |
src/file-processor.ts |
Adds post-processing to ensure MyST target labels attach to headings (removes intervening blank line). |
src/__tests__/language-config.test.ts |
Updates expectations for the added zh-cn rule. |
src/__tests__/component-reconstruction.test.ts |
Adds regression coverage for target-label/heading blank-line removal. |
CHANGELOG.md |
Records the new rule, reconstruction fix, and test count update under Unreleased. |
.github/copilot-instructions.md |
Updates the documented total test count (934 → 935). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Address feedback from lecture-python-programming.zh-cn PR #6 (HumphreyYang).
Changes
1. CJK–MyST spacing rule (zh-cn language config)
New
additionalRulesentry instructs Claude to always insert a space between Chinese characters and inline MyST directives ({doc},{ref},{any},{term}, etc.) or Markdown links ([text](url)).Before:
请参阅{doc}— directive may not renderAfter:
请参阅 {doc}— renders correctly2. MyST target-label blank-line cleanup (file-processor)
reconstructFromComponentsnow post-processes the joined document to strip blank lines between MyST target labels ((label)=) and headings. The section separator logic was inserting blank lines that break MyST target-to-heading attachment.Before:
After:
Files Changed
src/language-config.tssrc/file-processor.tssrc/__tests__/language-config.test.tssrc/__tests__/component-reconstruction.test.tsCHANGELOG.md.github/copilot-instructions.md