Lint + Section Numebering

This commit is contained in:
Valentin Boettcher 2019-01-05 11:44:50 +01:00
parent 80961773cb
commit 48e9b292d7
3 changed files with 33 additions and 18 deletions

View file

@ -92,7 +92,7 @@ code.hl-highlighted .list.active {
font-size: 14px;
}
.toc li a {
text-decoration: none;
text-decoration: none;
}
.toc {
overflow-y: auto
@ -102,7 +102,9 @@ code.hl-highlighted .list.active {
position: relative
}
.toc>.toc-list li {
list-style: none
list-style: none;
padding-left: 1em;
text-indent: -1em;
}
.toc-list {
margin: 0;
@ -145,3 +147,11 @@ a.toc-link {
display: none;
}
}
body {
counter-reset: chapter;
}
h2::before {
counter-increment: chapter; /* Increment the value of section counter by 1 */
content: counters(chapter, '.') ' '; /* Display the value of section counter */
}

9
js/.eslintrc Normal file
View file

@ -0,0 +1,9 @@
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
},
"rules": {
"semi": 2
}
}

View file

@ -37,18 +37,6 @@ function createTOC() {
});
}
function wrapInner(parent, wrapper, attribute, attributevalue) {
if (typeof wrapper === "string") {
wrapper = document.createElement(wrapper);
}
var div = parent.appendChild(wrapper)
.setAttribute(attribute, attributevalue);
while (parent.firstChild !== wrapper) {
wrapper.appendChild(parent.firstChild);
}
}
function wrapInner(parent, wrapper, className) {
if (typeof wrapper === "string")
wrapper = document.createElement(wrapper);
@ -113,14 +101,22 @@ function setUpNav() {
});
}
loadChapters().then(newChapters => {
chapters = newChapters;
});
function setUpNumbering() {
let chapter = findCurrentChapter();
if (chapter >= 0) {
document.documentElement.style['counter-reset'] = 'chapter ' + (chapter + 1);
}
};
// Let's apply that stuff.
loadChapters().then(newChapters => {
chapters = newChapters;
setUpNumbering();
});
wrapPre();
HighlightLisp.highlight_auto();
HighlightLisp.paren_match();
createTOC();
setUpNav();