52 modularized build script into functions and added possibility to have markdown appendices

This commit is contained in:
Dominik Becker 2021-04-15 13:26:54 +02:00
parent 76f9c8117f
commit e3b15a6c92
4 changed files with 88 additions and 21 deletions

View File

@ -1,4 +0,0 @@
%!TEX root = ../main.tex
\section{Example}
\label{app:example}

View File

@ -1,5 +1,7 @@
%!TEX root = ../main.tex
% input the appendix files here like this:
\input{appendix/01_example.tex}
\newpage
% \input{appendix/01_example.tex}
% \newpage
% when using markdown based appendices, they'll be generated to appendix/generated/${filename}.tex
% appendices need to be \sections!

View File

View File

@ -1,25 +1,94 @@
#!/bin/bash
# cleanup
latexmk -C
if [ -f chapter/out.tex ]
then
function run_clean {
latexmk -C
if [ -f main.bbl ]
then
rm main.bbl
fi
if [ -f main.lol ]
then
rm main.lol
fi
if [ -f main.ptc ]
then
rm main.ptc
fi
if [ -f main.run.xml ]
then
rm main.run.xml
fi
if [ -f chapter/out.tex ]
then
rm chapter/out.md
rm chapter/out.tex
fi
fi
shopt -s nullglob
for f in appendix/generated/*.tex
do
rm $f
done
}
function run_pandoc {
if [ -f chapter/out.tex ]
then
rm chapter/out.md
rm chapter/out.tex
fi
# run pandoc
if [ $1 == "pandoc" ]
then
cat chapter/*.md > chapter/out.md
pandoc --lua-filter templates/germanquotes.lua --citeproc --filter pandoc-crossref \
-M cref=true --top-level-division=chapter \
--bibliography library/library.bib --biblatex \
-o chapter/out.tex chapter/out.md
fi
}
# run latex build
if [ $1 != "clean" ]
then
function run_latexmk {
latexmk -latexoption="-shell-escape" main.tex
fi
}
function run_pandoc_appendix {
shopt -s nullglob
for f in appendix/generated/*.tex
do
rm $f
done
for f in appendix/*.md
do
filename=$(basename -- "$f")
filename="${filename%.*}"
pandoc --lua-filter templates/germanquotes.lua --citeproc --filter pandoc-crossref \
-M cref=true --top-level-division=chapter \
--bibliography library/library.bib --biblatex \
-o appendix/generated/$filename.tex appendix/$filename.md
done
}
case $1 in
"clean")
run_clean
;;
"pandoc")
run_pandoc
run_pandoc_appendix
run_latexmk
;;
"latex")
run_latexmk
;;
"appendix")
run_pandoc_appendix
;;
*)
echo $"Usage: $0 {clean|pandoc|latex}"
exit 1
esac