@@ -1,136 +0,0 @@
4−if (echo "$@" | grep -q xetex); then
9−SYNOPSIS="converts markdown-formatted text to PDF, using pdflatex."
16−err () { echo "$*" | fold -s -w ${COLUMNS:-110} >&2; }
17−errn () { printf "$*" | fold -s -w ${COLUMNS:-110} >&2; }
20− err "$1 - $2" # short description
22− pandoc -h | sed -ne '/--strict\|--preserve-tabs\|--tab-stop\|--parse-raw\|--toc\|--xetex\|--number-sections\|--include-in-header\|--include-before-body\|--include-after-body\|--custom-header\|--output\|--template\|--variable\|--help\|--version/p' >&2
27− oldifs="$IFS"; IFS=':'
29− if [ -x "$_p/$*" ] && [ -f "$_p/$*" ]; then
38−for p in pandoc $REQUIRED; do
40− err "You need '$p' to use this program!"
45−if (echo "$@" | grep -q -- "--help\|-h"); then
46− usage "$THIS" "$SYNOPSIS"
50−CONF=$(pandoc --dump-args "$@") || exit $?
51−OUTPUT=$(echo "$CONF" | sed -ne '1p')
52−ARGS=$(echo "$CONF" | sed -e '1d')
54−# As a security measure refuse to proceed if mktemp is not available.
55−pathfind mktemp || { err "Couldn't find 'mktemp'; aborting."; exit 1; }
57−# Avoid issues with /tmp directory on Windows/Cygwin
59−cygwin=$(uname | sed -ne '/^CYGWIN/p')
60−if [ -n "$cygwin" ]; then
66−THIS_TEMPDIR="$(mktemp -d -t $THIS.XXXXXXXX)" || exit 1
70− [ -z "$THIS_TEMPDIR" ] || rm -rf "$THIS_TEMPDIR"
71− exit $exitcode' 0 1 2 3 13 15
74−logfile=$THIS_TEMPDIR/log
76−pandoc -s -r markdown -w latex "$@" -o $THIS_TEMPDIR/$texname.tex
78−if [ "$OUTPUT" = "-" ]; then
79− firstinfile="$(echo $ARGS | sed -ne '1p')"
80− firstinfilebase="${firstinfile%.*}"
81− destname="${firstinfilebase:-stdin}.pdf"
89− TEXINPUTS=$origdir:$TEXINPUTS:
93− while [ $finished = "no" ]; do
94− $latexprogram -interaction=batchmode $texname.tex >/dev/null || {
96− err "${THIS}: $latexprogram failed with error code $errcode"
97− [ -f $texname.log ] && {
98− err "${THIS}: error context:"
99− sed -ne '/^!/,/^[[:space:]]*$/p' \
100− -ne '/^[Ll]a[Tt]e[Xx] [Ww]arning/,/^[[:space:]]*$/p' \
101− -ne '/^[Ee]rror/,/^[[:space:]]*$/p' $texname.log >&2
102− if grep -q "File \`ucs.sty' not found" $texname.log; then
103− err "${THIS}: Please install the 'unicode' package from CTAN:"
104− err " http://www.ctan.org/tex-archive/macros/latex/contrib/unicode/"
106− if grep -q "File \`ulem.sty' not found" $texname.log; then
107− err "${THIS}: Please install the 'ulem' package from CTAN:"
108− err " http://www.ctan.org/tex-archive/macros/latex/contrib/misc/ulem.sty"
113− if [ $runs -lt 3 ] &&
114− ((grep -q "Warning: There were undefined references." $texname.log) ||
115− (echo "$@" | grep -q -- "--toc\|--table-of-contents")); then
117− if grep -q "LaTeX Warning:.*[Cc]itation" $texname.log; then
118− bibtex $texname 2>&1 >bibtex.err
119− if [ $runs -gt 2 ]; then
120− if grep -q "error message" bibtex.err ||
121− grep -q "Warning" bibtex.err; then
126− elif [ $runs -gt 1 ]; then # always run at least twice for pdf bookmarks
134−mv -f $THIS_TEMPDIR/$texname.pdf "$destname"
136−err "Created $destname"