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.

What the AST SDK provides

CapabilityFunctions
Parsingparse(), parseBlocks()
FrontmatterextractFrontmatter(), splitFrontmatter()
YAMLparseYaml(), stringifyYaml()
Queryingfind(), findAll(), filter(), sectionsAtDepth(), sectionsByHeading()
SplittingsplitBy(), between(), after(), before()
ExtractioncodeBlocks(), inlineText(), textContent(), extractTodoItems()
Type guardsisHeading(), 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 wraps parse, stringify, schema, and examples into a single typed format
  • Typed frontmatterfrontmatterSchema validates and types doc.frontmatter before your parse function runs
  • Builder primitivesheading(), list(), codeBlock(), frontmatter() from datamark/stringify replace fragile string concatenation
  • Self-testingexamples are 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.

On this page