html-to-markdown-rs 3.5.7

High-performance HTML to Markdown converter using the astral-tl parser. Part of the Kreuzberg ecosystem.
Documentation
//! Example: Converting HTML tables to Markdown

fn convert(
    html: &str,
    opts: Option<html_to_markdown_rs::ConversionOptions>,
) -> html_to_markdown_rs::error::Result<String> {
    html_to_markdown_rs::convert(html, opts).map(|r| r.content.unwrap_or_default())
}

fn main() {
    let html = r"<table>
        <tr><th>Name</th><th>Age</th></tr>
        <tr><td>Alice</td><td>30</td></tr>
        <tr><td>Bob</td><td>25</td></tr>
    </table>";

    match convert(html, None) {
        Ok(markdown) => {
            println!("Markdown:\n{markdown}");
        }
        Err(e) => {
            eprintln!("Error: {e}");
        }
    }
}