aboutsummaryrefslogtreecommitdiff
path: root/aux
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-02-19 17:38:21 -0300
committerEuAndreh <eu@euandre.org>2022-02-19 17:40:30 -0300
commitbbcf49ac9abe7b4bdbc616ccd8ae8b8b0ac63bb5 (patch)
treede39968bb152098961b8beaeb2bf326d2bcdebf9 /aux
parentaux/workflow/style.css: Customize <pre> and <code> tag colors for dark mode (diff)
downloadgit-permalink-main.tar.gz
git-permalink-main.tar.xz
Extract aux/workflow/manpages2html.sh from doc/manpages.shHEADmain
Diffstat (limited to '')
-rwxr-xr-xaux/workflow/manpages2html.sh40
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