-#!/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 </body>.
-HTML=$(groff -t -e -mandoc -Thtml "$INFILE" | sed -e "1,2d" \
--e "s|<title>.*</title>|<title>Yoink Manual</title>|" -e "s|</body>|\
-<p style=\"font-size: 9px; text-align: center;\">\\
-This manual page was generated on $DATE.\\
-For more information, go to the\\
-<a href=\"http://www.dogcows.com/yoink/\">Yoink website</a>.\\
-</p>\\
-</body>|")
-
-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
-