Skip to content

Commit b83ee48

Browse files
committed
TOC: Run through pandoc to pick up styling, moved into chapters folder
1 parent f65a8f4 commit b83ee48

File tree

4 files changed

+49
-10
lines changed

4 files changed

+49
-10
lines changed

scripts/createWebBook.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -400,18 +400,16 @@ def returnChapterByCommonName( commonName ):
400400
#print html
401401

402402

403-
#----------------------------------------------------- make TOC
403+
#----------------------------------------------------- make TOC content
404404

405405
soup = Soup()
406-
html = Tag(soup, None, "html")
407406
a = Tag(soup, None, "a")
408-
soup.append(html)
409407

410408
for c in chapterDicts:
411409
ul = Tag(soup, None, "ul")
412410
li = Tag(soup, None, "li")
413411
a = Tag(soup, None, "a");
414-
a['href'] = "chapters/" + c['path'] + ".html"
412+
a['href'] = c['path'] + ".html"
415413
a.string = c['title']
416414
li.append(a)
417415
ul.append(li)
@@ -431,16 +429,13 @@ def returnChapterByCommonName( commonName ):
431429
liInner.append(a);
432430
#print "\t" + tag
433431

434-
html.append(ul);
432+
soup.append(ul);
435433

436434
htmlOut = soup.prettify("utf-8")
437435
tocPath = os.path.join(webBookPath, "toc.html")
438436
with open(tocPath, "wb") as file:
439437
file.write(htmlOut)
440438

441-
442-
443-
444439
# <ul>
445440
# <li>Coffee</li>
446441
# <li>Tea
@@ -452,5 +447,24 @@ def returnChapterByCommonName( commonName ):
452447
# <li>Milk</li>
453448
# </ul>
454449

450+
#----------------------------------------------------- run pandoc for TOC
451+
452+
destTocPath = os.path.join(webBookPath, "chapters", "toc.html")
453+
sourceTocPath = os.path.join(webBookPath, "toc.html")
454+
455+
print "Converting", sourceTocPath, "to", destTocPath, "..."
456+
457+
subprocess.call(["pandoc", "-o", destTocPath, sourceTocPath,
458+
"-s", "-p",
459+
"--include-in-header=createWebBookTemplate/IncludeInHeader.html",
460+
"--include-before-body=createWebBookTemplate/IncludeBeforeBodyTOC.html",
461+
"--include-after-body=createWebBookTemplate/IncludeAfterBodyTOC.html"])
462+
463+
print "Removing", sourceTocPath, "..."
464+
os.remove(sourceTocPath)
465+
466+
467+
468+
455469

456470

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
</p>
2+
<div class="footer">
3+
<div id="prev_chapter"></div>
4+
<div id="next_chapter"></div>
5+
</div>
6+
<div id="help"><i>please note that this book / chapter is a work in progress. Feel free to suggest edits / corrections <a href="https://github.com/openframeworks/ofbook">here</a></i></div>
7+
</div>
8+
</div>
9+
</body>
10+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div class="banner">
2+
<div class="content-wrapper">
3+
<b>Work in progress!</b>
4+
This is a preliminary version of ofBook, a collaboratively written book about openFrameworks. Please post any issues, suggestions, comments on our <a href="https://github.com/openframeworks/ofBook/">repo</a>.
5+
</div>
6+
</div>
7+
8+
<div class="content-wrapper">
9+
<div class="chapter-content toc">
10+
<h1>Table of Contents</h1>
11+
<p>

static/style/style.scss

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,11 @@ a:active {
169169

170170
}
171171

172-
#chapters, #toc {
172+
#chapters {
173173
display:none;
174174
}
175175

176-
.chapter-content {
176+
.chapter-content, .toc {
177177
width: 734px;
178178
margin-top:70px;
179179
background-color: rgba(255,255,255,1);
@@ -367,6 +367,10 @@ a:active {
367367
}
368368
}
369369

370+
.toc {
371+
width: 980px;
372+
margin-left: 0px;
373+
}
370374

371375
#help {
372376
font-family: 'fira';

0 commit comments

Comments
 (0)