Repository navigation
fix(html): preserve mailto: and tel: links (#2644) - #2648
İlker Oğulcan SAYIN (iosayin) wants to merge 1 commit into
Conversation
PRABHU KIRAN VANDRANKI (VANDRANKI)
left a comment
There was a problem hiding this comment.
Community review, so it does not clear the merge gate. I checked out the branch and ran it.
What I ran (packages/markitdown, Python 3.13 venv, upstream main 4cc9fa1 as base):
tests/test_html.pyandtests/test_docx.pyon this branch: 135 passed, 1 skipped.- A small probe converting
<a href="...">link</a>throughMarkItDown().convert_stream(..., ".html")on main and on this branch.
The basic case works: mailto:team@example.com and tel:+1-555-0100 now come out as [link](...) where main drops them to bare text. javascript: and sms: still collapse to text.
The problem is the if scheme in ["mailto", "tel"]: pass branch. It skips the path escaping completely, and the escaping is what keeps the output a valid Markdown link. From the probe:
tel:+1 555 0100becomes[link](tel:+1 555 0100)mailto:a b@example.combecomes[link](mailto:a b@example.com)
I rendered both with markdown-it and they come out as literal text, not links. A phone number written with spaces is a plausible href. For comparison #2645 escapes the path and gives tel:+1%20555%200100, which renders as a link (the PR also adds a test for the Word hyperlink path).
Smaller notes:
MAILTO:keeps its case on this branch ([link](MAILTO:team@example.com)), while #2645 normalizes it tomailto:. Harmless.- The new test only covers two clean addresses, so it would not catch the space case. A parametrized case with a space in a
tel:href would. - A raw space in the query (
?subject=Weekly report) also stays raw, as it does on #2645 and for http today.
Overlap: #2645 fixes the same thing. Suggest the maintainers pick one. I will leave a note there too.
I did not test other converters that use _CustomMarkdownify.
Resolves #2644
Summary of Changes
mailtoandtelto allowed schemes in_CustomMarkdownify.convert_a.mailto:andtel:link markdown conversions.