Skip to content

Read Reddit and Hacker News threads with site handlers - #123

Merged
paskal merged 2 commits into
masterfrom
site-handlers
Dec 5, 2026
Merged

paskal merged 2 commits into
masterfrom
site-handlers

Conversation

@paskal

@paskal paskal commented Dec 5, 2026

Copy link
Copy Markdown
Member

Previously, a Hacker News thread came out as the page's own layout: hundreds of nested tables, one per comment, with a spacer picture for each indent and no author or date line. A Kindle book made from it was delivered in fixed layout. Reddit had its own conversion wired into the extraction path, and how a page was fetched (which address, which retriever, whether to retry through Cloudflare) was decided in several places.

After this change:

  • Pages that need code of their own go through a small site interface (extractor/site.go) with a fixed list, reddit and hackerNews.
  • A Hacker News item page becomes an article: the item with its points, author, date, link and text, then the comments in the page's ranked order with replies nested. Polls keep their options' points, a comment's or a poll option's own page links its story or poll, and flagged, dead or deleted comments keep only their replies. The handler reads the item page, not the Algolia API, because only the page gives the ranked order.
  • On both sites, replies nest at most eight quotes deep; a deeper reply follows the one it answers at that depth, so a long chain keeps the width of a page.
  • The fetch address, the retriever and the Cloudflare fallback are decided together in plan, with a table test of routing and precedence.
  • POST /api/extract-html reads a Reddit or Hacker News page the client sends with the site's code, as it reads a fetched one.
  • A rule with a content selector still reads a site's page itself. When its selector finds nothing, the site's code reads the page instead of the general parser.
  • The response carries parser, naming what read the article: site:<name>, rule, readeck, readeck-hidden or media-only. It is omitted when empty. A site handler that cannot read a page logs a warning and leaves the page to the general parser.
  • POST /api/content-parsed-wrong refuses pages of hosts a site handler owns, listings included, since a selector rule there would replace the handler on every post.
  • CLAUDE.md is now AGENTS.md, with a table of where a site-specific fix belongs.

Verified:

  • The Reddit article for the existing fixture is byte-identical to the one master produces.
  • A live Hacker News thread of 341 comments extracts with no tables and no pictures, nested up to the limit. Polls, a poll option's page, a comment's page and a thread with flagged comments were checked against their live pages.
  • Golden-file tests compare the whole article each handler makes from its test page.
  • Each new test was run with its change reverted and failed. Lint, race tests and the Docker image build pass.

A Hacker News thread came out as hundreds of nested layout tables with a
spacer picture per comment, and a Kindle book made from it arrived in
fixed layout. Pages that need code of their own now go through a small
site interface: Reddit uses it, and a Hacker News item page becomes an
article with the story's points, author, date and link, then the
comments in the order the page ranks them, replies nested in quotes at
most eight deep. Polls, a comment's or a poll option's own page, and
flagged or deleted comments are handled.

How a page is fetched (address, retriever, Cloudflare fallback) is now
decided once, in plan. A rule with a selector still reads a site's page
itself, and the site's code takes over when the selector finds nothing.
The response carries parser, naming what read the article, and a site
handler that cannot read a page logs a warning. Rule suggestions are
refused for hosts a handler owns. Each site's test page has its expected
article in a golden file.
The guide for coding agents is now AGENTS.md. It gains a table of where
a site-specific fix belongs: a rule, a rule flag, a site handler, a
readeck preparation pass, or ukeeper-worker.
@paskal
paskal requested a balanced review from Copilot December 5, 2026 19:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@paskal
paskal merged commit b256bef into master Dec 5, 2026
2 checks passed
@paskal
paskal deleted the site-handlers branch December 5, 2026 19:38
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