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; font-size: 14px;
} }
.toc li a { .toc li a {
text-decoration: none; text-decoration: none;
} }
.toc { .toc {
overflow-y: auto overflow-y: auto
@ -102,7 +102,9 @@ code.hl-highlighted .list.active {
position: relative position: relative
} }
.toc>.toc-list li { .toc>.toc-list li {
list-style: none list-style: none;
padding-left: 1em;
text-indent: -1em;
} }
.toc-list { .toc-list {
margin: 0; margin: 0;
@ -145,3 +147,11 @@ a.toc-link {
display: none; 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) { function wrapInner(parent, wrapper, className) {
if (typeof wrapper === "string") if (typeof wrapper === "string")
wrapper = document.createElement(wrapper); wrapper = document.createElement(wrapper);
@ -113,14 +101,22 @@ function setUpNav() {
}); });
} }
function setUpNumbering() {
loadChapters().then(newChapters => { let chapter = findCurrentChapter();
chapters = newChapters; if (chapter >= 0) {
}); document.documentElement.style['counter-reset'] = 'chapter ' + (chapter + 1);
}
};
// Let's apply that stuff. // Let's apply that stuff.
loadChapters().then(newChapters => {
chapters = newChapters;
setUpNumbering();
});
wrapPre(); wrapPre();
HighlightLisp.highlight_auto(); HighlightLisp.highlight_auto();
HighlightLisp.paren_match(); HighlightLisp.paren_match();
createTOC(); createTOC();
setUpNav(); setUpNav();