2018.2

Table Of Contents
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
page548), for example ignore-me.
2. Add the :not selector to the queries in the script, specifying that class. Remember to put
a dot before the name of the class. For example: merge.context.query("h1:not
(.ignore-me), h2").
Note
Currently it is not possible to create links in a table of contents to the respective position in the
document (for example when generating PDF output).
Step 4: Styling the table of contents
Each component of the table of contents inserted in Step 3 is wrapped in a <span> element that
has a class, for example: "dots" or even multiple classes: "toc-entry h1". (Class names are
separated by a space.)
These classes can be used to style the table of contents with CSS. The principles of styling
with CSS are explained in another topic: "Styling templates with CSS files" on page646.
Add the following styles to the style sheet for the Print context (see "Step 1: edit CSS" on
page651) to align the page number to the right and fill the space between the text and the page
number with leader dots.
p.toc-entry {
display: flex;
margin: 0 0 0.25em 0;
}
p.toc-entry .text {
flex-shrink: 0;
}
p.toc-entry .dots {
flex-shrink: 1;
white-space: nowrap;
Page 771