Skip to content
ironmark

Rust

cargo add ironmark
use ironmark::{render_html, ParseOptions};
 
fn main() {
    // with defaults
    let html = render_html("# Hello\n\nThis is **fast**.", &ParseOptions::default());
 
    // with custom options
    let html = render_html("line one\nline two", &ParseOptions {
        hard_breaks: false,
        enable_strikethrough: false,
        ..Default::default()
    });
 
    // safe mode for untrusted input
    let html = render_html("<script>alert(1)</script>", &ParseOptions {
        disable_raw_html: true,
        max_input_size: 1_000_000, // 1 MB
        ..Default::default()
    });
}

Every field of ParseOptions is listed on Options and Security.

Cargo features

FeatureDefaultEnables
htmlyesMarkdown to HTML (render_html)
ansiyesMarkdown to ANSI terminal (render_ansi_terminal)
html-parseryesHTML to AST to Markdown (html_to_markdown)
serdenoSerialize/Deserialize for the AST types
clinoThe ironmark binary

Parsing to the AST (parse_markdown) and AST to Markdown (render_markdown) are always available. To build only what you use:

[dependencies]
ironmark = { version = "2", default-features = false, features = ["html"] }

Dependencies

At runtime ironmark depends only on memchr, rustc-hash, compact_str and smallvec. serde is optional and only pulled in by the serde feature.

More