git.iko.soy/typeable/pandoc
on master help sign in
Changes to markdown2pdf.in:
be157f3fiddlosopher
src/wrappers/markdown2pdf.in+36−19
@@ -10,7 +10,7 @@ SYNOPSIS="converts markdown-formatted text to PDF, using pdflatex."
10texname=output
10texname=output
11logfile=$THIS_TEMPDIR/log
11logfile=$THIS_TEMPDIR/log
12
12
13−pandoc -s -r markdown -w latex "$@" -o $THIS_TEMPDIR/$texname.tex 2>$logfile
13+pandoc -s -r markdown -w latex "$@" -o $THIS_TEMPDIR/$texname.tex || exit $?
14
14
15if [ "$OUTPUT" = "-" ]; then
15if [ "$OUTPUT" = "-" ]; then
16 firstinfile="$(echo $ARGS | sed -ne '1p')"
16 firstinfile="$(echo $ARGS | sed -ne '1p')"
@@ -25,25 +25,42 @@ fi
25 cd $THIS_TEMPDIR
25 cd $THIS_TEMPDIR
26 TEXINPUTS=$origdir:$TEXINPUTS:
26 TEXINPUTS=$origdir:$TEXINPUTS:
27 export TEXINPUTS
27 export TEXINPUTS
28+ finished=no
29+ runs=0
30+ while [ $finished = "no" ]; do
28− pdflatex -interaction=batchmode $texname.tex >/dev/null || {
31+ pdflatex -interaction=batchmode $texname.tex >/dev/null || {
29− errcode=$?
32+ errcode=$?
30− err "${THIS}: pdfLaTeX failed with error code $errcode"
33+ err "${THIS}: pdfLaTeX failed with error code $errcode"
31− [ -f $texname.log ] && {
34+ [ -f $texname.log ] && {
32− err "${THIS}: error context:"
35+ err "${THIS}: error context:"
33− sed -ne '/^!/,/^[[:space:]]*$/p' \
36+ sed -ne '/^!/,/^[[:space:]]*$/p' \
34− -ne '/^[Ll]a[Tt]e[Xx] [Ww]arning/,/^[[:space:]]*$/p' \
37+ -ne '/^[Ll]a[Tt]e[Xx] [Ww]arning/,/^[[:space:]]*$/p' \
35− -ne '/^[Ee]rror/,/^[[:space:]]*$/p' $texname.log >&2
38+ -ne '/^[Ee]rror/,/^[[:space:]]*$/p' $texname.log >&2
36− if grep -q "File \`ucs.sty' not found" $texname.log; then
39+ if grep -q "File \`ucs.sty' not found" $texname.log; then
37− err "${THIS}: Please install the 'unicode' package from CTAN:"
40+ err "${THIS}: Please install the 'unicode' package from CTAN:"
38− err " http://www.ctan.org/tex-archive/macros/latex/contrib/unicode/"
41+ err " http://www.ctan.org/tex-archive/macros/latex/contrib/unicode/"
39− fi
42+ fi
40− if grep -q "File \`fancyvrb.sty' not found" $texname.log; then
43+ if grep -q "File \`fancyvrb.sty' not found" $texname.log; then
41− err "${THIS}: Please install the 'fancyvrb' package from CTAN:"
44+ err "${THIS}: Please install the 'fancyvrb' package from CTAN:"
42− err " http://www.ctan.org/tex-archive/macros/latex/contrib/fancyvrb/"
45+ err " http://www.ctan.org/tex-archive/macros/latex/contrib/fancyvrb/"
43− fi
46+ fi
47+ }
48+ exit $errcode
44 }
49 }
45− exit $errcode
50+ if [ $runs -lt 3 ] &&
46− }
51+ grep -q "LaTeX Warning: There were undefined references." $texname.log; then
52+ runs=$(($runs + 1))
53+ if grep -q "LaTeX Warning:.*[Cc]itation" $texname.log &&
54+ ! bibtex $texname >/dev/null 2>&1 >bibtex.err; then
55+ if [ $runs -gt 2 ]; then
56+ err "${THIS}: bibtex warning messages:"
57+ cat bibtex.err
58+ fi
59+ fi
60+ else
61+ finished=yes
62+ fi
63+ done
47) || exit $?
64) || exit $?
48
65
49is_target_exists=
66is_target_exists=