yolowhtml is the HTML engine extracted from PageSift: a zero-copy arena HTML5 parser (yolowhtml-dom) plus a main-content and Markdown engine (yolowhtml), both pure Rust, both #![forbid(unsafe_code)], MIT licensed. Version 0.1.3, released this week, changes how it decides what the main content of a page is — from hand-written rules to a small statistical model. This post is about why, and what the numbers say.

The problem: rule-based extraction has a ceiling

Every extractor built on heuristics knows this loop. A page shape breaks the rules — the body is split across sibling containers, a "related stories" rail outweighs the article, a comment block scores like prose. You add a rule. The new rule fixes that page and quietly breaks two others. After enough rounds, the rule set is a sedimentary rock of exceptions, and accuracy stops moving no matter how much you tune.

Modern pages make it worse. Take one concrete case, a React-based news article:

  • The article text does not sit in the visible layout. It streams in later inside hidden <div hidden id="S:0"> chunks, meant to be swapped into <template id="B:0"> slots by React's streaming SSR. An extractor that reads the initial DOM sees placeholders.
  • Around the article sit repeated teaser cards and a related-stories rail — same headlines, same thumbnails, several times over. Repetition is exactly what density heuristics reward.
  • The real paragraphs are mid-length and interleaved with media, tables, and pull quotes — none of which look like a clean "main node".

Rules can be written for each of these. They were. The ceiling is that the combination keeps shifting.

What 0.1.3 does instead

A statistical block content model. Instead of asking "does this block match a rule", the new pipeline asks "how much does this block look like content", using 86 features computed from the DOM itself: composite text density, function-word density across languages (articles and particles are a strong prose signal), character-class Shannon entropy, and sibling-repetition structure (rails repeat; articles mostly don't). A Kadane maximum-subsequence pass proposes content segments, 125 depth-5 decision trees — 11.0 KiB total, fixed-point leaves, no ML runtime, no network — score the blocks, and a two-state Viterbi decoder modulated by DOM ancestry smooths the result so a lone "content-looking" ad between paragraphs does not flip the verdict. The decision threshold is chosen to optimize F1 on held-out data, not set by feel.

Measured on public extraction benchmarks, against the previous rule-based pipeline:

  • WCXB blind test: F1 0.8843 → 0.8992 (p = 0.0011)
  • WCXB full set, 1,842 pages: F1 0.8614 → 0.8823 (p = 0.0001)
  • WebMainBench, 545 pages, out-of-distribution: F1 0.8530 → 0.8677 (p = 0.0004)

Two things matter in those numbers. The p-values come from paired tests per page, so the gains are not a few lucky pages carrying the average. And the model is faster while doing it — per-page time geomean 0.876×–0.975× of the old pipeline across the three sets. Better and cheaper is the only kind of improvement worth shipping here.

Streaming SSR slot resolution. Before extraction, the parser now resolves React 18+ streaming slots at the arena level: hidden S:x chunks are matched to their B:x template slots, zero-copy, so the extractor sees the page the reader sees. The same pass suppresses post-decoding duplicate teaser blocks and repeated story-card rails on single-article pages, and rescues media, headings, tables, code, and formulas that sit inside genuine content regions.

Speed work. Tokenizing and tree construction use memchr; metadata and publication-date candidates are collected in a single DOM pass instead of several; inline Markdown rendering drops its intermediate String allocations. On the perf gate: a 100 KB blog page processes in a 2.39 ms median, a 250 KB wiki page in 9.01 ms. At that cost, extraction is never the bottleneck of an ingestion pipeline.

Two fixes from 0.1.2 that never got a post

This release line also closed two correctness bugs worth naming. Inputs past ~2 GiB could be silently misread — source positions were 31-bit, so text beyond the boundary decoded from the wrong place with no error. Input is now bounded at 1 GiB on a character boundary, and truncation is reported (Html::is_truncated(), an input_truncated coverage warning) instead of corrupting quietly. And thin app-shell pages containing <noscript> were parsed twice, the second pass producing byte-identical output; the fallback now measures the noscript content first and only re-parses when it could matter — 1.14 ms → 0.48 ms per page on a 410 KB shell.

Use it like this

use yolowhtml::{Options, process}; let opts = Options::default(); let output = process(html, &opts); // parse once; extract, date, metadata, Markdown println!("{}", output.markdown); 
[dependencies] yolowhtml = "0.1" # or yolowhtml-dom = "0.1" for just the parser + selectors 

Use yolowhtml when you feed real-world pages to an LLM or RAG pipeline at volume and extraction quality is a measured metric for you. If your pages are your own clean templates, a selector and a template will do — you do not need a statistical model to find content you placed yourself.