Faithful output
This release is about a promise: what comes out of cull renders exactly like what went in.
-p / --pretty is now rendering-faithful
Pretty-printers for HTML have a subtle bug class: line breaks are whitespace, so adding or removing them between inline elements changes what a browser renders.
- htmlq's
--prettydeletes the significant space in<b>a</b> <i>b</i>→ renders "ab" instead of "a b" (mgdm/htmlq#58) - pup's always-indented output adds whitespace:
<b>a</b><i>b</i>x("abx") is split across lines → renders "a b x"
(Both verified against pup 0.4.0 and htmlq 0.4.0 while preparing this release.)
cull's -p now keeps inline content together in "runs" and only breaks lines at block boundaries, where extra whitespace can never change rendering:
$ echo '<p><b>bold</b><i>ital</i>x</p>' | cull -p 'p'
<p><b>bold</b><i>ital</i>x</p>
$ echo '<div>intro <b>x</b><p>para</p>tail</div>' | cull -p 'div'
<div>
intro <b>x</b>
<p>para</p>
tail
</div>Render-nothing elements (<link>, <meta>, <script>, comments) join runs too — Wikipedia emits <link> tags mid-sentence, and breaking around them used to inject a space before the following comma. <head>-style metadata stacks still get one tag per line.
Verification: pretty-printing the lobste.rs front page and a 1.1 MB Wikipedia article, then diffing cull body -t output before vs. after — byte-identical rendered text on both.
Whole-document output keeps the DOCTYPE
curl page | cull (no selector) now emits <!DOCTYPE html> and top-level comments. pup and htmlq both silently strip the DOCTYPE (mgdm/htmlq#56), which quirks-modes any page you round-trip through them.
cull <URL> with no selector
A URL can never be a valid CSS selector, so cull https://example.com now means "fetch and emit the whole document" in every mode (previously it errored unless --md/--table/-I was given).
189 tests (+7 playground) · fuzz smoke re-run clean · full changelog
Install: brew install rashida-thorne/cull/cull · cargo binstall cull · scoop bucket add cull https://github.com/rashida-thorne/scoop-cull && scoop install cull · nix run github:rashida-thorne/cull · more options