Handbook
This is not “we support export to .md.”
The model is built so Markdown and the editor share the same shape.
import { mdToDoc, docToMd } from 'markloom'
const doc = mdToDoc(source)
const next = /* apply Steps… */
const out = docToMd(next)
Parsing and serialization go through mdast with GFM extensions.
Dirty blocks re-stringify locally. Clean blocks keep source spans so untouched prose is not reformatted on save. That is what makes round-trips feel honest for notes apps.
| Clipboard | Behavior |
|---|---|
text/plain | Parsed as Markdown |
text/html | Structured blocks (lists, tables, marks, …) |
| Selection + bare URL | Wrap as link |
One pipeline — not two half-broken converters fighting each other.
Some structures are not pure CommonMark (callouts, mentions, embeds, comments).
They round-trip via intentional HTML islands (data-* attributes) while
remaining first-class tree nodes in the editor.
Streaming AI soft-closes incomplete MD each frame, runs mdToDoc,
and previews real headings / lists / code / marks — not a plain text blob.
See AI write.
docToMd(doc) when MD is your storage format.mdToDoc for migrations and agent patches.