Skip to content

Start with Rust

Ferromark is an arena-allocated Markdown parser and HTML renderer. The Rust crate provides direct HTML helpers and an AST API for applications that need document structure. Requires Rust 1.95 or newer.

Install the release candidate

cargo add ferromark@=2.0.0-rc.1

V2 is in release-candidate testing and has a breaking API change from v1. Read the migration guide.

Save this in src/main.rs and run cargo run:

fn main() -> Result<(), ferromark::ParseError> {
    let html = ferromark::to_html("Hello, **world**!")?;
    assert_eq!(html, "<p>Hello, <strong>world</strong>!</p>\n");
    println!("{html}");
    Ok(())
}

Rust defaults preserve raw HTML. For untrusted Markdown, explicitly set HtmlRendererOptions { sanitize: true, ..Default::default() } with to_html_with_options as shown in configuration.

Choose your API

Your taskAPI
Render one documentto_html()Result<String, ParseError>
Select syntax and rendering policyto_html_with_options()
Append to an existing stringto_html_into() / to_html_into_with_options()
Inspect front matter or transform nodesAllocator + Parser + HtmlRenderer
Customize HTML outputHtmlRenderHooks

Continue with configuration and content pipelines. The API reference lists all types and methods.