Skip to content

fix: strip MyST roles in headingmap CLI - #54

Merged
mmcky merged 2 commits into
mainfrom
fix/headingmap-strip-myst-roles
Mar 26, 2026
Merged

fix: strip MyST roles in headingmap CLI#54
mmcky merged 2 commits into
mainfrom
fix/headingmap-strip-myst-roles

Conversation

@mmcky

@mmcky mmcky commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

The headingmap CLI's cleanHeading() only removed ## markers but did not strip MyST inline roles like {index}`Mutable <single: Mutable>`. This caused raw role syntax to appear in heading-map keys and values when running npx translate headingmap.

Root cause: The CLI had its own cleanHeading() that didn't call MystParser.stripMystRoles(), unlike the sync pipeline's updateHeadingMap() in heading-map.ts (fixed in v0.12.5).

Fix: Apply MystParser.stripMystRoles() in the CLI's cleanHeading().

Before:

Name Resolution::{index}`Mutable <single: Mutable>` Versus {index}`Immutable <single: Immutable>` Parameters

After:

Name Resolution::Mutable Versus Immutable Parameters

Adds 1 test (966 → 967 total). Once merged + released, the zh-cn and fa migration PRs should be re-run.

The headingmap CLI's cleanHeading() only removed ## markers but did
not strip MyST inline roles like {index}`Mutable <single: Mutable>`.
This caused raw role syntax to appear in heading-map keys and values.

Apply MystParser.stripMystRoles() in cleanHeading() to match the
behavior of the sync pipeline's updateHeadingMap().

Adds 1 test (966 → 967 total).
Copilot AI review requested due to automatic review settings March 26, 2026 00:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Aligns the headingmap CLI’s heading normalization with the main sync pipeline by stripping MyST inline role syntax, preventing raw role markup from polluting generated heading-map keys/values.

Changes:

  • Update cleanHeading() in the headingmap CLI to call MystParser.stripMystRoles().
  • Add a unit test verifying role stripping for both heading-map keys and values.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/cli/commands/headingmap.ts Strips MyST inline roles when cleaning headings for heading-map generation.
src/cli/tests/headingmap.test.ts Adds coverage ensuring role syntax is removed from generated heading-map keys/values.

Comment thread src/cli/commands/headingmap.ts
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