-
Notifications
You must be signed in to change notification settings - Fork 27
/
build_orig.sh
executable file
·71 lines (55 loc) · 2.04 KB
/
build_orig.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
#!/bin/sh
declare -r BASE_DIR=`dirname $0`
declare -r OUT_DIR=$BASE_DIR/out
declare -r ASSETS_DIR=images
# ================
# Helper functions
# ================
function convert()
{
# echo -e "\t$@"
local src_file=$@
# asciidoctor --trace -v \
asciidoctor \
-d book \
-b html5 \
-a stylesheet=stylesheets/asciidoctor.css \
-a linkcss! \
-a icons=font \
-a source-highlighter=highlightjs \
-a toc \
-a toc2 \
-a toclevels=3 \
-a toc=right \
-a idprefix! \
-a idseparator=- \
-a sectanchors \
--compact \
-D $OUT_DIR \
$src_file
}
function makeDir()
{
local target_dir=$1
# create output dir if it doesn't exist
if [ ! -d "$target_dir" ]; then
mkdir -p $target_dir
fi
}
# ===================
# Main flow execution
# ===================
# set -ex
if [ "$1" = "html" ]; then
echo Building book...
makeDir $OUT_DIR
# list all asciidoc files in the DOCS_DIR
adoc_files=(./Chapter_1.adoc ./Chapter_2.adoc ./Chapter_3.adoc ./Chapter_4.adoc ./Chapter_5.adoc ./Chapter_6.adoc ./Chapter_7.adoc ./Chapter_8.adoc ./Chapter_9.adoc ./Chapter_10.adoc ./Chapter_11.adoc ./Chapter_12.adoc ./Chapter_13.adoc ./Appendix_A.adoc)
# adoc_files=(./thewholebook.adoc )
convert `printf "%s " "${adoc_files[@]}" | cut -d " " -f 1-${#adoc_files[@]}`
asciidoctor -d book -b html5 -a stylesheet=stylesheets/asciidoctor.css --out-file out/index.html toc.adoc
elif [ "$1" = "clean" ]; then
echo Cleaning files:
rm -rv $OUT_DIR
fi
echo -e "BUILD FINISHED"