1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
function currentChapter() {
var path = document.location.pathname;
var idx = path.lastIndexOf("/") + 1;
var chap = path.substring(idx, idx + 2);
return parseInt(chap, 10);
}
function heading(i, heading, $heading) {
var currentLevel = parseInt(heading.tagName.substring(1));
var result = "";
if (currentLevel === this.headerLevel) {
this.headerCounts[this.headerLevel] += 1;
return "" + this.headerCounts[this.headerLevel] + " " + $heading.text();
} else if (currentLevel < this.headerLevel) {
while(currentLevel < this.headerLevel) {
this.headerCounts[this.headerLevel] = 1;
this.headerLevel -= 1;
}
this.headerCounts[this.headerLevel] += 1;
return "" + this.headerCounts[this.headerLevel]+ " " + $heading.text();
} else {
while(currentLevel > this.headerLevel) {
this.headerLevel += 1;
this.headerCounts[this.headerLevel] = 1;
}
return "" + this.headerCounts[this.headerLevel]+ " " + $heading.text();
}
}
$('#toc').toc(
{
'selectors': 'h1,h2,h3',
'smoothScrolling': false,
'chapter': currentChapter(),
'headerLevel': 1,
'headerCounts': [-1, currentChapter() - 1, 1, 1],
'headerText': heading
}
);
// no language auto-detect so that EBNF isn't detected as scala
hljs.configure({
languages: []
});
// syntax highlighting after mathjax is loaded so that mathjax can be used in code blocks
MathJax.Hub.Queue(function () {
hljs.initHighlighting();
$("pre nobr").addClass("fixws");
})
$("#chapters a").each(function (index) {
if (document.location.pathname.endsWith($(this).attr("href")))
$(this).addClass("chapter-active");
else
$(this).removeClass("chapter-active");
});
|