doccomp (517B)
1 #!/bin/sh 2 3 usage() 4 { 5 echo "usage: ${0##*/} file" 1>&2 && exit 1 6 } 7 8 file_exists() 9 { 10 test ! -f "${file}" && echo "${0##*/}: ${file}: file not found" 1>&2 && exit 1 11 } 12 13 test ${#} -eq 0 && usage 14 15 file="$(readlink -f "${1}")" 16 dir="${file%/*}" 17 base="${file%.*}" 18 ext="${file##*.}" 19 20 file_exists 21 cd "${dir}" || exit 1 22 23 case "${ext}" in 24 md) pandoc ${file} \ 25 --pdf-engine=xelatex \ 26 -V mainfont=Arial \ 27 -o "${base}.pdf" ;; 28 tex) pdflatex ${file} 29 rm -f *.aux *.log *.out *.bcf *.run.xml *.bbl *.blg *-blx.bib ;; 30 esac