forked from csev/py4e
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zipbook.sh
executable file
·76 lines (62 loc) · 1.96 KB
/
zipbook.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/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
# Pick your Python
MY_PYTHON=python
if which python3; then
MY_PYTHON=python3
fi
echo Using python command: $MY_PYTHON
# Clean directory
find zipbook/. -type f -not -path '*/images/*' -not -path '*/fonts/*' | xargs rm
# Add in css file
dirnames=("embeds" "offline")
for dir in "${dirnames[@]}"; do
echo $dir
cp trinket/base.css trinket/*.js trinket/trinket.css trinket/font-awesome.min.css trinket/fontawesome-webfont.woff2 zipbook/$dir/trinket
cp trinket/index.html trinket/README.md zipbook/$dir
done
# Make a symlink to figs
#(cd html && ln -s ../figs2/)
# Convert all mkd into html
for fn in *.mkd; do
echo "the next file is $fn"
x=`basename $fn .mkd`
echo $x
cat $fn | \
$MY_PYTHON pre-html.py | \
tee tmp.html.pre.$x | \
$MY_PYTHON verbatim.py --trinket --files | \
tee tmp.html.verbatim.$x | \
pandoc -s \
-f markdown -t html \
--template=trinket/offline \
--toc \
--default-image-extension=svg \
-o zipbook/offline/$x.html \
&& echo "Wrote zipbook/offline/$x.html"
cat $fn | \
$MY_PYTHON pre-html.py | \
tee tmp.html.pre.$x | \
$MY_PYTHON verbatim.py --trinket --files | \
tee tmp.html.verbatim.$x | \
$MY_PYTHON consoles3.py | \
pandoc -s \
-f markdown -t html \
--template=trinket/zip \
--toc \
--default-image-extension=svg \
-o zipbook/embeds/$x.html \
&& echo "Wrote zipbook/embeds/$x.html"
done
# Make the zip
rm zips/pfe.zip
zip -r9 zips/pfe.zip zipbook && echo "Wrote zips/pfe.zip"
# Updating ../trinket3
[[ -d ../trinket3 ]] || mkdir ../trinket3
rm ../trinket3/[0-9]*.html
cp -r zipbook/embeds/* ../trinket3
rm tmp.*
echo
echo Cleaning up zipbook folder
find zipbook/. -type f -not -path '*/images/*' -not -path '*/fonts/*' | xargs rm