#!/bin/bash function run_clean { latexmk -C if [ -f out/main.bbl ] then rm out/main.bbl fi if [ -f out/main.lol ] then rm out/main.lol fi if [ -f out/main.ptc ] then rm out/main.ptc fi if [ -f out/main.run.xml ] then rm out/main.run.xml fi if [ -f chapter/out.tex ] then rm chapter/out.md rm chapter/out.tex 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 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 } function run_latexmk { latexmk -quiet -latexoption="-shell-escape" -outdir=out main.tex } 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