A structured markdown format for semantic parsing and deterministic document processing. NCM extends CommonMark with YAML frontmatter, a two-stage parsing pipeline that produces typed Element[] and Block[] with deterministic identity, and a promotion engine that detects patterns like admonitions, task lists, and diagrams. Zero dependencies beyond yaml and zod.
import { parseNcm, buildBlocks } from "@nuucognition/ncm"// Parse any markdown documentconst doc = parseNcm(markdown)// Build semantic blocks with IDsconst blocks = buildBlocks(doc.elements)// Deterministic block identityconst header = blocks[0] // → { id: "b1", type: "header" }// Validate against NCM schemaconst result = validate(blocks)--- nc_version: 0.1.0 title: My Document tags: ["#doc"] --- # Hello World A short paragraph. ```ts parseNcm(md) ```
Frontmatter is extracted as structured metadata. The body is parsed into syntactic elements, then assembled into semantic blocks with deterministic IDs.