feat: Add substack.com custom parser#177
Open
jocmp wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a custom mercury-parser extractor for
substack.com(and any*.substack.comsubdomain via the base-domain match inget-extractor.js).Selectors target the canonical Substack web post structure:
og:andname="author"meta tags.available-content(the wrapper around.body.markup).captioned-image-containerfigures and unwrap.image-linklightbox links so embedded images surviveVerified against a real article (
https://garymarcus.substack.com/p/dario-amodei-hype-ai-safety-and-the) that 7 images and 4 figures are preserved end-to-end through the parse pipeline.Context: capyreader#2014
Filed against jocmp/capyreader#2014. The reporter is reading Substack newsletters via kill-the-newsletter (KTN) in capyreader, and "extract full content" gives them cropped images and missing headings.
Important caveat: capyreader's
Account.fetchFullContentpassesarticle.urlto mercury-parser, and KTN entry URLs arekill-the-newsletter.com/feeds/<id>/entries/<id>.html— not Substack URLs. So asubstack.comparser will not directly fix that user's KTN setup. It will, however, fix:*.substack.comfeed extracted in capyreader or any other mercury-parser consumer)A follow-up
kill-the-newsletter.comparser is likely needed to fully close capyreader#2014, but that would require a real KTN entry fixture (the email body, raw, with no surrounding<html>wrapper). I didn't have one available.Limitations
noahpinion.blog,astralcodexten.com,stratechery.com) won't match this extractor — mercury-parser routes by hostname / base domain, and a custom domain's base differs. They would need their own per-domain parsers (or detection-by-html, but that's a larger change).date_publishedis left to mercury's generic detection. Substack only emits the published date inside JSON-LD (<script type="application/ld+json">), which mercury's resource cleaner strips before extractor selectors run, and the on-page date markup uses obfuscated emotion-style class hashes that aren't stable across builds.Test plan
npx jest src/extractors/custom/substack.com/index.test.js— all 6 tests passnpx eslint src/extractors/custom/substack.com/clean