2022.1

Table Of Contents
to put dots between heading and page number.
The number class (for the page number) is not only used in CSS, but also later on in the script.
The table of contents is inserted in the section with: results.html(toc ); (see "html()" on
page1449).
The table of contents may get too long for a single page and affect the page numbers in other
sections. In that case it is necessary to re-paginate the content; merge.section.paginate(); does
the trick.
Note
Whether page numbering restarts in each section, depends on the settings for page
numbering; see "Configuring page numbers" on page533. By default, page numbering
starts with page 1 for each section.
If the pagination process has changed the page numbers, the TOC needs to be updated as
well.
To do that, the script first has to collect the page numbers from the table of contents. This is
where the number class comes in handy: var $numbers = query('.number');.
Note that this query() function, as opposed to merge.context.query(), only searches the current
section (see "query()" on page1379).
Then, the level 1 and 2 headings are collected from all Print sections again using
merge.context.query("h1, h2").
The callback function in each() retrieves the heading's new page number. It then uses the index
number of the heading in the result set to get the corresponding entry in the TOC: var entry =
$numbers.get(index ); (see "get(index)" on page1407), and replaces it with the new page
number.
Excluding headings
Often there are certain headings that you don't want to appear in the table of contents. The title
of the table of contents itself, for example.
To exclude these headings from the table of contents, do the following:
1. Give all the headings that you want to be ignored the same class (see "ID and class" on
page667), for example ignore-me.
Page 975