1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
tex-template-builder/build.sh

29 lines
666 B
Bash
Raw Normal View History

#!/usr/bin/env bash
2018-04-25 09:58:31 +01:00
set -e
SCRIPT=`realpath $0`
SCRIPTPATH=`dirname $SCRIPT`
ADDITIONAL_ARGS=${@:2}
INPUT_FILE=`realpath $1`
2018-04-02 22:44:53 +01:00
INPUT_DIR=`dirname $INPUT_FILE`
METADATA_FILE="$INPUT_DIR/metadata.yaml"
2018-04-25 09:54:31 +01:00
export OUTPUT_FILE="$INPUT_DIR/output.pdf"
2018-04-02 22:44:53 +01:00
INPUT_FILES="$INPUT_FILE"
if [ -f "$METADATA_FILE" ]
then
INPUT_FILES="$INPUT_FILES $METADATA_FILE"
fi
2018-04-03 13:34:01 +01:00
PANDOC_ARGS="$INPUT_FILES --lua-filter=$SCRIPTPATH/variables.lua --template $SCRIPTPATH/main.tex -o $OUTPUT_FILE $ADDITIONAL_ARGS"
echo "> Building document..."
2018-04-03 13:48:04 +01:00
cd $SCRIPTPATH && pandoc $PANDOC_ARGS
echo "> Running second pass..."
2018-04-03 13:48:04 +01:00
cd $SCRIPTPATH && pandoc --lua-filter=$SCRIPTPATH/word-count.lua $PANDOC_ARGS