summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnailed <luca@snaile.de>2022-08-10 11:53:24 +0000
committerGitHub <noreply@github.com>2022-08-10 11:53:24 +0000
commitd92287afe0d055319ad7e3df95732be72d693d09 (patch)
treee06b9a2e42aa299d51c740ac611ccacd9b2473ab
parent606905268fb71a1c6f3b23ddcaab38886b2f2296 (diff)
downloadeibhear-d92287afe0d055319ad7e3df95732be72d693d09.tar.gz
eibhear-d92287afe0d055319ad7e3df95732be72d693d09.tar.zst
eibhear-d92287afe0d055319ad7e3df95732be72d693d09.zip
Parse tex root for more complex latex files
Allows parsing texroot comments so that you can compile a LaTeX document from outside of the document root, as long as it contains the usual magic comment format: % !TEX root = doc.tex
-rwxr-xr-x.local/bin/compiler2
1 files changed, 2 insertions, 0 deletions
diff --git a/.local/bin/compiler b/.local/bin/compiler
index 67992be..85a0c58 100755
--- a/.local/bin/compiler
+++ b/.local/bin/compiler
@@ -18,6 +18,8 @@ cd "$dir" || exit 1
textype() { \
command="pdflatex"
+ texroot=$(grep -Poi "^ *% *\! *tex root *= *\w+(?:\.\w*)?" "$file" | cut -d "=" -f 2 | tr -d "[:blank:]")
+ [ -n "$texroot" ] && base=$texroot && echo "Compiling from TeX root: $texroot"
( head -n5 "$file" | grep -qi 'xelatex' ) && command="xelatex"
$command --output-directory="$dir" "$base" &&
grep -qi addbibresource "$file" &&