Build a nested table of contents from the headings inside a content region and render it as a list of anchor links, replacing the nav's placeholder content (which is restored on destroy). With scrollSpy enabled, the entry for the heading currently in view is marked with aria-current. Call refresh() on the returned API after the content changes.