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

31 lines
713 B
Bash
Raw Permalink 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`
export INPUT_DIR=`dirname $INPUT_FILE`
2018-04-02 22:44:53 +01:00
METADATA_FILE="$INPUT_DIR/metadata.yaml"
2018-04-25 10:23:32 +01:00
export OUTPUT_FILE="$PWD/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-30 09:42:38 +01:00
PANDOC_ARGS="$INPUT_FILES --lua-filter=$SCRIPTPATH/variables.lua --template $SCRIPTPATH/main.tex --listings -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
2018-04-25 10:14:06 +01:00
echo "> Output to '$OUTPUT_FILE'"