Skip to content

Commit 6b5c107

Browse files
committed
Merge pull request #115 from mattfelsen/master
TOC: Run through pandoc to pick up styling, moved into chapters folder
2 parents cd05e7d + b83ee48 commit 6b5c107

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
@@ -176,11 +176,11 @@ a:active {
176176

177177
}
178178

179-
#chapters, #toc {
179+
#chapters {
180180
display:none;
181181
}
182182

183-
.chapter-content {
183+
.chapter-content, .toc {
184184
width: 734px;
185185
margin-top:70px;
186186
background-color: rgba(255,255,255,1);
@@ -374,6 +374,10 @@ a:active {
374374
}
375375
}
376376

377+
.toc {
378+
width: 980px;
379+
margin-left: 0px;
380+
}
377381

378382
#help {
379383
font-family: 'fira';

0 commit comments

Comments
 (0)