VALIDATION-PLANES-01: Parse markdown into a DocTree
What it demonstrates
Section titled “What it demonstrates”parse(md) returns the raw DocTree of frontmatter, sections, and positions before any contract exists.
Builds on: nothing — this is the first rung of Authoring Contracts in Code: Structure, Content, and Custom Rules.
How it’s done
Section titled “How it’s done”A TypeScript program against the library API; inline comments show the resulting values and behavior.
import { parse } from "markdown-contract";
const tree = parse("---\nid: T-1\n---\n## Summary\n\nShips today.\n");tree.frontmatter.data; // { id: "T-1" }tree.root.sections[0].name; // "Summary"tree.root.sections[0].pos; // { line: 4, col: 1 }tree.root.sections[0].blocks; // [{ kind: "paragraph", text: "Ships today." }]Surfaces exercised
Section titled “Surfaces exercised”parse() -> DocTree (src/core/projection.ts)DocTree.frontmatter / root / mdastSectionNode.name / pos / blocks