Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/extensions/score_sphinx_bundle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ def setup(app: Sphinx) -> dict[str, object]:
for e in score_extensions:
app.setup_extension(e)

# Enable cross-reference resolution for [text](file.md#anchor) links up to h4.
# Without this, MyST treats heading anchors as opaque and cannot resolve them.
config_setdefault(app.config, "myst_heading_anchors", 4)

# MyST's default slug function uses GitHub-style heading IDs that keep leading
# digits ("3.3 Toolchain Management" -> "33-toolchain-management"), but docutils'
# make_id strips them ("toolchain-management"). Since Sphinx section IDs are
# generated by docutils, the two algorithms disagree whenever a heading starts
# with a numeric prefix, causing myst.xref_missing warnings on valid cross-
# references. Aligning MyST's slug function on make_id fixes the mismatch.
config_setdefault(app.config, "myst_heading_slug_func", "docutils.nodes.make_id")

# enable "..."-syntax in markdown — must come after myst_parser is loaded above
if isinstance(app.config.myst_enable_extensions, list):
app.config.myst_enable_extensions.append("colon_fence")
Expand Down
Loading