diff options
Diffstat (limited to 'aux/workflow/manpages2html.sh')
-rwxr-xr-x | aux/workflow/manpages2html.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/aux/workflow/manpages2html.sh b/aux/workflow/manpages2html.sh new file mode 100755 index 0000000..2498b5c --- /dev/null +++ b/aux/workflow/manpages2html.sh @@ -0,0 +1,40 @@ +#!/bin/sh +set -eu + +while getopts 'o:' flag; do + case "$flag" in + o) + OUTDIR="$OPTARG" + ;; + *) + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) + +assert_arg() { + if [ -z "$1" ]; then + echo "Missing $2" >&2 + exit 2 + fi +} + +assert_arg "${OUTDIR:-}" '-o OUTDIR' + +for f in "$@"; do + l="$(echo "$f" | awk -F. '{print $(NF-1)}')" + n="$(echo "$f" | awk -F. '{print $NF}')" + to_name="$(basename "${f%."$l"."$n"}.$n.html")" + mkdir -p "$OUTDIR/$l" + pandoc \ + --toc \ + --toc-depth=2 \ + -s \ + -r man \ + -w html \ + -H aux/workflow/favicon.html \ + -H aux/workflow/style.css \ + --metadata "lang=$l" \ + < "$f" > "$OUTDIR/$l/$to_name" +done |