separate script for use in opout, use just % root=
This commit is contained in:
parent
1a37b0bc99
commit
b82b091d96
3 changed files with 21 additions and 9 deletions
|
@ -17,15 +17,15 @@ ext="${file##*.}"
|
||||||
cd "$dir" || exit 1
|
cd "$dir" || exit 1
|
||||||
|
|
||||||
textype() { \
|
textype() { \
|
||||||
|
textarget="$(getcomproot "$file" || echo "$file")"
|
||||||
|
echo "$textarget"
|
||||||
command="pdflatex"
|
command="pdflatex"
|
||||||
texroot=$(grep -Poi "^ *% *\! *tex root *= *\w+(?:\.\w*)?" "$file" | cut -d "=" -f 2 | tr -d "[:blank:]")
|
( head -n5 "$textarget" | grep -qi 'xelatex' ) && command="xelatex"
|
||||||
[ -n "$texroot" ] && base=$texroot && echo "Compiling from TeX root: $texroot"
|
$command --output-directory="${textarget%/*}" "${textarget%.*}"
|
||||||
( head -n5 "$file" | grep -qi 'xelatex' ) && command="xelatex"
|
grep -qi addbibresource "$textarget" &&
|
||||||
$command --output-directory="$dir" "$base" &&
|
biber --input-directory "${textarget%/*}" "${textarget%.*}" &&
|
||||||
grep -qi addbibresource "$file" &&
|
$command --output-directory="${textarget%/*}" "${textarget%.*}" &&
|
||||||
biber --input-directory "$dir" "$base" &&
|
$command --output-directory="${textarget%/*}" "${textarget%.*}"
|
||||||
$command --output-directory="$dir" "$base" &&
|
|
||||||
$command --output-directory="$dir" "$base"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$ext" in
|
case "$ext" in
|
||||||
|
|
12
.local/bin/getcomproot
Executable file
12
.local/bin/getcomproot
Executable file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# A helper script for LaTeX/groff files used by `compiler` and `opout`.
|
||||||
|
# The user can add the root file of a larger project as a comment as below:
|
||||||
|
# % root = mainfile.tex
|
||||||
|
# And the compiler script will run on that instead of the opened file.
|
||||||
|
|
||||||
|
texroot="$(grep -i "^.\+\s*root\s*=\s*\S\+" "$1")"
|
||||||
|
texroot="${texroot##*=}"
|
||||||
|
texroot="${texroot//[\"\' ]}"
|
||||||
|
|
||||||
|
[ -f "$texroot" ] && readlink -f "$texroot" || exit 1
|
|
@ -7,7 +7,7 @@
|
||||||
basename="${1%.*}"
|
basename="${1%.*}"
|
||||||
|
|
||||||
case "${*}" in
|
case "${*}" in
|
||||||
*.tex|*.m[dse]|*.[rR]md|*.mom|*.[0-9]) setsid -f xdg-open "$basename".pdf >/dev/null 2>&1 ;;
|
*.tex|*.m[dse]|*.[rR]md|*.mom|*.[0-9]) target="$(getcomproot "$1" || echo "$1")" ; setsid -f xdg-open "${target%.*}".pdf >/dev/null 2>&1 ;;
|
||||||
*.html) setsid -f "$BROWSER" "$basename".html >/dev/null 2>&1 ;;
|
*.html) setsid -f "$BROWSER" "$basename".html >/dev/null 2>&1 ;;
|
||||||
*.sent) setsid -f sent "$1" >/dev/null 2>&1 ;;
|
*.sent) setsid -f sent "$1" >/dev/null 2>&1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in a new issue