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