Loading homepage
Implement tableOfContents to construct a hierarchical navigation data tree from the headings in an HTML document.
Input: // Headings: h2#intro, h4#detail, h2#next tableOfContents(root); Output: [{ id: "intro", text: "Intro", level: 2, children: [{ id: "detail", text: "Detail", level: 4, children: [] }] }, { id: "next", text: "Next", level: 2, children: [] }]
Use the documented contract in both JS and TS.