aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/tex2pdf57
1 files changed, 24 insertions, 33 deletions
diff --git a/bin/tex2pdf b/bin/tex2pdf
index 6d13513..d3b6270 100755
--- a/bin/tex2pdf
+++ b/bin/tex2pdf
@@ -1,16 +1,17 @@
-#!/usr/bin/env bash
+#!/usr/bin/bash
+
set -eu
initial_pwd=$(pwd)
filename=""
dirname=""
-mupdf_pid="0"
input_suffix=".tex"
probe_suffix="tex"
output_suffix=".pdf"
get_filename() {
- local base="$(basename "${1}")"
+ local base
+ base="$(basename "${1}")"
filename="${base%.*}"
}
@@ -28,38 +29,28 @@ probe_extension() {
}
probe_tools() {
- if [ ! -x /usr/bin/pdflatex ]; then
- echo "/usr/bin/pdflatex not available. Exiting..."
- exit 1
- fi
- if [ ! -x /usr/bin/bibtex ]; then
- echo "/usr/bin/bibtex not available. Exiting..."
- exit 1
- fi
- if [ ! -x /usr/bin/mupdf ]; then
- echo "/usr/bin/mupdf not available. Exiting..."
- exit 1
- fi
+ local tools=(
+ pdflatex
+ bibtex
+ mupdf
+ )
+ local tool
+
+ for tool in "${tools[@]}"; do
+ if ! command -v "$tool" > /dev/null; then
+ printf "%s not available. Exiting...\n" "$tool"
+ exit 1
+ fi
+ done
+
return 0
}
create_pdf() {
cd "${dirname}"
set +e
- pdflatex \
- -interaction=nonstopmode \
- -shell-escape \
- "${filename}${input_suffix}" > /dev/null
- bibtex "${filename}.aux"
- makeglossaries "${filename}"
- pdflatex \
- -interaction=nonstopmode \
- -shell-escape \
- "${filename}${input_suffix}" > /dev/null
- pdflatex \
- -interaction=nonstopmode \
- -shell-escape \
- "${filename}${input_suffix}"
+ xelatex -interaction=nonstopmode "${filename}${input_suffix}"
+ xelatex -interaction=nonstopmode "${filename}${input_suffix}"
set -e
cd "${initial_pwd}"
return 0
@@ -73,10 +64,10 @@ show_pdf() {
}
cleanup() {
- rm -f "${dirname}/"*.{acn,acr,alg,aux,bbl,bcf,blg,dvi,glg,glo,gls,glsdefs,idx,ist,lof,log,lol,lot,nav,out,run.xml,snm,toc,upa,upb,vrb,xdy} \
- "${dirname}/"*/*.{acn,acr,alg,aux,bbl,bcf,blg,dvi,glg,glo,gls,glsdefs,idx,ist,lof,log,lol,lot,nav,out,run.xml,snm,toc,upa,upb,vrb,xdy} \
- ./*.{acn,acr,alg,aux,bbl,bcf,blg,dvi,glg,glo,gls,glsdefs,idx,ist,lof,log,lol,lot,nav,out,run.xml,snm,toc,upa,upb,vrb,xdy} \
- ./*/*.{acn,acr,alg,aux,bbl,bcf,blg,dvi,glg,glo,gls,glsdefs,idx,ist,lof,log,lot,nav,out,run.xml,snm,toc,upa,upb,vrb,xdy}
+ rm -f "${dirname}/"*.{acn,acr,alg,aux,bbl,bcf,blg,dvi,glg,glo,gls,glsdefs,idx,ist,lof,lol,lot,nav,out,run.xml,snm,toc,upa,upb,vrb,xdy} \
+ "${dirname}/"*/*.{acn,acr,alg,aux,bbl,bcf,blg,dvi,glg,glo,gls,glsdefs,idx,ist,lof,lol,lot,nav,out,run.xml,snm,toc,upa,upb,vrb,xdy} \
+ ./*.{acn,acr,alg,aux,bbl,bcf,blg,dvi,glg,glo,gls,glsdefs,idx,ist,lof,lol,lot,nav,out,run.xml,snm,toc,upa,upb,vrb,xdy} \
+ ./*/*.{acn,acr,alg,aux,bbl,bcf,blg,dvi,glg,glo,gls,glsdefs,idx,ist,lof,lot,nav,out,run.xml,snm,toc,upa,upb,vrb,xdy}
}
render_diags() {