Skip to content

Commit 8eb8f3c

Browse files
committed
Add global TOC styling. Fixes #7
1 parent 45e2a4b commit 8eb8f3c

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ ADD script/md_file_tree.py /usr/local/src/toc.py
3030

3131
# HTML
3232
COPY html/template.html /usr/local/src/template.html
33+
COPY html/contents_template.html /usr/local/src/contents_template.html
3334
# CSS
3435
COPY css/style.css /usr/local/src/style.css
3536
# JS

css/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ nav a.right {
423423

424424
.toc ul {
425425
list-style-type: none;
426+
padding: 0;
426427
}
427428

428429
.toc li.uncollapsible {
@@ -481,7 +482,6 @@ nav a.right {
481482
.toc ul.content-inner {
482483
border-bottom-left-radius: 7px;
483484
border-bottom-right-radius: 7px;
484-
padding-left: 3rem;
485485
}
486486

487487
@keyframes highlight {

html/contents_template.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!doctype html>
2+
3+
<html lang="en">
4+
<head>
5+
<meta charset="utf-8">
6+
<title>___TITLE___</title>
7+
___CSS___
8+
___JS___
9+
</head>
10+
<body>
11+
<div class="toc">
12+
___BODY___
13+
</div>
14+
</body>
15+
</html>

js/script.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
document.addEventListener("DOMContentLoaded", function() {
2+
// COLLAPSIBLE TOC HANDLER
23
let external_lis = document.querySelectorAll('div.toc>ul li');
34
Array.from(external_lis).forEach(li => {
4-
55
li.classList.add("collapsed");
6-
console.log(Array.from(li.childNodes.values()))
7-
86
if (li.hasChildNodes() && Array.from(li.childNodes.values()).some(e => e.nodeType === 1 && e.nodeName == "UL")) {
97
li.classList.add("collapsible");
108
} else {
119
li.classList.add("uncollapsible");
1210
};
1311
});
14-
1512
let internal_uls = document.querySelectorAll('div.toc>ul li>ul');
1613
Array.from(internal_uls).forEach(ul => {
1714
ul.classList.add("collapsed-content");
@@ -21,7 +18,6 @@ document.addEventListener("DOMContentLoaded", function() {
2118
li.addEventListener("click",
2219
e => {
2320
e.stopPropagation();
24-
console.log("external");
2521
if (li.classList.contains("collapsed")) {
2622
li.classList.replace("collapsed", "visible");
2723
Array.from(li.children).forEach(ul => {
@@ -33,6 +29,7 @@ document.addEventListener("DOMContentLoaded", function() {
3329
ul.classList.replace("visible-content", "collapsed-content");
3430
});
3531
};
36-
})
32+
}
33+
);
3734
});
3835
});

script/try_convert.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ if [ -f "${SRC}${FILE}" ]; then
5656
cp "${DEST}${RESULTNAME}" "${TMP_DIR}${TMP_FILE}"
5757

5858
# Copy the html template to destination
59-
cp /usr/local/src/template.html "${DEST}${RESULTNAME}"
59+
if [ "${FILE}" = "contents.md" ] ; then
60+
cp /usr/local/src/contents_template.html "${DEST}${RESULTNAME}"
61+
else
62+
cp /usr/local/src/template.html "${DEST}${RESULTNAME}"
63+
fi
6064

6165
# Substitute strings
6266
sed -i "s/___CSS___/${ESCAPED_CSS}/g" "${DEST}${RESULTNAME}"

0 commit comments

Comments
 (0)