Skip to content
Ferromark

Ferromark / Rust

Configure Rust Rendering

Choose syntax with ParserOptions and HTML output with HtmlRendererOptions. These are independent settings; Rust defaults preserve raw HTML.

Render untrusted content

use ferromark::{to_html_with_options, HtmlRendererOptions, ParserOptions};

let html = to_html_with_options(
    "==Important== <b>authored HTML</b>",
    ParserOptions { highlight: true, ..ParserOptions::default() },
    HtmlRendererOptions { sanitize: true, ..HtmlRendererOptions::default() },
).unwrap();
assert!(html.contains("<mark>Important</mark>"));
assert!(html.contains("&lt;b&gt;"));

sanitize: true escapes raw HTML and filters unsafe link and image schemes. Custom hook output still requires your own escaping. See rendering and trust.

Select a dialect

ProfileParserRenderer
CommonMark specificationParserOptions::commonmark()HtmlRendererOptions::commonmark()
GFM specificationParserOptions::gfm_spec()HtmlRendererOptions::gfm_spec()
GFM with publishing conveniencesParserOptions::gfm()HtmlRendererOptions::gfm()

The specification renderer profiles disable automatic heading IDs, callouts, and fence metadata cleanup. The GFM specification profile enables the tag filter and leaves footnotes off. ParserOptions::gfm() also enables footnotes. No profile enables front matter or the extra table-layout options. Set sanitize: true independently when the source is untrusted.

Add publishing features

use ferromark::{AbbreviationOptions, HtmlRendererOptions, ParserOptions};

let syntax = ParserOptions {
    front_matter: true,
    insertions: true,
    merged_table_cells: true,
    table_attributes: true,
    image_attributes: true,
    image_captions: true,
    extended_attributes: true,
    bracketed_spans: true,
    blockquote_attributions: true,
    ..ParserOptions::gfm()
};
let output = HtmlRendererOptions {
    table_colgroup: true,
    table_column_names: true,
    sanitize: true,
    ..HtmlRendererOptions::default()
};
let abbreviations = AbbreviationOptions::default();
let html = ferromark::to_html_with_options_and_abbreviations(
    "# Notes\n\n++An important note++.",
    syntax,
    output,
    abbreviations,
).unwrap();
assert!(html.contains("<ins>An important note</ins>"));

Use the non-exhaustive AbbreviationOptions type to provide exact titles, bare wrappers (Some("")), or suppressions (None). Add AbbreviationOptions::default() and set its public overrides field. Passing this separate configuration opts in to matching while keeping HtmlRendererOptions source-compatible. For a reusable renderer, call HtmlRenderer::new().with_abbreviations(options) or HtmlRenderer::with_options(options).with_abbreviations(abbreviations). See the technical abbreviation guide for token boundaries, protected content, and the built-in dictionary.

guillemet_digraphs preserves <<Bonjour>> as text for the optional locale-aware typography pass. See the typography guide for the Rust pass and Node.js configuration.

See the FFM guide for author-facing publishing examples and the Rust API guide for all entry points. Keep unused extensions off when their syntax is unnecessary; profile measurements describe their costs. Image captions explain the independent image options and the plain table caption form. Shared attributes cover bracketed spans and key/value metadata. Block quote attributions describe visible sources, attachment boundaries, and figure attributes.