fix: align MyST heading slugs with docutils section IDs#550
Open
AlexanderLanin wants to merge 1 commit into
Open
fix: align MyST heading slugs with docutils section IDs#550AlexanderLanin wants to merge 1 commit into
AlexanderLanin wants to merge 1 commit into
Conversation
MyST's default slug function uses GitHub-style heading IDs that preserve
leading digits ("3.3 Toolchain Management" -> "33-toolchain-management"),
but Sphinx section IDs are generated by docutils' make_id which strips
them ("toolchain-management"). This mismatch causes spurious
myst.xref_missing warnings on valid [text](file.md#anchor) cross-
references whenever a heading starts with a numeric prefix.
Set myst_heading_slug_func to docutils.nodes.make_id so both sides
agree. Also enable myst_heading_anchors=4 so MyST can resolve heading
cross-references up to h4 depth.
Both settings use config_setdefault, so projects can still override them
in their own conf.py.
License Check Results🚀 The license check job ran with the Bazel command: bazel run --lockfile_mode=error //src:license-checkStatus: Click to expand output |
|
The created documentation from the pull request is available at: docu-html |
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.
Summary
myst_heading_slug_func = "docutils.nodes.make_id"as a bundle default so MyST's cross-reference resolver and docutils' section ID generator use the same algorithmmyst_heading_anchors = 4as a bundle default so[text](file.md#anchor)links resolve up to h4 depthconfig_setdefault, so projects can still override in their ownconf.pyProblem
MyST's default slug function uses GitHub-style heading IDs that preserve leading digits (
"3.3 Toolchain Management"→"33-toolchain-management"), but Sphinx section IDs are generated by docutils'make_idwhich strips them ("toolchain-management"). This causes spuriousmyst.xref_missingwarnings on valid[text](file.md#anchor)cross-references whenever a heading starts with a numeric prefix.The bug only surfaces when headings have leading numbers (e.g. numbered chapters), which is why most projects never notice.
Test plan
[text](file.md#anchor)cross-references — verify nomyst.xref_missingwarnings