git.iko.soy/typeable/pandoc
on 79fdbce help sign in
typeable/pandoc/markdown2html
31 lines 654 B history raw
1#!/bin/sh -e
2# converts markdown to HTML
4pathfind () { # portable which(1), code taken from Debian Developer's Reference
5 OLDIFS="$IFS"
6 IFS=:
7 for _p in $PATH; do
8 if [ -x "$_p/$*" ]; then
9 IFS="$OLDIFS"
10 return 0
11 fi
12 done
13 IFS="$OLDIFS"
14 return 1
17for p in pandoc; do
18 pathfind $p || {
19 echo >&2 "You need '$p' to use this program!"
20 exit 1
21 }
22done
24ALL="$*"
25ARGS=${ALL%% -- *} # only the part before ' -- ' delimiters is relevant
26set -- $ARGS
28REST=${ALL#$ARGS}; REST=${REST# -- }
29PANDOC_OPTS=${REST:-$PANDOC_OPTS}
31iconv -t utf-8 $* | pandoc $PANDOC_OPTS | iconv -f utf-8