man-to-html/man-to-html

16 lines
345 B
Bash
Executable file

#!/usr/bin/env bash
if [[ $# -ne 2 ]]; then
echo "USAGE: ./man-to-html INPUT OUTPUT"
exit 1
fi
set -euo pipefail
eval "meta=($(head -n 1 "$1" | sed "s/.TH //"))"
pandoc -f man -t html \
--template man-template \
-M title="${meta[4]}" -M date="${meta[2]}" \
-M version="${meta[3]}" -M cmd="${meta[0]^^}(${meta[1]})" \
"$1" > "$2"