Small Rust + wasm markdown parser.
Requirements:
- Rust and Cargo
- Node.js (or Bun)
- wasm-pack
Install wasm-pack:
cargo install wasm-packBuild the wasm package:
npm run buildThis generates the TS/WASM bindings in pkg/.
The module comes with one function: parse_markdown(input: string)
import { parse_markdown } from "markdown_wasm";
await init();
const input = `# Hello`
const html = parse_markdown(input);
console.log(html);- Headings (
#to###currently parsed) - Paragraph blocks (including multi-line paragraphs)
- Unordered lists
- Ordered lists
- Fenced code blocks (``` and ~~~)
- Blockquotes
- Thematic breaks (
---,***,___) - Inline links (
[text](url)) - Emphasis (
*italic*,**bold**) - Images (
) - Inline code spans (
`code`) - Autolinks (
<https://example.com>) - Backslash escapes (
\*,\[, etc.) - HTML escaping in rendered output
- Tables
- Task lists (
- [ ]/- [x]) - Strikethrough (
~~text~~) - Autolink literals (
https://example.com) - Footnotes
- Pipe table alignment (
:---,:---:,---:)
- Setext headings (
Heading+===) - Indented code blocks (4-space)
- Reference-style links (
[text][id])
Using @rsms/markdown-wasm's bench suite for comparison. Ran on Window 11 Version 10.0.26200 Build 26200. Ran on an AMD 7800X3D.
Ops/second represents how many times a library is able to parse markdown and render HTML during a second, on average across all sample files.
Throughput is the average amount of markdown data processed during a second while both parsing and rendering to HTML. The statistics does not include HTML generated but only bytes of markdown source text parsed.
This graph shows the spread between the fastest and slowest parse-and-render operations for each library. Lower numbers are better.