2020-01-15 19:04:42 -08:00
|
|
|
#!/bin/bash
|
2020-01-18 05:17:20 -08:00
|
|
|
|
2020-01-18 02:15:33 -08:00
|
|
|
PANDOC_PATH=/usr/bin/
|
2020-01-18 05:17:20 -08:00
|
|
|
for arg in "$@"
|
|
|
|
do
|
|
|
|
if [ "$arg" == "--local" ]
|
|
|
|
then
|
|
|
|
PANDOC_PATH=/home/pi/pandoc_src/bin/
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2020-01-15 19:04:42 -08:00
|
|
|
MAKEFILE=Makefile
|
2020-01-18 02:15:33 -08:00
|
|
|
WORKING_DIR=`pwd`
|
|
|
|
OUTPUT_FILENAME=${WORKING_DIR}'/offline/Speeduino_manual.pdf'
|
|
|
|
METADATA=${WORKING_DIR}'/offline/metadata.yaml'
|
|
|
|
DEFINITION=${WORKING_DIR}'/offline/std_manual.md'
|
|
|
|
BUILD='/tmp/book'
|
2020-06-17 18:07:14 -07:00
|
|
|
CHAPTERS=`tail -n +10 ${DEFINITION}`
|
2020-01-15 19:04:42 -08:00
|
|
|
IMAGES_FOLDER="img"
|
|
|
|
IMAGES=${IMAGES_FOLDER}/*
|
|
|
|
COVER_IMAGE=${IMAGES_FOLDER}/Speeduino\ logo.png
|
|
|
|
TEMPLATE=offline/eisvogel.tex
|
2020-01-16 16:39:01 -08:00
|
|
|
TEMPLATE_OPTIONS='--listings --toc --toc-depth=2'
|
|
|
|
ARGS="${TEMPLATE_OPTIONS} --template=${TEMPLATE}"
|
|
|
|
#ARGS="${TEMPLATE_OPTIONS}"
|
|
|
|
#PDF_ARGS="--pdf-engine=xelatex"
|
2020-01-18 05:17:20 -08:00
|
|
|
PDF_ARGS="-f markdown-markdown_in_html_blocks --pdf-engine=xelatex --metadata-file=${WORKING_DIR}/offline/metadata.yml"
|
|
|
|
METADATA_ARGS="--metadata date=`date +%D`"
|
2020-01-15 19:04:42 -08:00
|
|
|
|
|
|
|
#This contains all the fonts that might be needed
|
|
|
|
#sudo apt-get install texlive-fonts-extra
|
2020-01-16 16:39:01 -08:00
|
|
|
CUR_PATH=`pwd`
|
|
|
|
mkdir -p ${BUILD}
|
|
|
|
cd ${BUILD}
|
2020-01-18 02:15:33 -08:00
|
|
|
echo "Temp directory:" `pwd`
|
2020-01-16 16:39:01 -08:00
|
|
|
git clone --depth=1 https://github.com/speeduino/wiki.js.git
|
|
|
|
cd wiki.js
|
|
|
|
|
|
|
|
#Add a blank line on the top of each file to prevent issues with pandoc concatenation
|
|
|
|
for f in ${CHAPTERS}
|
|
|
|
do
|
|
|
|
sed -s -i '1i\\' $f
|
|
|
|
done
|
|
|
|
|
|
|
|
|
2020-01-19 21:50:27 -08:00
|
|
|
echo ${PANDOC_PATH}pandoc ${ARGS} ${METADATA_ARGS} ${PDF_ARGS} -o ${OUTPUT_FILENAME} ${CHAPTERS}
|
|
|
|
${PANDOC_PATH}pandoc ${ARGS} ${METADATA_ARGS} ${PDF_ARGS} -o ${OUTPUT_FILENAME} ${CHAPTERS}
|
2020-01-16 16:39:01 -08:00
|
|
|
|
|
|
|
#Copy the produced PDF back to the main directory
|
2020-01-18 02:15:33 -08:00
|
|
|
#cp ${OUTPUT_FILENAME} ${CUR_PATH}/offline
|
2020-01-15 19:04:42 -08:00
|
|
|
# @echo "$@ was built"
|
|
|
|
|
2020-01-16 16:39:01 -08:00
|
|
|
|
|
|
|
#Cleanup
|
|
|
|
cd ${CUR_PATH}
|
2020-01-18 02:15:33 -08:00
|
|
|
rm -rf ${BUILD}
|