Skip to content

fix: CJK–MyST spacing rule and target-label blank-line cleanup#49

Merged
mmcky merged 1 commit intomainfrom
fix/myst-target-spacing-rules
Mar 25, 2026
Merged

fix: CJK–MyST spacing rule and target-label blank-line cleanup#49
mmcky merged 1 commit intomainfrom
fix/myst-target-spacing-rules

Conversation

@mmcky
Copy link
Copy Markdown
Contributor

@mmcky mmcky commented Mar 25, 2026

Address feedback from lecture-python-programming.zh-cn PR #6 (HumphreyYang).

Changes

1. CJK–MyST spacing rule (zh-cn language config)

New additionalRules entry 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 render
After: 请参阅 {doc} — renders correctly

2. MyST target-label blank-line cleanup (file-processor)

reconstructFromComponents now 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:

(paf_generators)=

## 生成器

After:

(paf_generators)=
## 生成器

Files Changed

File Change
src/language-config.ts Add spacing rule to zh-cn config
src/file-processor.ts Post-process to strip blank lines between targets and headings
src/__tests__/language-config.test.ts Update to expect 2 rules
src/__tests__/component-reconstruction.test.ts New test for target-label cleanup
CHANGELOG.md Add unreleased entries
.github/copilot-instructions.md Update test count 934 → 935

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)
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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).

@mmcky mmcky merged commit a8d66c5 into main Mar 25, 2026
4 checks passed
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