diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-01-08 19:55:34 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-01-08 19:55:34 +0000 |
commit | 58697ebe785b1f7eb4713d8874cd5aaae4d6a03b (patch) | |
tree | bc3a3c8f9c360cb3a6d31e58188aa78761dbee56 /src/wrappers/markdown2pdf.in | |
parent | 9eafa971568aa522dcdc798a566069887eee5d30 (diff) | |
download | pandoc-58697ebe785b1f7eb4713d8874cd5aaae4d6a03b.tar.gz |
Modified shell scripts to use new Pandoc --dump-args and
--ignore-args features. This allows a simpler, cleaner design.
Make use of TEXINPUTS environment variable to ensure that
pdflatex will find images and other sources in the working
directory from which markdown2pdf is called.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@456 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/wrappers/markdown2pdf.in')
-rw-r--r-- | src/wrappers/markdown2pdf.in | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/wrappers/markdown2pdf.in b/src/wrappers/markdown2pdf.in index 90c5e6bb1..aaae07184 100644 --- a/src/wrappers/markdown2pdf.in +++ b/src/wrappers/markdown2pdf.in @@ -1,6 +1,7 @@ #!/bin/sh -e REQUIRED="pdflatex" +SYNOPSIS="converts markdown-formatted text to PDF, using pdflatex." ### common.sh @@ -8,27 +9,25 @@ REQUIRED="pdflatex" texname=output logfile=$THIS_TEMPDIR/log +origdir=$(pwd) -if ! pandoc -s -d -r markdown -w latex "$@" >$THIS_TEMPDIR/$texname.tex \ -2>$logfile; then - [ -f $logfile ] && sed -e 's/^pandoc/markdown2pdf/g' \ - -e '/^INPUT=/d' -e '/^OUTPUT=/d' \ - -e '/^[[:space:]]*\(-f\|-t\|-s\|-R\|-S\|-m\|-i\|-c\|-T\|-D\|-d\)/,/./d'\ - -e 's/(implies -s)//g' $logfile >&2 - exit 1 -fi +pandoc -s -r markdown -w latex "$@" -o - >$THIS_TEMPDIR/$texname.tex \ +2>$logfile -outfile="$(sed -ne 's/^OUTPUT=//p' $logfile)" -IFS="$NEWLINE" -set -- $(sed -ne 's/^INPUT=//p' $logfile) -firstinfilebase="${1%.*}" -defaultdest="${firstinfilebase:-stdin}.pdf" -destname="${outfile:-$defaultdest}" +if [ "$OUTPUT" = "-" ]; then + firstinfile="$(echo $ARGS | sed -ne '1p')" + firstinfilebase="${firstinfile%.*}" + destname="${firstinfilebase:-stdin}.pdf" +else + destname="$OUTPUT" +fi ( cd $THIS_TEMPDIR - if ! pdflatex -interaction=batchmode $texname.tex >/dev/null 2>&1; then - err "${THIS}: pdfLaTeX error context:" + TEXINPUTS=$TEXINPUTS:$origdir pdflatex -interaction=batchmode \ + $texname.tex >/dev/null 2>&1 || { + errorcode=$? + err "${THIS}: pdfLaTeX error context:" sed -ne '/^!/,/^[[:space:]]*$/p' \ -ne '/^[Ll]a[Tt]e[Xx] [Ww]arning/,/^[[:space:]]*$/p' \ -ne '/^[Ee]rror/,/^[[:space:]]*$/p' $texname.log >&2 @@ -40,8 +39,8 @@ destname="${outfile:-$defaultdest}" err "${THIS}: Please install the 'fancyvrb' package from CTAN:" err " http://www.ctan.org/tex-archive/macros/latex/contrib/fancyvrb/" fi - exit 1 - fi + exit $errorcode + } ) || exit $? is_target_exists= |