diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-01-09 04:10:24 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-01-09 04:10:24 +0000 |
commit | be157f353d01a7f4b22cffbf530ced2764036c7c (patch) | |
tree | 9fe25b3cc9aca3ed806bb4c7d0b7719c27cdd044 | |
parent | 4814b0ae021ed0e1389e8c124294b85bb81c1b29 (diff) | |
download | pandoc-be157f353d01a7f4b22cffbf530ced2764036c7c.tar.gz |
Changes to markdown2pdf.in:
+ Exit if pandoc fails (second time through) -- no need to store the log for this.
+ Run pdflatex up to three times, if needed to resolve references. Also
run bibtex as needed.
+ Minor reformatting.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@469 788f1e2b-df1e-0410-8736-df70ead52e1b
-rw-r--r-- | src/wrappers/markdown2pdf.in | 55 |
1 files changed, 36 insertions, 19 deletions
diff --git a/src/wrappers/markdown2pdf.in b/src/wrappers/markdown2pdf.in index ee7fa8cd4..e1ef9e344 100644 --- a/src/wrappers/markdown2pdf.in +++ b/src/wrappers/markdown2pdf.in @@ -10,7 +10,7 @@ SYNOPSIS="converts markdown-formatted text to PDF, using pdflatex." texname=output logfile=$THIS_TEMPDIR/log -pandoc -s -r markdown -w latex "$@" -o $THIS_TEMPDIR/$texname.tex 2>$logfile +pandoc -s -r markdown -w latex "$@" -o $THIS_TEMPDIR/$texname.tex || exit $? if [ "$OUTPUT" = "-" ]; then firstinfile="$(echo $ARGS | sed -ne '1p')" @@ -25,25 +25,42 @@ fi cd $THIS_TEMPDIR TEXINPUTS=$origdir:$TEXINPUTS: export TEXINPUTS - pdflatex -interaction=batchmode $texname.tex >/dev/null || { - errcode=$? - err "${THIS}: pdfLaTeX failed with error code $errcode" - [ -f $texname.log ] && { - err "${THIS}: error context:" - sed -ne '/^!/,/^[[:space:]]*$/p' \ - -ne '/^[Ll]a[Tt]e[Xx] [Ww]arning/,/^[[:space:]]*$/p' \ - -ne '/^[Ee]rror/,/^[[:space:]]*$/p' $texname.log >&2 - if grep -q "File \`ucs.sty' not found" $texname.log; then - err "${THIS}: Please install the 'unicode' package from CTAN:" - err " http://www.ctan.org/tex-archive/macros/latex/contrib/unicode/" - fi - if grep -q "File \`fancyvrb.sty' not found" $texname.log; then - err "${THIS}: Please install the 'fancyvrb' package from CTAN:" - err " http://www.ctan.org/tex-archive/macros/latex/contrib/fancyvrb/" - fi + finished=no + runs=0 + while [ $finished = "no" ]; do + pdflatex -interaction=batchmode $texname.tex >/dev/null || { + errcode=$? + err "${THIS}: pdfLaTeX failed with error code $errcode" + [ -f $texname.log ] && { + err "${THIS}: error context:" + sed -ne '/^!/,/^[[:space:]]*$/p' \ + -ne '/^[Ll]a[Tt]e[Xx] [Ww]arning/,/^[[:space:]]*$/p' \ + -ne '/^[Ee]rror/,/^[[:space:]]*$/p' $texname.log >&2 + if grep -q "File \`ucs.sty' not found" $texname.log; then + err "${THIS}: Please install the 'unicode' package from CTAN:" + err " http://www.ctan.org/tex-archive/macros/latex/contrib/unicode/" + fi + if grep -q "File \`fancyvrb.sty' not found" $texname.log; then + err "${THIS}: Please install the 'fancyvrb' package from CTAN:" + err " http://www.ctan.org/tex-archive/macros/latex/contrib/fancyvrb/" + fi + } + exit $errcode } - exit $errcode - } + if [ $runs -lt 3 ] && + grep -q "LaTeX Warning: There were undefined references." $texname.log; then + runs=$(($runs + 1)) + if grep -q "LaTeX Warning:.*[Cc]itation" $texname.log && + ! bibtex $texname >/dev/null 2>&1 >bibtex.err; then + if [ $runs -gt 2 ]; then + err "${THIS}: bibtex warning messages:" + cat bibtex.err + fi + fi + else + finished=yes + fi + done ) || exit $? is_target_exists= |