Files
pandoc/markdown2html
T
roktas 19486ee0e1 * Add PANDOC_OPTS support to 'markdown2pdf'.
* Sanitize comand line handling a bit in all wrappers:
  + Correct delimiters syntax should be ' -- '.
  + Print warning for extra arguments which are ignored.
  + Instead of positional arguments use named variables whenever 
    appropriate.


git-svn-id: https://pandoc.googlecode.com/svn/trunk@97 788f1e2b-df1e-0410-8736-df70ead52e1b
2006-11-13 16:34:07 +00:00

32 lines
652 B
Bash

#!/bin/sh -e
# converts markdown to HTML
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; 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}
iconv -t utf-8 $* | pandoc $PANDOC_OPTS | iconv -f utf-8