markplus_core
A universal, high-performance Markdown → AST compiler written in Rust.
markplus_core parses Markdown (with optional YAML frontmatter) into a
structured, versioned JSON AST. It does not render HTML or Typst —
rendering is the responsibility of a downstream crate or plugin that consumes
the AST. This keeps the parser lean and completely independent of any output
target.
Key capabilities
| Feature | Detail |
|---|---|
| Platform sovereign | Compiles to native (Tauri, CLI) and WebAssembly (browser/PWA) from one codebase |
| Versioned AST | JSON output carries a schema version so renderers can detect incompatible shapes |
| Frontmatter | YAML frontmatter extracted and serialised to JSON; stripped body kept separately |
| All pulldown-cmark extensions | Tables, footnotes, strikethrough, task lists, math, GFM alerts, definition lists, superscript/subscript |
| Fenced block attrs | ```python execute=true linenos → { "name": "python", "attrs": {...} } |
| Extended links/images | [text](url){key=value} and {width=480} |
| Inline widgets | :[text]{tooltip text="Local oscillator"} for custom inline extensions |
| Formal JSON Schema | schema/markplus-ast.v2.schema.json — validators and renderers use this as the source of truth |
Project structure
markplus_core/
├── Cargo.toml
├── docs/
│ ├── usage.md ← API / CLI usage guide
│ └── ast-reference.md ← Markdown → AST node reference
└── src/
├── lib.rs ← Public API (native + Wasm exports)
├── main.rs ← mpc CLI (single-command AST emitter)
├── config.rs ← Parser options / FrontmatterMode
├── event_filter.rs ← Frontmatter stripper, passes events through
├── ast.rs ← Stack-based AST builder
└── json.rs ← SiteAsset wire format
Quick start
Build
CLI
# Emit compact AST JSON
# Emit pretty-printed AST JSON
Rust library
use ;
// Full document with frontmatter
let asset = parse_document?;
let json = asset.to_json?; // write to note.json
// Pre-stripped body only
let ast = parse_body;
WebAssembly (JavaScript)
import init from './pkg/markplus_core.js';
await ;
// Plain markdown body → AST array JSON string
const ast = JSON.;
// Raw markdown (frontmatter ignored in wasm) → full SiteAsset JSON string
const site = JSON.;
Wire format — note.json
See docs/ast-reference.md for the full AST node schema.
Schema
The file schema/markplus-ast.v1.schema.json
is a JSON Schema 2020-12 document that formally defines every node type in the AST.
It is the source of truth for both markplus_core (producer) and all downstream
renderers and plugins (consumers). When a new node type is added, the schema is updated
first — then the core, then the renderers.
Validate your AST
# Python (jsonschema)
|
See schema/CHANGELOG.md for the schema versioning policy.
Further reading
docs/usage.md— detailed API and CLI usagedocs/ast-reference.md— every Markdown construct mapped to its AST nodeschema/markplus-ast.v1.schema.json— formal JSON Schema (machine-readable)schema/CHANGELOG.md— schema versioning history and breaking-change policy