aboutsummaryrefslogtreecommitdiff
path: root/src/wrappers/common.sh
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-01-08 19:55:34 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-01-08 19:55:34 +0000
commit58697ebe785b1f7eb4713d8874cd5aaae4d6a03b (patch)
treebc3a3c8f9c360cb3a6d31e58188aa78761dbee56 /src/wrappers/common.sh
parent9eafa971568aa522dcdc798a566069887eee5d30 (diff)
downloadpandoc-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/common.sh')
-rw-r--r--src/wrappers/common.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/wrappers/common.sh b/src/wrappers/common.sh
index 2cde64157..9605f5940 100644
--- a/src/wrappers/common.sh
+++ b/src/wrappers/common.sh
@@ -6,6 +6,11 @@ NEWLINE='
err () { echo "$*" | fold -s -w ${COLUMNS:-110} >&2; }
errn () { printf "$*" | fold -s -w ${COLUMNS:-110} >&2; }
+usage () {
+ err "$1 - $2" # short description
+ err "See the $1(1) man page for usage."
+}
+
# Portable which(1).
pathfind () {
oldifs="$IFS"; IFS=':'
@@ -25,3 +30,14 @@ for p in pandoc $REQUIRED; do
exit 1
}
done
+
+CONF=$(pandoc --dump-args "$@" 2>&1) || {
+ errcode=$?
+ echo "$CONF" | sed -e '/^pandoc \[OPTIONS\] \[FILES\]/,$d' >&2
+ [ $errcode -eq 2 ] && usage "$THIS" "$SYNOPSIS"
+ exit $errcode
+}
+
+OUTPUT=$(echo "$CONF" | sed -ne '1p')
+ARGS=$(echo "$CONF" | sed -e '1d')
+