-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Anchor validation false positives after upgrading to 1.6 #3690
Description
First of all, thanks for the very useful new anchor validation feature! Upgrading to MkDocs 1.6, I was able to fix many stale anchors in our documentation. However, in the process, I came across a few false positives – the anchors are correct, but MkDocs reports them nonetheless. This is particularly the case when using the Tabbed extension with combine_header_slug, which allows to prepend the slug of the nearest header to the tab.
I believe this needs to be fixed in MkDocs, since it might be some kind of ordering issue when running anchor validation, but I'm tagging @facelessuser here for visibility. By using the Tabbed extension, anchor links to tabs are much more readable, something that many users asked for on the Material for MkDocs issue tracker.
Example
The following example is used for illustration. You can also download it here: anchor-validation-bug.zip
index.md
# Page with tabs
## Headline
=== "Tab A"
Anchor for this tab is `#headline-tab-a`
=== "Tab B"
Anchor for this tab is `#headline-tab-b`foo.md
# Links to tabs
- [Tab A](index.md#headline-tab-a)
- [Tab B](index.md#headline-tab-b)MkDocs will not detect those links and report them as non-existent:
INFO - Cleaning site directory
INFO - Doc file 'foo.md' contains a link 'index.md#headline-tab-a', but the doc 'index.md' does not contain an anchor '#headline-tab-a'.
INFO - Doc file 'foo.md' contains a link 'index.md#headline-tab-b', but the doc 'index.md' does not contain an anchor '#headline-tab-b'.
INFO - Documentation built in 0.12 seconds
When running the example, it's easy to see that anchor are correct and work as expected.