markstone
v0.1.0
Published
Fast, safe Markdown-to-HTML and AST engine with Actos extensions for Node.js and the browser
Maintainers
Readme
markstone
Unified Node.js and browser package for markstone: fast, safe Markdown-to-HTML and AST engine with Actos extensions.
Uses native napi-rs addon on Node.js and WebAssembly (wasm-bindgen) in browsers via conditional exports. Both paths produce byte-for-byte identical output.
Installation
npm install markstonePrebuilt addons ship for Linux (x64 and arm64, glibc 2.28+ and musl), macOS (x64 and arm64) and Windows (x64 and arm64). On any other platform, Node falls back to the WebAssembly build with no extra setup.
Usage
Node.js (Native Addon)
import markstone, { toHtml, toAst, actos } from 'markstone';
// Generic CommonMark + GFM
const html = toHtml('# Hello world');
const ast = toAst('# Hello world');
// Actos extensions (@mentions and #tags)
const actosHtml = actos.toHtml('Hello @alice and #rust');
const actosAst = actos.toAst('Hello @alice and #rust');Browser (WebAssembly)
import markstone, { init, toHtml, toAst, actos } from 'markstone';
// Initialize WASM binary once in browser
await init();
// Render
const html = toHtml('# Hello from the browser');
const actosHtml = actos.toHtml('Hello @alice and #rust');Security & Conformance
- No raw HTML or dangerous scripts pass through the AST sanitizer.
- Depth limit: 64 block levels (
DEPTH_EXCEEDED). - Input limit: 4 MiB (
INPUT_TOO_LARGE). - 100% byte-for-byte conformance parity between Node native and browser WASM.
