Expand description
Section numbering and table-of-contents construction over the document model.
number_sections splices a section number into each numbered heading: a leading
header-section-number span carrying the number, a following space, and a number key/value
attribute. build_toc produces a nested bullet list linking to the document’s headings, which a
writer renders into the toc template variable. Both number headings the same way — a counter per
level, the result joined from the document’s shallowest heading level — so a heading and its
contents entry always carry the same number.
Functions§
- build_
toc - Build a nested bullet list linking to the document’s headings down to
depth, orNonewhen no heading qualifies. Withnumbered, each entry carries a leadingtoc-section-numberspan holding the heading’s number (computed exactly asnumber_sectionsdoes); without it, entries carry only the heading text. Withanchors, each entry’s link carries its owntoc--prefixed id so it can be linked back to; formats that cannot represent an inline identifier passfalseto omit it. Footnotes are dropped and links unwrapped, so an entry never nests an anchor or a note marker. - number_
sections - Splice section numbers into the headings of
blocks, walking nested sections in document order. A numbered heading gains a leadingheader-section-numberspan holding its number, a following space, and anumberkey/value attribute; an unnumbered heading is left untouched.