Expand description
Extract readable article content from HTML.
The crate does not fetch pages. Pass HTML from a crawler, browser, cache, or fixture, plus an optional base URL for resolving relative links.
Use extract for normal application code. Use
extract_with_diagnostics when debugging root selection, cleanup, or site
profiles.
use lectito::{extract, ReadabilityOptions};
let options = ReadabilityOptions::default();
let article = extract(html, Some("https://example.com/post"), &options)?;
if let Some(article) = article {
println!("{}", article.text_content);
}Structs§
- Article
- Extracted article content and metadata.
- Attempt
Diagnostic - Diagnostics for one generic extraction attempt.
- Candidate
Diagnostic - Diagnostics for one candidate article root.
- Cleanup
Diagnostic - Cleanup measurements for a selected article root.
- Content
Selector Diagnostic - Diagnostics for a caller-provided content selector.
- Extraction
Diagnostics - Details about how extraction selected, cleaned, and accepted article roots.
- Extraction
Report - Article output plus diagnostics for the decisions made during extraction.
- Flag
Diagnostic - Generic extraction flags used for an attempt.
- Markdown
Options - Options for Markdown-to-HTML rendering.
- Node
Diagnostic - Stable summary of a DOM node used in diagnostics.
- Readability
Options - Options for full article extraction.
- Readable
Options - Options for the quick readability check.
- Recovery
Diagnostic - Content recovery performed before scoring.
- Rule
Source - Provenance for a built-in trope rule.
- Text
Range - Location of a match in the original input.
- Trope
Finding - One trope finding in the input text.
- Trope
Options - Options for trope diagnostics.
- Trope
Report - Complete trope diagnostics report.
- Trope
Summary - Aggregate report measurements.
Enums§
- Candidate
Selection - Reason a node was considered as an article root.
- Error
- Error returned by Lectito extraction and conversion functions.
- Extraction
Outcome - Final status for an extraction report.
- Media
Retention - Controls how much media remains in extracted article HTML and Markdown.
- Severity
- Severity of one finding.
- Trope
Category - Broad category for a trope rule or detector.
- Trope
Preset - Built-in scanning preset.
- Trope
Signal - Coarse trope signal for a report.
Functions§
- analyze_
tropes - Analyze text for AI-like writing tropes.
- clean_
article_ html - Extract and return only the cleaned article HTML.
- escape_
html - Escapes text for safe insertion into HTML text or attribute contexts.
- extract
- Extract a readable article from an HTML document.
- extract_
with_ diagnostics - Extract an article and include diagnostics for root selection and cleanup.
- html_
to_ markdown - Convert a cleaned HTML fragment to Markdown.
- is_
probably_ readable - Return a quick estimate of whether an HTML document contains article text.
- markdown_
to_ html - Render Markdown to HTML with the provided options.
- markdown_
with_ toml_ frontmatter - Format an article as Markdown with TOML frontmatter.
Type Aliases§
- Result
- Result type used by Lectito APIs.