Render fragment-only hyperlinks as plain text instead of dead links - #2265
Open
abhays02 wants to merge 1 commit into
Open
Render fragment-only hyperlinks as plain text instead of dead links#2265abhays02 wants to merge 1 commit into
abhays02 wants to merge 1 commit into
Conversation
Author
|
@microsoft-github-policy-service agree |
abhays02
marked this pull request as ready for review
August 2, 2026 07:45
Internal anchors like Word TOC/cross-reference bookmarks (#_Toc12345) never resolve in the Markdown output, since heading ids are not preserved anywhere in the conversion pipeline. Fixes microsoft#2125.
abhays02
force-pushed
the
fix/2125-docx-toc-anchors
branch
from
August 2, 2026 07:55
4467de9 to
709982f
Compare
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.
Internal DOCX hyperlinks such as TOC entries and cross-references are converted to Word bookmark anchors like
[Executive Summary](#_Toc12345). These anchors never resolve in the Markdown output: nothing in the conversion pipeline preserves headingids (see_CustomMarkdownify.convert_hn), so a fragment-only href can never point at anything, no matter which converter produced the source HTML (DOCX, PPTX, or raw HTML). The result is a block of dead links.This changes
_CustomMarkdownify.convert_ain_markdownify.pyto detect hrefs that are fragment-only (no scheme, no netloc, no path — just#...) and render the link text plain instead of wrapping it in a non-functional Markdown link. Hrefs with a path plus a fragment (e.g.page.html#section) are unaffected.Fixes #2125.
Verified with a regression test (
test_fragment_only_links_render_as_plain_textintests/test_module_misc.py) that:[Executive Summary](#_Toc12345)present in output)Full existing test suite: 335 passed, 4 skipped, 2 failed. Both failures (
test_markitdown_remote,test_speech_transcription) are pre-existing and unrelated — they fail identically with this change reverted, due to network access to arxiv.org and a speech-recognition API being blocked in the sandbox this was verified in.