2019.1

Table Of Contents
$numbers.get(๎˜ƒindex ); (see "get(index)" on page๎˜ƒ775), 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
page๎˜ƒ181), for example ignore-me.
2. Add the:notselector 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").
Adding internal hyperlinks
It is possible to create links in a table of contents that point to the respective position in the
document (for example when generating PDF output). An internal hyperlink points to an
element with a specified ID. (See: "Hyperlink and mailto link" on page๎˜ƒ250.)
Here's how to change the each() function in the script in order to add internal hyperlinks to the
table of contents:
1. Add the following variable: var linknumber = 1;. This variable is used to generate
unique IDs for elements that don't have an ID.
2. Before the first line that starts with 'toc ', add the following:
var anchorId = '';
if (this.attr("id")) {
anchorId = this.attr("id");
}
else {
anchorId = 'generatedID-' + linknumber;
linknumber++;
this.attr("id", anchorId);
}
This code takes the element's ID. If an element doesn't have an ID, the script generates a
new, unique ID for it.
3. Replace the line:
toc += '<span class="text">' + text + '</span>';
Page 410