about summary refs log tree commit diff stats
path: root/compile.sh
blob: da7cc4b84bf02fd5411b8a8a97fe6a573439a1b5 (plain)
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
# for windows only right now

num=0
for file in src/*.txt; do # TODO: change this to work with globs & args & stuff
    echo -n "Compiling $file ..."
    pandoc -f markdown \
           -t html5 \
           --template=_template.html \
           --smart \
           --mathjax \
           $file \
           -o "${file%.txt}.html"
    echo " Done."
    ((num += 1))
done

echo
echo "Moving files to build directory ..."
mv src/*.html ./
echo "Finished compiling $num files."
###############################################
echo
echo "Adding class=\"external\" to external links ..."
sed -i 's,<a href="\(http://.*\)">,<a href="\1" class="external">,g' *.html
echo "Finished."
###############################################
echo
echo "Updating js/lozenge.js with file list ..."

lozengeList=( $(ls *.html | grep -v '\(_template\|loremipsum\|ipsumlorem\)') )

list=$(sed -e 's/\S\+\.html/"&",/g' -e 's/,$//' -e 's/^.*$/var files=[&]/' <<< "${lozengeList[@]}")

sed -i "s/var files=.*/$list/" js/lozenge.js

echo "Finished."