Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Optional OpenAI flags, all in the `--openai.*` group: `api-key` / `OPENAI_API_KE
2. Take the charset from a byte order mark, the Content-Type header or a `<meta>` tag, in that order, and convert to UTF-8; a page that declares no known charset is kept as is (`toUtf8` in `extractor/text.go`)
3. Look up custom CSS selector rule from MongoDB by domain; a rule with non-blank `match_url` entries applies only to URLs containing one of them (`Rule.MatchesURL`)
4. If rule found → extract via goquery CSS selector, minus the elements matching its `excludes` selectors; if fails → fall back to general parser
5. If no rule → general parser: `codeberg.org/readeck/go-readability/v2` (a port of Mozilla Readability.js), with the page prepared first (`prepareForReadeck`: `aria-hidden` removed from paragraphs and iframes, since some sites hide the article that way until a script runs; a paragraph or div with no text that holds video, audio or an iframe becomes a figure, which readeck keeps) and every embed kept, not only known video sites. When readeck finds no article, or one with under 250 characters of text (a page that hides its article until a script shows it), the page is parsed again with hidden elements shown (`showHidden`) and the longer text wins; a page with no article gives empty content, not an error, and one on which readeck finds no text but which holds pictures, video or embeds gives its `<article>` (else `<body>`) without scripts as rich content (`mediaOnly`). On Substack posts the footnote references are replaced by placeholders while readeck parses and put back after, and the notes are taken out of the page and appended, with their pictures, to rich content under "Notes" (`extractor/footnotes.go`)
5. If no rule → general parser: `codeberg.org/readeck/go-readability/v2` (a port of Mozilla Readability.js), with the page prepared first (`prepareForReadeck`: `aria-hidden` removed from paragraphs and iframes, since some sites hide the article that way until a script runs; a paragraph or div with no text that holds video, audio or an iframe becomes a figure, which readeck keeps;) and every embed kept, not only known video sites. `keepPictures` then unwraps inline formatting around a link in a figure caption (readeck deletes a figure whose caption is mostly a link inside formatting), shows a hidden tab panel that holds a figure with a picture and some text, and replaces a button holding a picture with alt text which the page shows nowhere else (outside buttons, templates and hidden elements) with what it holds, since readeck deletes buttons; icons (svg, or declared under 64 px), tabs and buttons inside links stay with readeck; a picture in a closed dialog such as a lightbox counts as shown, since readeck keeps the dialog; pictures count as the same when their sources differ only by a `/cdn-cgi/image/` proxy, resize query parameters or a size suffix (`pictureKey`). When it changes the page, readeck also parses the page without it, and that result wins unless the other keeps every picture and every piece of text it has (`keepsPictures`, `keepsText`); `readeckArticle` also returns the text length of that plain parse, which decides the hidden-article pass below. When readeck finds no article, or one with under 250 characters of text (a page that hides its article until a script shows it), the page is parsed again with hidden elements shown (`showHidden`) and the longer text wins; a page with no article gives empty content, not an error, and one on which readeck finds no text but which holds pictures, video or embeds gives its `<article>` (else `<body>`) without scripts as rich content (`mediaOnly`). On Substack posts the footnote references are replaced by placeholders while readeck parses and put back after, and the notes are taken out of the page and appended, with their pictures, to rich content under "Notes" (`extractor/footnotes.go`)
6. Normalize relative links to absolute, extract images concurrently (pick largest as lead image)

## Key Conventions
Expand Down
Loading