CONSUME-AS-DATA-09: Collect tolerated extra sections
What it demonstrates
Section titled “What it demonstrates”Sections outside the contract (via gap()/allowUnknown) partition into doc.body.unknown as a positional SectionView[].
Builds on: CONSUME-AS-DATA-02: Read one section’s prose two ways
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.
const c = contract({ body: sections({ order: "strict" }, [ section("Title"), section("Overview"), section("Status"), gap(),])});
const doc = c.read(src, { path: "status.md" });doc.body.status.text(); // declared section, typed keydoc.body.unknown.length; // 1 — e.g. an un-modeled "## Risks"doc.body.unknown.map(s => s.name); // ["Risks"] — heading is the handleSurfaces exercised
Section titled “Surfaces exercised”gap()sections order:"strict"doc.body.unknown SectionView[] read by index/iteration/.name