Skip to content

VALIDATION-PLANES-06: Admit unknown sections with a bounded gap

gap({max}) permits a counted window of unrecognized sections between required ones, flagging overflow as structure/gap-count.

Builds on: VALIDATION-PLANES-03: Constrain section order

A TypeScript program against the library API; inline comments show the resulting values and behavior.

import { gap } from "markdown-contract";
const c = contract({ body: sections({ order: "strict" }, [
section("Summary"),
gap({ max: 2 }), // up to 2 unknown sections here
section("Decision"),
]) });
// 3+ unknown sections between them -> structure/gap-count
  • gap() / GapSpec min/max (src/core/grammar.ts)
  • structure/gap-count (src/core/structure.ts checkStrict gap window)
  • doc.body.unknown partition (src/core/model.ts)