Skip to content

Pin fetch output with golden tests and upgrade htmd and readabilityrs - #6

Merged
sharmis-tp merged 4 commits into
cppalliance:masterfrom
sharmis-tp:golden-tests
Nov 26, 2026
Merged

sharmis-tp merged 4 commits into
cppalliance:masterfrom
sharmis-tp:golden-tests

Conversation

@sharmis-tp

@sharmis-tp sharmis-tp commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Step 1 of the WebFetch report: pin today's output, then upgrade the crates.

Golden tests (src/fetch/tests-golden.rs, fixtures in tests/golden/) compare the whole text of a fetch, header included: an article with links, an image, headings, two code blocks, nested lists, a table, and a blockquote, on the readability path and with raw; a page too short for an article, on the fallback; and the url: line after a redirect. GOLDEN_BLESS=1 rewrites the texts, so a later change to the rendering is reviewed as a diff of tests/golden/.

Then htmd 0.5.5 -> 0.5.6 and readabilityrs 0.1.3 -> 0.1.4. The lockfile drops 8 crates (kuchikikiki, indexmap, hashbrown, crc, crc-catalog, equivalent, thiserror 1, thiserror-impl 1). The only change in the goldens is the fix of htmd#138, on the raw path:

-sudo apt updatesudo apt install curl
+sudo apt update
+sudo apt install curl

It shows only with the markup Hugo's Chroma writes (each line in spans that end with the newline), so the fixture uses that.

What the report expected and the goldens show otherwise:

  • readabilityrs 0.1.4 renders a page nested 1,000 levels deep, but htmd 0.5.6 and 0.6.1 recurse once per level and overflow the stack between 500 and 1,000 levels, which aborts the process. The upgrade does not fix this, so the test for it comes with a separate fix.
  • The readability path still drops the page's h1, and the envelope has no title line (G7). The raw path still prints the <title> text as its first line.
  • readabilityrs 0.1.5, which carries Match void elements without a closing tag to avoid quadratic time theiskaa/readabilityrs#27 (an 8 MiB page from 117 s to 6.6 s), is not published yet. It is a one-line bump once it is.

Also tested: a table with 5,000-character cells stays under four times its input size on both paths.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 746c42d0-6168-4b8b-a362-cf8a186144b0
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@vinniefalco

Copy link
Copy Markdown
Member

The golden tests are worth keeping. I’d like to fix three things in the URL rewrite before merging.

  1. Bound the work before calling Url::join. The length check runs after join has already copied the base path. With a long <base href>, we can repeat that work for every relative link, even when all the resulting URLs are discarded. This affects raw too. Can we cap the effective base before walking the links?
  2. Resolve the image URL Readability actually uses. We rewrite img[src], but Readability can later replace it with a relative URL from data-src or srcset. Let’s resolve the selected URL and cover it with an article fixture.
  3. Resolve fragment links when <base href> changes the document. On /guide/ with <base href="/manual/">, #section means /manual/#section. Keep the bare fragment when it points to the fetched document and make it absolute when it points elsewhere.

… image and fragment links readability and base point to
@sharmis-tp

Copy link
Copy Markdown
Collaborator Author

Done in the new commit.

  1. A base over 2,000 characters, the longest URL a fetch takes, now leaves every link as written, so a join never copies more than that. Every join also spends from the budget, including ones thrown away as too long, and the walk stops when the budget runs out. On a 7 MiB page with a 1,998-character base and only links that resolve too long, the thrown-away joins went from about 145 ms to under 1 ms.
  2. Readability now gets the original page, and links resolve on the article it returns, after standardize_all has picked the image source (data-src, or the largest srcset or data-srcset entry). This calls readabilityrs's own public standardize_all and html_to_markdown, the same steps output_markdown runs, so nothing else in the goldens changed. The golden article now has a lazy-loaded image and a srcset image. The raw path still shows the src as written, because htmd only reads src.
  3. A bare fragment stays bare when the base is the fetched page, query included, and resolves against the base when a points elsewhere: /guide/ with gives /manual/#section.

Each of the four new tests fails on the previous commit.

Since this PR includes #5's commits and the review is here, I'll close #5 in favor of this one, unless you prefer otherwise.

@vinniefalco

Copy link
Copy Markdown
Member

I think this should be merged, and we need an issue opened for the RV tool render()

@sharmis-tp
sharmis-tp merged commit 4b300a0 into cppalliance:master Nov 26, 2026
10 checks passed
@sharmis-tp
sharmis-tp deleted the golden-tests branch November 26, 2026 02:29
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.

2 participants