-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.sh
36 lines (30 loc) · 1.06 KB
/
build.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
set -x -e
mkdir -p tmp
# Build navigation
pandoc -f markdown -t html SUMMARY.md | \
sed -e 's|\.md|.html|' > book/SUMMARY.html
echo '[' > tmp/documents.json
for file in $(ls -1 pages); do
echo $file
title=$(egrep --max-count=1 '^# ' pages/$file | tail -c +3)
# Build JSON documents for indexing
tr \" \' < pages/$file | tr -d "[:punct:]" | \
pandoc -f gfm \
-t plain \
-V url="$(basename $file .md).html" \
-V pagetitle="$title" \
--template template.json - | tr "\n" " " >> tmp/documents.json
# Build web pages
# TODO: level should be taken from SUMMARY
pandoc -f gfm+smart \
-t html \
-V level="1.1" \
-V navigation="$(cat book/SUMMARY.html)" \
-V pagetitle="$title" \
-o "book/$(basename $file .md).html" \
--template template.html pages/$file
done
echo '{}]' >> tmp/documents.json
cp book/README.html book/index.html
node bake-index.js < tmp/documents.json > book/search_index.json
rm tmp/documents.json