Skip to content

CONSUME-AS-DATA-03: Walk a SectionView's content surface

A SectionView exposes name, pos, anchors, text(scope), tables/table and lists, with absent optionals reading as undefined.

Builds on: CONSUME-AS-DATA-02: Read one section’s prose two ways

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

const s = doc.body.summary;
s.name; // "Summary"
s.pos; // { line: 1, col: 1 } — heading SourcePos
s.anchors; // ["summary"] — its ^block-ids
s.text("all"); // prose + block text flattened
s.tables; // TableView[] (s.table for the sole one)
s.lists; // ListView[]
doc.body.why?.text(); // undefined — absent optional section short-circuits
  • SectionView.name/.pos/.anchors
  • .text("prose"|"all")
  • .tables/.table
  • .lists
  • absent-optional reads