man-to-html/man-to-html

17 lines
345 B
Plaintext
Raw Normal View History

2019-04-10 23:30:39 +00:00
#!/usr/bin/env bash
2019-04-11 20:41:30 +00:00
if [[ $# -ne 2 ]]; then
echo "USAGE: ./man-to-html INPUT OUTPUT"
2019-04-11 20:12:50 +00:00
exit 1
fi
set -euo pipefail
2019-04-11 20:41:30 +00:00
eval "meta=($(head -n 1 "$1" | sed "s/.TH //"))"
2019-04-10 23:30:39 +00:00
2019-04-11 01:15:13 +00:00
pandoc -f man -t html \
--template man-template \
2019-04-11 20:41:30 +00:00
-M title="${meta[4]}" -M date="${meta[2]}" \
-M version="${meta[3]}" -M cmd="${meta[0]^^}(${meta[1]})" \
2019-04-11 01:15:13 +00:00
"$1" > "$2"