Skip to content
ironmark

Security

import { markdownToHtml } from "ironmark";
 
markdownToHtml(userInput, { safe: true });

Options

OptionJS (camelCase)Rust (snake_case)DefaultDescription
Safe modesafe—falseShorthand: sets disableRawHtml: true and tagFilter: true
Disable raw HTMLdisableRawHtmldisable_raw_htmlfalseEscape all HTML blocks and inline HTML
No HTML blocksnoHtmlBlocksno_html_blocksfalseEscape block-level HTML only (more granular than disableRawHtml)
No HTML spansnoHtmlSpansno_html_spansfalseEscape inline HTML only
Tag filtertagFiltertag_filterfalseGFM tag filter: escape <script>, <iframe>, …
Max nesting—max_nesting_depth128Limit blockquote and list nesting depth (DoS prevention)
Max input size—max_input_size0 (no limit)Truncate input beyond this byte count

Always on

Dangerous URI schemes are always stripped from link and image destinations, regardless of options:

  • javascript:
  • vbscript:
  • data:, except data:image/…

doc.links() returns these links with url: "".

Rust

use ironmark::{render_html, ParseOptions};
 
let html = render_html("<script>alert(1)</script>", &ParseOptions {
    disable_raw_html: true,
    tag_filter: true,
    max_input_size: 1_000_000, // 1 MB
    ..Default::default()
});

MDX is code