This is the source code for Lectito, containing the library, CLI, & documentation.
Lectito is a library and command-line tool to extract readable content from HTML. It's an augmented, Rust implementation of the Mozilla Readability algorithm.
Learn more by reading the docs and the book
Install the command-line tool:
cargo install lectito-cli
lectito https://example.com/article --format markdownInstall the optional PDF feature when you want the CLI to write extracted articles as PDFs:
cargo install lectito-cli --features pdf
lectito https://example.com/article --format pdf --output article.pdfWithout --output, PDF mode writes {hash}.pdf in the current directory and
prints the path it wrote.
Use the Rust library when your application already has HTML:
use lectito::{extract, ReadabilityOptions};
fn main() -> Result<(), lectito::Error> {
let html = r#"
<article>
<h1>Readable HTML in Rust</h1>
<p>Lectito extracts the article body and removes page chrome.</p>
<p>It returns cleaned HTML, Markdown, plain text, and metadata.</p>
</article>
"#;
let options = ReadabilityOptions { char_threshold: 0, ..Default::default() };
let article = extract(html, Some("https://example.com/post"), &options)?
.expect("example article should be readable");
println!("{}", article.markdown);
Ok(())
}Run the checked example in this repo:
cargo run -p lectito-basic-examplecargo add lectitoor add it to Cargo.toml:
[dependencies]
lectito = "0.1"cargo install lectito-cli
# With PDF output
cargo install lectito-cli --features pdfcargo install lectito-mcpWith an up to date Rust toolchain, clone the repo and then check out the local dev guide.
