Skip to content

CONSUME-AS-DATA-08: Traverse nested subsections

SectionView.sections is itself a dual-key group of the nested H3 subsections.

Builds on: CONSUME-AS-DATA-03: Walk a SectionView’s content surface

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

const c = contract({ body: sections({ allowUnknown: true }, [
optional(section("Post-mortem", { children: sections({ order: "strict" }, [
section("Acceptance criteria coverage"),
section("What worked"),
]) })),
])});
const pm = c.read(src, { path: "T-AB12.md" }).body.postMortem;
pm.sections.whatWorked.text(); // camelCase key
pm.sections.section("What worked").text(); // exact-heading accessor — same view
  • section() children: sections()
  • nested SectionView.sections dual-key group
  • optional()