Skip to content

stormlightlabs/lectito

Repository files navigation

Lectito banner

MPL 2.0 License

This is the source code for Lectito, containing the library, CLI, & documentation.

What is Lectito?

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

Quick Start

Install the command-line tool:

cargo install lectito-cli
lectito https://example.com/article --format markdown

Install 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.pdf

Without --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-example

Installation

Library

cargo add lectito

or add it to Cargo.toml:

[dependencies]
lectito = "0.1"

CLI

cargo install lectito-cli

# With PDF output
cargo install lectito-cli --features pdf

MCP Server

cargo install lectito-mcp

Local Development

With an up to date Rust toolchain, clone the repo and then check out the local dev guide.

License

MPL 2.0

About

web page/article fetcher inspired by readability

Topics

Resources

License

Stars

11 stars

Watchers

0 watching

Forks

Sponsor this project

  •  

Contributors