Skip to main content

Crate markkit

Crate markkit 

Source
Expand description

§Markkit

Extract clean markdown from any format.

Markkit is a Rust library for converting HTML, PDF, DOCX, spreadsheets, and other document formats into clean, well-structured markdown.

§Quick Start

use markkit::{DocumentHint, Markkit};

let markkit = Markkit::builder().build();

// Extract markdown from HTML
let md = markkit.extract_html("<h1>Hello</h1><p>World</p>").await?;

// Convert any supported document from bytes (format detected from the
// content type, then the file extension, then magic bytes).
let bytes = std::fs::read("report.docx")?;
let doc = markkit.extract_document_sync(&bytes, DocumentHint::file_name("report.docx"))?;
println!("{} ({}): {}", doc.title.unwrap_or_default(), doc.format, doc.markdown);

// Extract from a URL (requires the `http_client` feature)
#[cfg(feature = "http_client")]
let md = markkit.extract_url("https://example.com").await?;

§Features

  • HTML (html, default): Convert HTML to markdown with configurable rules
  • DOCX (docx): Convert Word documents
  • Spreadsheet (spreadsheet): Convert XLSX/XLSM, XLS and ODS workbooks to tables
  • PDF (pdf): Planned; currently returns Error::UnsupportedFormat
  • URL fetching (http_client, default): Fetch and extract from URLs via reqwest

Embedders that do their own fetching can drop reqwest entirely: markkit = { version = "0.1", default-features = false, features = ["docx", "spreadsheet"] }.

Re-exports§

pub use config::MarkkitBuilder;
pub use error::Error;
pub use extract::Extraction;
pub use extract::ExtractionStats;
pub use extract::Markkit;
pub use format::DocumentHint;
pub use format::Format;
pub use ir::Document;
pub use render::MarkdownRenderer;

Modules§

config
error
extract
format
Format detection and content type handling.
html
HTML parsing module.
ir
Canonical intermediate representation for documents.
render
Rendering module.

Type Aliases§

Result
Result type alias for markkit operations.