🐛 Keep link titles through cross-reference resolution - #1196
Open
dylanpulver wants to merge 1 commit into
Open
Conversation
A CommonMark link title, [text](#target "title"), was dropped whenever the reference was rebuilt: the transform that turns a local anchor into a pending_xref copied ids/names/dupnames but not reftitle, and _process_wrap_node copied "title" instead of aliasing it to "reftitle".
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.
[text](#target "title")renders as a tooltip in CommonMark, and the docs say so (docs/syntax/cross-referencing.md: "in HTML titles are rendered as tooltips"). Most links lose it.Checked against markdown-it-py's own
RendererHTMLover the same markdown, one Sphinx build:[a](#index "T")doc root[b](#explicit-target "T")[c](#some-section "T")[d](other.md "T")[e](other.md#anchor "T")[f](https://example.com "T")[g](#nope "T")unresolvedThe reference renderer keeps all 7; MyST kept 2. Two places drop it:
transforms.pyrebuilds the reference as apending_xrefand copiesids,names,dupnames— notreftitle._process_wrap_nodecopiestitlerather than aliasing it toreftitle, which is what every othercopy_attributescall does.Resolution then builds a fresh node, so the carry-over in
myst_refs.pyis needed too — but alone it fixes nothing: the title is already gone by then. With only that one-line change it is still 2 of 7, though it looks like the whole fix.1247 passed, 12 skipped. The 3 failures (test_cmdline[40-linkify],test_extended_syntaxes,test_extended_syntaxes_text) are identical on unpatched master in the same session. ruff 0.15.20 and ruff-format clean.Drafted with Claude Opus 5 (
claude-opus-5); I ran and checked every number above.