Expand description
HTML → markdown/text extraction + token estimation. Owner: parser agent.
§Requirements
extractconverts feed item HTML into the requestedContentFormat:Markdown: convert withhtmd(HTML → Markdown).Text: render to plain text withhtml2text.Html: return the HTML as-is (feed-rs already emits sanitized content).None: callers should not callextract; return an empty string defensively.
- On any converter error, fall back to a naive tag strip rather than panicking, and
report the fallback so callers can surface a
CONTENT_EXTRACTION_FALLBACKwarning. estimate_tokensreturns a cheap, dependency-free token estimate (ceil(chars / 4)), used so agents can budget context.
Constants§
- TRUNCATION_
MARKER - Marker appended to truncated content. The boolean flag is authoritative; this is a human/agent-visible hint that the body was cut.
Functions§
- content_
hash - Stable 16-hex (64-bit) SHA-256 prefix of already-extracted content, for cheap change-detection across runs. Mirrors the item-id construction (lowercase hex, first 8 bytes); 64 bits is ample to flag “this body changed”.
- estimate_
tokens - Rough token estimate for already-extracted text. Owner:
parseragent. - extract
- Convert
htmlto the requested format. Owner:parseragent. - truncate_
to_ chars - Truncate
textto at mostmax_charscharacters (not bytes), appendingTRUNCATION_MARKERwhen anything was cut. Returns(text, was_truncated).