diff options
author | roktas <roktas@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2006-12-12 07:04:09 +0000 |
---|---|---|
committer | roktas <roktas@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2006-12-12 07:04:09 +0000 |
commit | 426cbadfef6c26323faedcab2cd5ea7efa64d1bb (patch) | |
tree | e16afb28eec790226a7b0524b8fb325594232e5c /markdown2pdf | |
parent | 6411ea7466f67f94816c541a22abb7249d36c377 (diff) | |
download | pandoc-426cbadfef6c26323faedcab2cd5ea7efa64d1bb.tar.gz |
Merge changes in branches/wrappers into trunk.
[in trunk] svn merge -r105:HEAD \
https://pandoc.googlecode.com/svn/branches/wrappers
git-svn-id: https://pandoc.googlecode.com/svn/trunk@177 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'markdown2pdf')
-rw-r--r-- | markdown2pdf | 113 |
1 files changed, 0 insertions, 113 deletions
diff --git a/markdown2pdf b/markdown2pdf deleted file mode 100644 index 7799b1077..000000000 --- a/markdown2pdf +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/sh -# converts markdown to latex, then uses latex to make a PDF - -pathfind () { # portable which(1), code taken from Debian Developer's Reference - OLDIFS="$IFS" - IFS=: - for _p in $PATH; do - if [ -x "$_p/$*" ]; then - IFS="$OLDIFS" - return 0 - fi - done - IFS="$OLDIFS" - return 1 -} - -for p in pandoc pdflatex; do - pathfind $p || { - echo >&2 "You need '$p' to use this program!" - exit 1 - } -done - -ALL="$*" -ARGS=${ALL%% -- *} # only the part before ' -- ' delimiters is relevant -set -- $ARGS - -REST=${ALL#$ARGS}; REST=${REST# -- } -PANDOC_OPTS=${REST:-$PANDOC_OPTS} - -outfile= -for option; do - if [ -n "$prev" ]; then - eval "$prev=\$option" - prev= - shift - continue - fi - optarg=$(expr "x$option" : 'x[^=]*=\(.*\)') - case $option in - -h | --h | --help ) - help=1 - shift ;; - -o | --o | --output ) - prev=outfile - shift ;; - -o=* | --o=* | --output=* ) - outfile=$optarg - shift ;; - -* ) echo >&2 "$0: unknown option: $option; aborting" - exit 1 ;; - * ) break ;; - esac -done - -[ -z "$help" ] || { - echo >&2 "Usage: $0 [-o|--output output-file] [input-file]" - exit 0 -} - -infile=$1 - -if ! [ -r $infile ]; then - echo >&2 "'$infile' not found" - exit 1 -fi - -if [ $# -gt 1 ]; then - shift - echo >&2 "Warning: extra arguments '$@' will be ignored!" -fi - -if [ -z "$outfile" ]; then - if [ -n "$infile" ]; then - outfile=${infile%.*}.pdf - else - outfile='stdin.pdf' # input is STDIN, since no argument given - fi -fi - -BASE=${outfile##*/} -BASE=${BASE%.*} - -set -e - -TEMP=${TMPDIR-/tmp}/markdown2pdf.$$ -trap "status=$?; rm -rf $TEMP; exit $status" 0 INT -mkdir -p $TEMP - -iconv -t utf-8 $infile | \ -pandoc $PANDOC_OPTS -w latex -s | \ -iconv -f utf-8 > $TEMP/$BASE.tex && ( - cd $TEMP - if ! pdflatex -interaction=batchmode $BASE.tex >/dev/null 2>&1; then - echo >&2 "LaTeX errors:" - sed -ne '/^!/,/^ *$/p' $BASE.log >&2 - exit 1 - fi -) || exit $? - -is_target_exists= -if [ -f $outfile ]; then - is_target_exists=1 - mv -f $outfile $outfile~ -fi - -mv -f $TEMP/$BASE.pdf $outfile - -printf "Created $outfile" >&2 -[ -z "$is_target_exists" ] || { - printf " (previous file has been backed up as '$outfile~')" >&2 -} -echo >&2 . |