Getting started
ironmark is a Markdown parser written in Rust. It passes all 652 CommonMark 0.31.2 spec tests, adds the common extensions (tables, task lists, strikethrough, autolinks and more), and has no third-party parsing dependencies.
It renders one parse to several outputs: HTML, plain text, an AST, ANSI terminal output, normalized Markdown, or MDX compiled to JSX. It also converts HTML back to Markdown.
Install
The npm package runs the Rust parser as WebAssembly in Node, Bun and the browser. For the crate, see Rust.
Quick start
import ironmark from "ironmark";
const doc = ironmark.parse("# Hello\n\n**World**");
doc.html(); // "<h1>Hello</h1>\n<p><strong>World</strong></p>\n"
doc.ast(); // { Document: { children: [...] } }
doc.headings(); // [{ level: 1, text: "Hello", id: "hello" }]ironmark.parse() returns a document. Nothing renders until you ask for an output, and each output is computed once.
Prefer plain functions? Every output also has a named export:
import { markdownToHtml, markdownToAst } from "ironmark";
const html = markdownToHtml("# Hello\n\n**World**");
const ast = markdownToAst("# Hello\n\n**World**");Node, Bun and the browser
Under Node and Bun the WASM binary loads synchronously, so you can call any function right away.
In the browser, wait for the binary once before the first call:
import ironmark from "ironmark";
await ironmark.ready; // or: await ironmark.init()
ironmark.html("# Hello");ready and init() return the same cached promise. init() returns a promise in every entry and resolves immediately under Node. See Browser and bundlers for custom .wasm URLs.
Next steps
- Which function should I use? maps common goals to functions.
- Options lists every extension and how to turn it off.
- Safe HTML covers untrusted input.
- MDX and the build tool plugins import
.mdand.mdxfiles as components. - The playground renders every output live in the browser.