| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# Require BASH 3 or newer |
| 4 |
|
| 5 |
REQUIRED_BASH_VERSION=3.0.0 |
| 6 |
|
| 7 |
if [[ $BASH_VERSION < $REQUIRED_BASH_VERSION ]]; then |
| 8 |
echo "You must use Bash version 3 or newer to run this script" |
| 9 |
exit |
| 10 |
fi |
| 11 |
|
| 12 |
# Canonicalise the source dir, allow this script to be called anywhere |
| 13 |
DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P) |
| 14 |
|
| 15 |
# DEFINE |
| 16 |
|
| 17 |
TARGET=target |
| 18 |
MASTER=cdi-spec.asciidoc |
| 19 |
|
| 20 |
OUTPUT_FORMATS=("xml" "epub" "pdf") |
| 21 |
#OUTPUT_FORMATS=("xml") |
| 22 |
OUTPUT_CMDS=("asciidoc -b docbook -o \${output_filename} \$MASTER" "a2x -f epub -D \$dir \$MASTER" "a2x --dblatex-opts \"-s custom-asciidoc-dblatex.sty -P latex.output.revhistory=0\" --backend-opts \"-f docbook45.conf\" -D \$dir \$MASTER") |
| 23 |
|
| 24 |
echo "** Building spec" |
| 25 |
|
| 26 |
echo "**** Cleaning $TARGET" |
| 27 |
rm -rf $TARGET |
| 28 |
mkdir -p $TARGET |
| 29 |
|
| 30 |
output_format=html |
| 31 |
dir=$TARGET/$output_format |
| 32 |
mkdir -p $dir |
| 33 |
|
| 34 |
echo "**** Processing $MASTER > $TARGET/cdi-spec.html" |
| 35 |
asciidoc -n -b html5 -a toc2 -a toclevels=3 -a pygments -f html5.conf -o $TARGET/cdi-spec.html $MASTER |
| 36 |
|
| 37 |
for ((i=0; i < ${#OUTPUT_FORMATS[@]}; i++)) |
| 38 |
do |
| 39 |
output_format=${OUTPUT_FORMATS[i]} |
| 40 |
dir=$TARGET |
| 41 |
output_filename=$dir/${MASTER//.asciidoc/.$output_format} |
| 42 |
mkdir -p $dir |
| 43 |
echo "**** Processing $MASTER > ${output_filename}" |
| 44 |
eval ${OUTPUT_CMDS[i]} |
| 45 |
done |
| 46 |
|