@@ -9,7 +9,6 @@ SYNOPSIS="converts markdown-formatted text to PDF, using pdflatex."
99
1010texname=output
1111logfile=$THIS_TEMPDIR/log
12−origdir=$(pwd)
1312
1413pandoc -s -r markdown -w latex "$@" -o - >$THIS_TEMPDIR/$texname.tex \
15142>$logfile
@@ -23,23 +22,27 @@ else
2322fi
2423
2524(
25+ origdir=$(pwd)
2626 cd $THIS_TEMPDIR
27− TEXINPUTS=$TEXINPUTS:$origdir pdflatex -interaction=batchmode \
28− $texname.tex >/dev/null 2>&1 || {
29− errorcode=$?
30− err "${THIS}: pdfLaTeX error context:"
31− sed -ne '/^!/,/^[[:space:]]*$/p' \
32− -ne '/^[Ll]a[Tt]e[Xx] [Ww]arning/,/^[[:space:]]*$/p' \
33− -ne '/^[Ee]rror/,/^[[:space:]]*$/p' $texname.log >&2
34− if grep -q "File \`ucs.sty' not found" $texname.log; then
35− err "${THIS}: Please install the 'unicode' package from CTAN:"
36− err " http://www.ctan.org/tex-archive/macros/latex/contrib/unicode/"
37− fi
38− if grep -q "File \`fancyvrb.sty' not found" $texname.log; then
39− err "${THIS}: Please install the 'fancyvrb' package from CTAN:"
40− err " http://www.ctan.org/tex-archive/macros/latex/contrib/fancyvrb/"
41− fi
42− exit $errorcode
27+ TEXINPUTS=$origdir:$TEXINPUTS:
28+ pdflatex -interaction=batchmode $texname.tex >/dev/null || {
29+ errcode=$?
30+ err "${THIS}: pdfLaTeX failed with error code $errcode"
31+ [ -f $texname.log ] && {
32+ err "${THIS}: error context:"
33+ sed -ne '/^!/,/^[[:space:]]*$/p' \
34+ -ne '/^[Ll]a[Tt]e[Xx] [Ww]arning/,/^[[:space:]]*$/p' \
35+ -ne '/^[Ee]rror/,/^[[:space:]]*$/p' $texname.log >&2
36+ if grep -q "File \`ucs.sty' not found" $texname.log; then
37+ err "${THIS}: Please install the 'unicode' package from CTAN:"
38+ err " http://www.ctan.org/tex-archive/macros/latex/contrib/unicode/"
39+ fi
40+ if grep -q "File \`fancyvrb.sty' not found" $texname.log; then
41+ err "${THIS}: Please install the 'fancyvrb' package from CTAN:"
42+ err " http://www.ctan.org/tex-archive/macros/latex/contrib/fancyvrb/"
43+ fi
44+ }
45+ exit $errcode
4346 }
4447) || exit $?
4548