Skip to main content

Crate quick_html2md

Crate quick_html2md 

Source
Expand description

Fast HTML to Markdown conversion with GFM support.

§Features

  • Headings: <h1>-<h6> -> #-######
  • Emphasis: <strong>/<b> -> **bold**, <em>/<i> -> *italic*
  • Strikethrough: <del>/<s> -> ~~struck~~
  • Lists: <ul>/<ol> with proper nesting and indentation
  • Links: <a href=""> -> [text](url)
  • Images: <img> -> ![alt](src)
  • Code: <code> -> `inline`, <pre><code> -> fenced blocks with language
  • Tables: Full GFM table support with alignment
  • Blockquotes: <blockquote> -> > quote

§Quick Start

use quick_html2md::html_to_markdown;

let html = "<h1>Hello</h1><p>World</p>";
let md = html_to_markdown(html);
assert!(md.contains("# Hello"));
assert!(md.contains("World"));

§With Options

use quick_html2md::{html_to_markdown_with_options, MarkdownOptions};

let options = MarkdownOptions::new()
    .include_links(false)
    .preserve_tables(true);

let html = "<p><a href='url'>link</a></p>";
let md = html_to_markdown_with_options(html, &options);

Re-exports§

pub use options::MarkdownOptions;

Modules§

options
Configuration for Markdown output.

Functions§

element_to_markdown
Convert HTML element to Markdown.
element_to_markdown_with_options
Convert HTML element to Markdown with options.
html_to_markdown
Convert HTML string to Markdown.
html_to_markdown_with_options
Convert HTML string to Markdown with options.
to_markdown
Convert HTML document to Markdown.
to_markdown_with_options
Convert HTML document to Markdown with options.