VALIDATION-PLANES-09: Require a fenced code block in a language
What it demonstrates
Section titled “What it demonstrates”code({lang}) requires a fenced block and pins its language, separating the structural kind-gate from the content check.
Builds on: VALIDATION-PLANES-07: Require a block kind: a table
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 { code } from "markdown-contract";
const c = contract({ body: sections({}, [ section("Example", { content: code({ lang: "ts" }) }),]) });// no fenced block -> structure/block-missing// a ```js block where ```ts is required -> content/code/langSurfaces exercised
Section titled “Surfaces exercised”code() leaf, lang pin (src/core/leaves.ts)structure kind-gate (block-missing) vs content/code/lang split (src/core/structure.ts + content.ts)