diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-11-03 22:14:03 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-11-03 22:14:03 +0000 |
commit | 4a841bfc5464907adea4cdd655485565565b40ae (patch) | |
tree | 36c0a21e3639614c8d25b5fb1909c32d0ab11dcd /wrappers/markdown2pdf.in | |
parent | 3116d30133196e1bb258f7e74e03d4a85f3b21ae (diff) | |
download | pandoc-4a841bfc5464907adea4cdd655485565565b40ae.tar.gz |
Use template haskell to avoid the need for templates:
+ Added library Text.Pandoc.Include, with a template haskell
function $(includeStrFrom fname) to include a file as a string
constant at compile time.
+ This removes the need for the 'templates' directory or Makefile
target. These have been removed.
+ The base source directory has been changed from src to .
+ A new 'data' directory has been added, containing the ASCIIMathML.js
script, writer headers, and S5 files.
+ The src/wrappers directory has been moved to 'wrappers'.
+ The Text.Pandoc.ASCIIMathML library is no longer needed, since
Text.Pandoc.Writers.HTML can use includeStrFrom to include the
ASCIIMathML.js code directly. It has been removed.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1063 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'wrappers/markdown2pdf.in')
-rw-r--r-- | wrappers/markdown2pdf.in | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/wrappers/markdown2pdf.in b/wrappers/markdown2pdf.in new file mode 100644 index 000000000..37be69469 --- /dev/null +++ b/wrappers/markdown2pdf.in @@ -0,0 +1,81 @@ +#!/bin/sh -e + +REQUIRED="pdflatex" +SYNOPSIS="converts markdown-formatted text to PDF, using pdflatex." + +### common.sh + +### tempdir.sh + +texname=output +logfile=$THIS_TEMPDIR/log + +pandoc -s -r markdown -w latex "$@" -o $THIS_TEMPDIR/$texname.tex + +if [ "$OUTPUT" = "-" ]; then + firstinfile="$(echo $ARGS | sed -ne '1p')" + firstinfilebase="${firstinfile%.*}" + destname="${firstinfilebase:-stdin}.pdf" +else + destname="$OUTPUT" +fi + +( + origdir=$(pwd) + cd $THIS_TEMPDIR + TEXINPUTS=$origdir:$TEXINPUTS: + export TEXINPUTS + 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 \`ulem.sty' not found" $texname.log; then + err "${THIS}: Please install the 'ulem' package from CTAN:" + err " http://www.ctan.org/tex-archive/macros/latex/contrib/misc/ulem.sty" + fi + } + exit $errcode + } + if [ $runs -lt 3 ] && + ((grep -q "LaTeX Warning: There were undefined references." $texname.log) || + (echo "$@" | grep -q -- "--toc\|--table-of-contents")); then + runs=$(($runs + 1)) + if grep -q "LaTeX Warning:.*[Cc]itation" $texname.log; then + bibtex $texname 2>&1 >bibtex.err + if [ $runs -gt 2 ]; then + if grep -q "error message" bibtex.err || + grep -q "Warning" bibtex.err; then + cat bibtex.err >&2 + fi + fi + fi + else + finished=yes + fi + done +) || exit $? + +is_target_exists= +if [ -f "$destname" ]; then + is_target_exists=1 + mv "$destname" "$destname~" +fi + +mv -f $THIS_TEMPDIR/$texname.pdf "$destname" + +errn "Created $destname" +[ -z "$is_target_exists" ] || { + errn " (previous file has been backed up as $destname~)" +} +err . |