2018.2

Table Of Contents
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253.
Add the following styles to the style sheet for the Print context (see "Step 1: edit CSS" on
page257) 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;
overflow: hidden;
text-overflow: clip;
}
p.toc-entry .dots::after {
font-weight: normal;
content: ". . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Page 389