-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
trinketbook.sh
executable file
·43 lines (34 loc) · 1.19 KB
/
trinketbook.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# Testfile
#cat trinket/test | python verbatim.py --trinket | pandoc -s -f markdown -t html --template=trinket/template --toc --default-image-extension=svg --css=../trinket/simplegrid.css -o html/test.html
# Clean directory
find trinket/pfe/. -type f -not -name 'figs2' | xargs rm
# Make a symlink to figs
#(cd html && ln -s ../figs2/)
OUTPUTDIR='trinket/pfe'
# Convert all mkd into html
CHAPTER=1
for fn in *.mkd; do
echo "the next file is $fn"
x=`basename $fn .mkd`
cat $fn | \
python pre-html.py | \
tee tmp.html.pre.$x | \
python verbatim.py --trinket --files | \
tee tmp.html.verbatim.$x | \
python consoles.py | \
pandoc -s --self-contained \
-f markdown -t html \
--template=trinket/nunjucks \
--toc \
--default-image-extension=svg \
-o $OUTPUTDIR/$x.html
# Post-process the TOC
python trinket/buildtoc.py $OUTPUTDIR/$x.html
# Add in extra CSS for syntax highlighting
cat trinket/highlight.html >> $OUTPUTDIR/$x.html
# Add chapter title
echo -e "\n\n{% block title %}Chapter $CHAPTER | Python For Everyone | Trinket{% endblock %}" >> $OUTPUTDIR/$x.html
CHAPTER=$((CHAPTER+1))
done
rm tmp.*