dotfiles

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 5fc6f7459844c6c378c303d380eb52a5945c27fa
parent 4f62fed2833caf9bdbe21472b033d482e9ad8974
Author: Luke Smith <luke@lukesmith.xyz>
Date:   Wed, 25 Jul 2018 12:14:38 -0400

compiler simplified

Diffstat:
M.scripts/compiler | 29+++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/.scripts/compiler b/.scripts/compiler @@ -3,29 +3,30 @@ # This is a compilation handler, so to speak, which I have vim run. # # It compiles a document to pdf +# +# If you put the sequence `xelatex` somewhere in the first 5 lines of a .tex +# file, it will be compiled with `xelatex` rather than `pdflatex`. +# +# If it detects an `addbibresource` line, it will run `biber` and perform +# multiple compiles to get the references correct. file=$(readlink -f "$1") ext="${file##*.}" base="${file%.*}" -textype() { [ grep -i addbibresource "$file" ] && bib=1 - -if sed 5q "$file" | grep -i -q 'xelatex' > /dev/null 2>&1; then - [ -z ${bib+x} ] || (xelatex "$base" && break) - xelatex "$base" && - biber "$base" && - xelatex "$base" && - xelatex "$base" -else - [ -z ${bib+x} ] || (pdflatex "$base" && break) - pdflatex "$base" && +textype() { \ + command="pdflatex" + ( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex" + $command "$base" && + grep -i addbibresource "$file" && biber "$base" && - pdflatex "$base" && - pdflatex "$base" -fi ;} + $command "$base" && + $command "$base" + } case "$ext" in rmd) echo "require(rmarkdown); render('$file')" | R --vanilla ;; tex) textype "$file" ;; md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;; + *) sent "$file" 2>/dev/null & ;; esac