-
Notifications
You must be signed in to change notification settings - Fork 4
/
build-html.sh
76 lines (67 loc) · 1.98 KB
/
build-html.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
# PANDOC='pandoc'
# CROSSREF='pandoc-crossref'
if [ ! -f "./pandoc" ]; then
# Download Pandoc/Pandoc-crossref binaries
curl "https://yongfu.name/deps/pandoc.tar.xz" -O
tar xf pandoc.tar.xz
fi
IN="002-test.md"
OUT=${IN/%md/html}
# Get Chapter number
# arrIN=(${IN//-/ })
# let "CHAP=10#${arrIN[0]}"
# OFFSET=$(( $CHAP - 1 ))
# pandoc $IN -o appendix-A.html \
# --template chapter.html5
# Pass chapter toc to tocChapTmp.html
printf "index.html__" > chapter_index.txt
for IN in chapters/*.md; do
if [[ $(basename $IN) == 'denotations.md' ]]; then
continue
fi
OUT=${IN/%md/html}
fname=$(basename $OUT)
printf "${fname}__" >> chapter_index.txt
done
chaptoc=$(cat chapter_index.txt)
tocChaptmp=$(<deps/tocChap.html)
echo "${tocChaptmp//ANCHOR.TOCCHAP/$chaptoc}" > "tocChapTmp.html"
# Build index page
./pandoc setup.md chapters/denotations.md -o docs/index.html \
--from markdown+superscript+subscript \
--template deps/main.html5 \
-H deps/style.html \
-A tocChapTmp.html \
-A deps/after-body.html \
--mathjax
# Build chapters
for IN in chapters/*.md; do
fname=$(basename $IN)
if [[ "$fname" == 'denotations.md' ]]; then
continue
fi
OUT=${IN/%md/html}
fname=$(basename $OUT)
./pandoc setup.md $IN -o docs/$fname \
--from markdown+superscript+subscript \
--template deps/chapter.html5 \
-H deps/style.html \
-A tocChapTmp.html \
-A deps/after-body.html \
--lua-filter deps/lua/rmCiteSpace.lua \
-F ./pandoc-crossref \
--lua-filter deps/lua/insertTables.lua \
--lua-filter deps/lua/pandoc-ling.lua \
--lua-filter deps/lua/reference-title.lua \
--bibliography chapters/references.bib \
--citeproc \
--csl deps/citation-style.csl \
--mathjax
done
# Move files
[[ -d docs ]] || mkdir docs
# mv chapters/*.html docs/
cp -r chapters/figures docs/
touch docs/custom.css
# Clean up
rm tocChapTmp.html chapter_index.txt