Skip to content

Extract web pages with Defuddle, offline, keeping Readability as a fallback - #69

Merged
callumalpass merged 1 commit into
mainfrom
feat/defuddle-extractor
Oct 11, 2026
Merged

callumalpass merged 1 commit into
mainfrom
feat/defuddle-extractor

Conversation

@callumalpass

@callumalpass callumalpass commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Web captures in Reader and the extension now use Defuddle (pinned 0.19.5, browser core) instead of Readability. It is loaded only when saving, as Readability was.

What changes

  • No network during extraction. Defuddle can fetch missing content from third-party APIs (e.g. FxTwitter); async fallbacks are off and its fetch throws. A test fails on any fetch or XHR. Extraction depends only on the captured HTML.
  • Conservative settings. On a 39-page comparison, Defuddle's defaults truncated a Wikipedia article and dropped Rust Book code figures, arXiv table figures and hidden sidenotes. Standardisation, content patterns, partial selectors and hidden/small-element removal are therefore off. With these settings no real body text was lost on any page.
  • Readability fallback. If Defuddle's output is suspiciously short against the page text, Readability runs, and is used only when it finds substantially more. It did not trigger on the 39 pages. Provenance records the extractor that ran (defuddle@0.19.5 or mozilla-readability@0.6.0), and existing reading copies are never re-extracted, so their highlights keep their anchors.
  • Metadata: publisher and scholarly tags still take precedence; Defuddle's title, author, date and site fill gaps where Readability's did.
  • X pages go to the social-post adapter from Save social posts one at a time from X, Bluesky and Mastodon #68, so the offline test expects an X shell to be refused there, still without a network request.

Comparison (same captured HTML, real Chromium; words of extracted body)

Category Pages Readability Defuddle
News 2 2,485 2,721
Blogs 9 51,537 51,872
Substack 1 1,924 1,957
Documentation 8 31,839 34,821
Wikipedia 4 53,264 73,783
Academic HTML 5 77,085 77,101
Code/math 4 13,525 14,715
Long-form 5 168,596 170,863

Defuddle keeps math as MathML (Wikipedia, arXiv) where Readability drops it, which accounts for much of the Wikipedia difference; it also keeps code blocks with captions and arXiv tables, and strips site suffixes from titles. Bylines still differ on some academic pages, which is why publisher metadata stays authoritative. Three small structural fixtures (original prose) are committed as regression tests.

Cost

The lazy Defuddle chunk is about 310 KB (86 KB gzip), fetched only on save; the extension panel does not load it on open. The Readability chunk (34 KB, 11 KB gzip) remains for the fallback.

Verification

pnpm check passes; extension and Reader build. Fixture rendering and quote re-anchoring were checked in Chromium, and the built MV3 extension extracted offline. A connected LAB round trip has not run: LAB's daemon currently reports incompatible_version.

Base automatically changed from feat/social-feed-posts to main October 11, 2026 09:30
… evidence

Replace Readability with the pinned Defuddle 0.19.5 browser core for
article extraction in Reader and the extension, lazily loaded on save.

- Extraction is offline: async fallbacks are off and Defuddle's fetch is
  replaced with one that throws. A test fails on any fetch or XHR.
- Defuddle's default cleanup lost real text on a 39-page comparison
  (a truncated Wikipedia article, Rust Book code figures, arXiv table
  figures, hidden sidenotes), so standardisation, content patterns,
  partial selectors and hidden/small-element removal are disabled.
- Readability stays as a lazy fallback when Defuddle's output is
  suspiciously short; provenance records whichever extractor ran.
  Existing reading copies are never re-extracted.
- Publisher and scholarly metadata still take precedence.
- X pages belong to the social-post adapter, so the offline test expects
  an X shell to be refused there, still without a network request.
@callumalpass
callumalpass force-pushed the feat/defuddle-extractor branch from df91538 to 61457d3 Compare October 11, 2026 09:30
@callumalpass
callumalpass merged commit 74f4adb into main Oct 11, 2026
2 checks passed
@callumalpass
callumalpass deleted the feat/defuddle-extractor branch October 11, 2026 09:34
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.

1 participant