diff options
author | EuAndreh <eu@euandre.org> | 2022-02-19 17:38:21 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2022-02-19 17:40:30 -0300 |
commit | bbcf49ac9abe7b4bdbc616ccd8ae8b8b0ac63bb5 (patch) | |
tree | de39968bb152098961b8beaeb2bf326d2bcdebf9 /aux/workflow/manpages2html.sh | |
parent | aux/workflow/style.css: Customize <pre> and <code> tag colors for dark mode (diff) | |
download | git-permalink-main.tar.gz git-permalink-main.tar.xz |
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 |