Skip to content

Fix external links with anchors being rewritten as relative doc links#872

Open
mbeijen wants to merge 2 commits intomitmproxy:mainfrom
mbeijen:url-fragments
Open

Fix external links with anchors being rewritten as relative doc links#872
mbeijen wants to merge 2 commits intomitmproxy:mainfrom
mbeijen:url-fragments

Conversation

@mbeijen
Copy link

@mbeijen mbeijen commented Mar 10, 2026

Hi, I tried to setup documentation for a project where I had anchor tags in links in my README.md such as http://example.com/foobar#baz however the linkification module thought these were code references and it would not render properly. Here my naive bugfix, I hope it helps

mbeijen and others added 2 commits March 10, 2026 22:22
Protect <a href="https?://..."> links from linkify so identifiers in the
URL fragment (e.g. #django.http.HttpResponseNotFound) or in the link text
are not turned into relative documentation links. Mask such links with
placeholders before linkify, then restore them after.

Add test_external_link_with_anchor_preserved and testdata module to
verify README/included markdown links to external docs with anchors
remain intact.
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

Successfully merging this pull request may close these issues.

1 participant