Repository navigation
Description
html-to-markdown-rs 3.15.0 adds ConversionOptions::base_url, which resolves relative
href/src (including srcset, media source, graphic, lazy-load fallbacks) against a
caller-supplied base and honours a document <base href> the way a browser does. That is the
same job as the crawlberg-side pre-pass added for #63
(crates/crawlberg/src/html/link_targets.rs), so the two now overlap.
Adopting base_url and deleting the URL-joining half of link_targets.rs is the right end
state. It also answers #104: the pre-pass exists only because the converter could not do this,
and dropping it removes the second HTML parse #104 is about.
What must stay in link_targets.rs — h2m's base_url does not do either of these:
- the
data:payload removal (keeping inline image bytes out of the markdown), - the raw-text guard (leaving
<script>/<style>/<textarea>content untouched).
Two blockers, both of which make enabling base_url today a regression:
src=""as a sentinel. fix(markdown): keep inline image data out of the markdown #105 writes an emptysrc=""/srcset=""to mark an image whose
inline data payload was dropped.base_urlresolves an empty reference to the base, so a
dropped payload would become a link to the page itself. fix(markdown): leave raw text alone, decode the front matter base, and cover graphic data #123 fixes this by removing the
attribute instead of emptying it, sobase_urlis only safe once fix(markdown): leave raw text alone, decode the front matter base, and cover graphic data #123 has landed.- Fragment-only
href="#x". The feat(markdown): resolve relative links against the page's own address or its base URL #63 pre-pass deliberately leaves these as written.
Adoptingbase_urlchanges that output, so it is a behaviour change that needs its own
decision and test coverage, not a silent side effect of a dependency bump.
The dependency is declared as a caret range (html-to-markdown-rs = { version = "3.14" }), so
3.15 arrives on a routine cargo update with base_url left None and nothing failing. A
canary test (html_to_markdown_has_no_base_url_option in crates/crawlberg/src/markdown.rs)
now fails when that happens, so the bump cannot land without someone reading this issue.
Order of work: #123, then adopt base_url, decide the fragment question, delete the joining
half of the pre-pass, close #104.
Activity
test(markdown): fail if html-to-markdown-rs gains base_url
Goldziher commentedon Sep 26, 2026
One factual correction, since this issue is now the tracker for #104 (closed in its favour).
The canary this issue relies on does not exist:
html_to_markdown_has_no_base_url_optionis not incrates/crawlberg/src/markdown.rs, nor anywhere else in the repo.markdown.rshas amod testsat line 85 containing seven tests —converts_heading,converts_paragraph,converts_link,converts_full_page,empty_html_returns_some,drops_noscript_fallback_content_by_default,preserves_content_when_no_noscript_present— and the stringbase_urlappears nowhere in the file.git log -S'html_to_markdown_has_no_base_url_option'returns no commits, so it was never added and later removed; it was never written.That matters for this issue's closing sentence, "so the bump cannot land without someone reading this issue." Nothing currently enforces that. Combined with the fact that
Cargo.toml:83's"3.14"is a caret range that already admits 3.15.0, a routinecargo updatewill pick upbase_urlsilently, with it leftNoneand nothing failing — exactly the scenario the canary was meant to prevent.Worth adding the canary for real as the first step of this issue, before the dependency moves on its own.
Goldziher commentedon Sep 26, 2026
Correction to the note above: the canary does exist. It is
html_to_markdown_has_no_base_url_optionatcrates/crawlberg/src/markdown.rs:430on PR #82's branchfix/markdown-relative-links, added by743ab35d7("test(markdown): fail if html-to-markdown-rs gains base_url"), with a pointer comment atmarkdown.rs:44.The earlier note searched
main, where it is correctly absent — the canary lands when #82 merges. It was verified red-then-green before being committed: green on the pinned 3.14.3, and red aftercargo update -p html-to-markdown-rs --precise 3.15.0, failing with a message that names this issue.It asserts on the serialised option set rather than on
ConversionOptions::default().base_url, because that field does not exist on 3.14.3 and referencing it would be a compile error today rather than a failure when 3.15 arrives.So the enforcement #190 depends on is real, with one caveat worth keeping in view: it only fires once #82 lands. Until then a
cargo updatecould still pull 3.15.0 —Cargo.toml's"3.14"is a caret range that already admits it, and the current pin to 3.14.3 is the lockfile, not the requirement.fix(markdown): resolve relative links against the page URL (#82)
Goldziher commentedon Sep 26, 2026
Label set:
blockedis correct,duplicate-clusteris not — dropping it. This is gated, not redundant, and #104 already closed in its favour.The two notes above about the canary contradict each other and both are now stale. It is on
main:html_to_markdown_has_no_base_url_optionatcrates/crawlberg/src/markdown.rs:430, with the pointer comment at:44, since PR #82 merged. So the body's closing claim — the bump cannot land without someone reading this issue — holds today, and the first note's suggestion to "add the canary for real" is already done.The upstream half has moved, which sharpens the blockers. html-to-markdown 3.15.0 is released (tag
v3.15.0inxberg-io/html-to-markdown), soCargo.toml:84's"3.14"caret admits it now and the canary is the only thing standing between a routinecargo updateand a silently-Nonebase_url. Adoption additionally waits on xberg-io/html-to-markdown#510, which is open and sits under that repo's[Unreleased]: without itbase_urlresolves every destination except<blockquote cite>, which would force the joining half of the pre-pass to stay alive for that one attribute — so a 3.15.1 release is part of the blocker, not just 3.15.0. In-repo, blocker 1 still waits on #123 (open).tobocop2 commentedon Sep 26, 2026
One more case for the fragment decision here. With
<a href="#top">onhttps://example.com/dir/page, the links list reportshttps://example.com/dir/page#top, while the markdown keeps[top](#top). The links list joins every reference to the base (html/links.rs), and the markdown pre-pass leaves absolute and fragment-only references as written (html/link_targets.rs). This is the same on main, #98 and #122. Whatever this issue decides for fragment-only links when the rewrite moves tobase_urlshould settle which of the two outputs is right, so the two stop disagreeing.test(markdown): replace the base_url canary with tests of what that o…
test(markdown): replace the base_url canary with tests of the link pr…
fix(markdown): preserve document base URL (#190)
Goldziher commentedon Oct 5, 2026
The crawlberg-side link pre-pass is removed; Crawlberg now passes the document URL through html-to-markdown 3.17.1 base_url handling. Fixed by 2ed5261 and included in 1.10.0.