tiptap-rusty-parser
A fast, schema-agnostic Rust crate to parse, query, edit, diff and validate
Tiptap / ProseMirror JSONContent documents.
- Any schema. Every node and mark type is accepted. A schema is optional and only used when you validate.
- Faithful roundtrip. Unknown node types and unknown JSON fields are kept and written back.
- Fast. Queries return borrows instead of clones, and edits happen in place.
It is the engine behind Tiptap Studio, and is also published for JavaScript as
@tiptap-studio/rusty-parser.
Documentation: guide · API reference
Install
[]
= "0.6"
Quick start
use ;
let mut doc = from_json_str
.unwrap;
// Query with a closure, or with the query language.
assert_eq!;
let q = parse.unwrap;
assert_eq!;
// Bold every text node and append a paragraph.
let changed = doc.replace_all;
assert_eq!;
doc.push_child;
assert_eq!;
What it does
| Area | Guide |
|---|---|
| Parse and serialize, with source maps from nodes to JSON byte spans | Parsing |
Find nodes with closures, selectors or a query language (type == heading && attrs.level > 1) |
Querying, Query language |
| Address nodes by index path or by ProseMirror position, and map positions through edits | Paths and positions |
| Edit marks, attributes, children and text; normalize; range and block commands | Mutating, Range and block editing |
| Record edits as an invertible change log for undo | Transactions |
| Apply position-addressed edits, as AI tools produce them | Position editing |
| Diff two documents into a change list; compose, compact, map and cherry-pick changes | Diffing, Change algebra |
| Validate against a schema with ProseMirror-style content expressions | Schema |
| Extract text, render HTML, build nodes in code | Text, HTML, Building nodes |
Upgrading from 0.5: see the migration guide.
License
MIT