Parse SDK
Parse SDK
The Parse SDK is the low-level layer of datamark. It turns Markdown strings into fully typed syntax trees and gives you the tools to query, transform, and extract data from them.
Use it directly when you need fine-grained control over parsing, or as the foundation for higher-level formats built with the Format SDK.
parse()
Turn Markdown into a typed Document with a section tree
Frontmatter
Extract and split YAML frontmatter from Markdown strings
YAML
Parse and stringify YAML with thin built-in helpers
Tree Utilities
Find, filter, split, and extract data from the AST
What the AST SDK provides
| Capability | Functions |
|---|---|
| Parsing | parse(), parseBlocks() |
| Frontmatter | extractFrontmatter(), splitFrontmatter() |
| YAML | parseYaml(), stringifyYaml() |
| Querying | find(), findAll(), filter(), sectionsAtDepth(), sectionsByHeading() |
| Splitting | splitBy(), between(), after(), before() |
| Extraction | codeBlocks(), inlineText(), textContent(), extractTodoItems() |
| Type guards | isHeading(), isCodeBlock(), isTodoItem(), isSection(), isBlockNode(), isInlineNode(), isParentNode() |
What the Format SDK adds on top
The Format SDK builds on the Parse SDK and adds:
datamark()— a factory that wrapsparse,stringify,schema, andexamplesinto a single typed format- Typed frontmatter —
frontmatterSchemavalidates and typesdoc.frontmatterbefore yourparsefunction runs - Builder primitives —
heading(),list(),codeBlock(),frontmatter()fromdatamark/stringifyreplace fragile string concatenation - Self-testing —
examplesare validated by.test()automatically
When to use the Parse SDK directly
- You need to parse Markdown without defining a full format
- You want to inspect or transform an AST interactively
- You're building custom tooling on top of datamark's parser
- You need to extract data from an AST without serialization
For most use cases — especially when you want typed data, validation, and round-trip serialization — the Format SDK is the better starting point.