fix: register anchor collector at priority -1 to catch extension-generated anchors - #4161
Open
Mubashir78 wants to merge 1 commit into
Open
Mubashir78 wants to merge 1 commit into
Mubashir78 wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Fix #3690
Problem
The
_ExtractAnchorsTreeprocessoris registered at priority 5, but PyMdown Tabbed'sTabbedTreeprocessorruns at priority 4. Since Python-Markdown's Registry sorts by priority descending, priority 5 runs before priority 4, causing the anchor collector to miss slugified tab IDs generated by the Tabbed extension.When Tabbed is configured with a
slugifyfunction, readable IDs likemy-tab-titleorheadline-tab-a(withcombine_header_slug) are added to<input>elements during the treeprocessor phase -- after the anchor collector has already scanned the tree.Any link like
[see instructions](page.md#my-tab-title)then produces a false-positive anchor validation warning, even though the anchor exists in the final HTML.Fix
Changed the registration priority of
_ExtractAnchorsTreeprocessorfrom 5 to -1, ensuring it runs after all other treeprocessors (includingTabbedTreeprocessorat priority 4 and_RelativePathTreeprocessorat priority 0) so it captures all dynamically generated anchors.Verification
test_anchor_no_warning,test_anchor_warning, etc.)pymdownx.tabbedconfirmstab-a,tab-b, andheadline-tab-a/headline-tab-b(withcombine_header_slug) are all correctly collected