compiler simplified

This commit is contained in:
Luke Smith 2018-07-25 12:14:38 -04:00
parent 4f62fed283
commit 5fc6f74598

View file

@ -3,29 +3,30 @@
# This is a compilation handler, so to speak, which I have vim run. # This is a compilation handler, so to speak, which I have vim run.
# #
# It compiles a document to pdf # 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") file=$(readlink -f "$1")
ext="${file##*.}" ext="${file##*.}"
base="${file%.*}" base="${file%.*}"
textype() { [ grep -i addbibresource "$file" ] && bib=1 textype() { \
command="pdflatex"
if sed 5q "$file" | grep -i -q 'xelatex' > /dev/null 2>&1; then ( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex"
[ -z ${bib+x} ] || (xelatex "$base" && break) $command "$base" &&
xelatex "$base" && grep -i addbibresource "$file" &&
biber "$base" && biber "$base" &&
xelatex "$base" && $command "$base" &&
xelatex "$base" $command "$base"
else }
[ -z ${bib+x} ] || (pdflatex "$base" && break)
pdflatex "$base" &&
biber "$base" &&
pdflatex "$base" &&
pdflatex "$base"
fi ;}
case "$ext" in case "$ext" in
rmd) echo "require(rmarkdown); render('$file')" | R --vanilla ;; rmd) echo "require(rmarkdown); render('$file')" | R --vanilla ;;
tex) textype "$file" ;; tex) textype "$file" ;;
md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;; md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;;
*) sent "$file" 2>/dev/null & ;;
esac esac