Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anchor validation and special characters. #3704

Closed
KITMohi opened this issue May 14, 2024 · 2 comments
Closed

Anchor validation and special characters. #3704

KITMohi opened this issue May 14, 2024 · 2 comments

Comments

@KITMohi
Copy link

KITMohi commented May 14, 2024

Hi and thank you for the great project!

I've noticed an unexpected behavior with the new anchor validation features where headers contain special characters, specifically "&".

Here is a reproducible sample with 1.6.0

mkdocs.yml:

site_name: Test Docs
validation:
  unrecognized_links: warn
  not_found: warn
  anchors: warn

docs/index.md

# Title

- [Title](#title)
  - [Sub-title](#sub-title)
  - [Conclusion & Future Work](#conclusion--future-work)

## Sub-title

## Conclusion & Future Work

And here's the error I get:

mkdocs serve --strict
INFO    -  Building documentation...
INFO    -  Cleaning site directory
WARNING -  edit_uri: 'edit/main/docs/index.md' is not a valid URL, it should include the http:// (scheme)
WARNING -  Doc file 'index.md' contains a link '#conclusion--future-work', but there is no such anchor on this page.

It's worth noting that it's a TOC generated by VSCode.

@pawamoy
Copy link
Sponsor Contributor

pawamoy commented May 14, 2024

Hello, thanks for the report :) Could you tell us what the actual anchor is when you serve your docs? VSCode probably doesn't slugify the same way as Python-Markdown does.

@pawamoy
Copy link
Sponsor Contributor

pawamoy commented May 18, 2024

Yep, here's the anchor I get when serving my docs with a Conclusion & Future Work heading: #conclusion-future-work. In short, the anchors generated by VSCode do not match the ones generated by MkDocs. So the anchor validation warning is right. I'd recommend always checking the anchors by serving your docs and looking at them in a browser. I'll close this but feel free to comment further!

@pawamoy pawamoy closed this as not planned Won't fix, can't repro, duplicate, stale May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants