馃悰 Use the target's title for [](doc.md#label) links - #1207
Open
dstrodtman wants to merge 1 commit into
Open
dstrodtman wants to merge 1 commit into
dstrodtman wants to merge 1 commit into
Conversation
A path link with empty text to an explicit target in another document, such as `[](other.md#my-label)` where `other.md` has `(my-label)=` above a heading, resolved to the right anchor but rendered no link text. Since executablebooks#1158 the link no longer warns, so the build passed with an invisible link. `resolve_myst_ref_doc` set the implicit text only on the heading-slug path. The section-id and std-label paths now carry the section title too. When no title exists, as for an anonymous label on a paragraph, the link shows the target id instead of rendering empty, matching the fallback for unresolved `[](#target)` links. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
@chrisjsewell PR here is coded by Claude but reviewed by a human. This behavior allows Sphinx MyST to read closer to standard markdown while auto-parsing section/page headers. Motivation is maintainability and making sure raw .md files are friendly to agents. Please let me know what else I can do to push this forward. Currently in process of converting all OSS Ray docs to MyST, and this would keep me from rigging up my own custom solution there. |
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.
A path link with empty text to an explicit target in another document resolves to the right anchor but renders no link text:
On
masterthis renders<a href="other.html#my-label"><span class="std std-ref"></span></a>. Since #1158, which fixed the false-positivemyst.xref_missingwarning reported in #1151, the link no longer warns, so a build with-Wpasses with an invisible link. On v5.1.0 the same link warned, so the empty text was visible as a failing build rather than silent.Cause
resolve_myst_ref_docsetsimplicit_textonly when the fragment matches a heading slug. The two later branches added in #1158, a section's docutils id and a std-domain label referenced by id or name, settargetidbut leaveimplicit_textempty.Fix
myst_slugs._std_label_id_in_docbecomes_std_label_in_docand returns the label's section title with its id. Named labels carry a title. Anonymous labels don't.[](#target)links inMystReferenceResolver.run.Explicit link text is unchanged.
master[](other.md#my-label), label on a headingLabelled heading[](other.md#colon:label), label by nameColon heading[](other.md#colon-label), label by idColon heading[](other.md#para-label), anonymous labelpara-label[custom](other.md#my-label)customcustomTests
test_doc_with_target_link_textcovers the rows above across two documents withmyst_heading_anchorson. Four of its five cases fail onmaster. The explicit-text case passes on both, as a guard.doc_with_target_idanddoc_with_target_namefixtures recorded the empty<inline>. They're regenerated and now containTitle.masterin the same environment:test_cmdline[40-linkify],test_extended_syntaxes, andtest_extended_syntaxes_text.pre-commit run(ruff, ruff-format, mypy) passes on the changed files.I didn't add a
CHANGELOG.mdentry because there's no unreleased section since v5.1.0. Happy to add one if you'd like.Found while evaluating path links with hand-assigned anchors,
[](/page.md#label), as a cross-reference convention for a large Sphinx project mixing MyST and rST.馃 Generated with Claude Code