X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=doc%2Fman2html.sh;fp=doc%2Fman2html.sh;h=49f6c7244c5b227d9612da28a3997a8cef45e250;hp=0000000000000000000000000000000000000000;hb=0b8dbc2d02c7f78d273ad9cfdf05c927c648ffd1;hpb=6c47a7028f7c72fabc40f417aa41111c28de8a84 diff --git a/doc/man2html.sh b/doc/man2html.sh new file mode 100755 index 0000000..49f6c72 --- /dev/null +++ b/doc/man2html.sh @@ -0,0 +1,88 @@ +#!/bin/sh + +# +# Yoink +# Run this script to convert the manual page to html. +# +# Requires groff. +# Have fun! +# + +function showhelp() +{ + echo "Create an html manual page." + echo "Usage: $0 [-Hfh] [-i manpage] [-o htmlfile]" + echo "" + echo " -H Hide email addresses in the manual page." + echo " -f Force overwrite of output file." + echo " -h Show this help an exit." + echo " -i Specify the manual page to convert." + echo " -o Specify output path of html file." +} + +INFILE="doc/yoink.6" +OUTFILE="yoink.html" + +while getopts ":Hfhi:o:" opt +do + case $opt in + H) + HIDE_EMAIL=yes + ;; + f) + FORCE=yes + ;; + h) + showhelp + exit 0 + ;; + i) + INFILE="$OPTARG" + ;; + o) + OUTFILE="$OPTARG" + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + showhelp + exit 1 + ;; + esac +done + +if test x$FORCE != xyes && test -e "$OUTFILE" +then + echo "Refusing to overwrite file: $OUTFILE. Use -f to override." >&2 + exit 1 +fi + +if test ! -f "$INFILE" +then + echo "Can't open file: $INFILE" >&2 + exit 1 +fi + +DATE=$(date +"%d %b %Y") + +# 1. Remove first two lines (comments about groff). +# 2. Edit page title. +# 3. Insert a footer before . +HTML=$(groff -t -e -mandoc -Thtml "$INFILE" | sed -e "1,2d" \ +-e "s|.*|Yoink Manual|" -e "s||\ +

\\ +This manual page was generated on $DATE.\\ +For more information, go to the\\ +Yoink website.\\ +

\\ +|") + +if test x$HIDE_EMAIL = xyes +then +# 4. Replace email addresses with a placeholder. + echo "$HTML" \ + | sed -e "s|<.*@.*>|\<email address not shown\>|g" \ + >"$OUTFILE" +else + echo "$HTML" >"$OUTFILE" +fi +