Get Started
The core package never touches the DOM. Use it on the server, in agents, or in batch jobs — the same types as the editor.
import { mdToDoc, docToMd } from 'markloom'
const doc = mdToDoc(fs.readFileSync('note.md', 'utf8'))
// …transform…
fs.writeFileSync('note.md', docToMd(doc))
import { apply, appendText, mdToDoc, docToMd } from 'markloom'
let doc = mdToDoc(source)
const blockId = /* stable id of target block */
for await (const token of stream) {
doc = apply(doc, appendText(doc, blockId, token))
}
await save(docToMd(doc))
import { diffById } from 'markloom'
const changes = diffById(before, after)
// each block: added | changed | removed | same
import { createHistory, commit, undo, redo } from 'markloom'
let h = createHistory(doc)
h = commit(h, steps)
h = undo(h)
h = redo(h)
Import markloom/view only on the client.
Keep transforms and agent patches on the kernel so SSR bundles stay clean.