manuals/build-pandoc.sh

78 lines
1.4 KiB
Bash
Raw Normal View History

#!/bin/sh
2021-07-26 13:11:23 +00:00
2021-08-25 15:46:54 +00:00
set -e
2021-07-26 13:11:23 +00:00
# enter the current directory
cd "$(dirname $0)"
export PANDOC_DIR=pandoc/cl
if [ -z $1 ]; then
export target=pdf
else
export target=$1
fi
2021-08-25 15:46:54 +00:00
if [ -z $2 ]; then
export kind=user
else
export kind=$2
fi
if [ $kind = 'user' ]; then
export files="
2022-03-11 13:44:33 +00:00
$kind/person.md
2022-03-16 20:39:18 +00:00
$kind/person-vendee.md
2022-03-14 21:09:24 +00:00
$kind/activite.md
2022-03-16 16:01:20 +00:00
$kind/document.md
2022-03-15 10:29:01 +00:00
$kind/thirdparty.md
2021-08-25 15:46:54 +00:00
$kind/parcours.md
2022-03-15 17:07:59 +00:00
$kind/menage.md
2022-03-16 15:07:28 +00:00
$kind/notifications.md
2022-03-11 16:30:20 +00:00
$kind/choisir_une_adresse.md
2021-08-25 15:46:54 +00:00
"
elif [ $kind = 'admin' ]; then
export files="
$kind/generation-documents.md
"
2022-03-11 13:44:33 +00:00
else
2021-08-25 15:46:54 +00:00
echo "kind '$kind' is not valid";
exit 1;
fi
2021-07-26 13:11:23 +00:00
export ARGS="
--from markdown
2021-08-25 15:46:54 +00:00
--metadata-file ./$kind/metadata.yaml
2021-07-26 13:11:23 +00:00
--lua-filter "${PANDOC_DIR}/format-link.lua"
"
export PDF_TEMPLATE="./pandoc/template/eisvogel.tex"
export LATEX_ARGS="
--template "${PDF_TEMPLATE}"
--lua-filter "${PANDOC_DIR}/boxes.lua"
"
2021-08-25 15:46:54 +00:00
if [ $target = "latex" ]; then
2021-07-26 13:11:23 +00:00
pandoc $ARGS $LATEX_ARGS \
--to latex \
$files;
2021-08-25 15:46:54 +00:00
elif [ $target = "pdf" ]; then
2021-07-26 13:11:23 +00:00
pandoc $ARGS $LATEX_ARGS \
--to pdf \
--pdf-engine xelatex \
2021-08-25 15:46:54 +00:00
-o "./$kind-manual.pdf" \
2021-07-26 13:11:23 +00:00
$files
2021-08-25 15:46:54 +00:00
elif [ $target = "html" ]; then
2021-07-26 13:11:23 +00:00
# check target directory exists
if [ ! -d "./build/html" ]; then
echo "create build/html directory"
mkdir -p "./build/html"
fi
pandoc $ARGS \
--to html \
-o ./build/html/index.html \
$files
fi