xref: /netbsd-src/external/ibm-public/postfix/dist/mantools/man2html (revision 76c7fc5f6b13ed0b1508e6b313e88e59977ed78e)
1#!/bin/sh
2
3# Crude script to convert formatted manpages to HTML. Requires GROFF_NO_SGR.
4
5while :
6do
7    case $1 in
8    -t) title=$2; shift; shift;;
9    -*) echo "Usage: $0 [-t title] [file(s)]" 1>&2; exit 1;;
10     *) break;;
11    esac
12done
13
14echo "<!doctype html public \"-//W3C//DTD HTML 4.01 Transitional//EN\"
15        \"http://www.w3.org/TR/html4/loose.dtd\">
16<html> <head>
17<meta http-equiv=\"Content-Type\" content=\"text/html; charset=us-ascii\">
18<title> $title </title>
19</head> <body> <pre>"
20
21#ESC=`echo x | tr '[x]' '[\033]'`
22
23sed '
24	s/\([<>&]\)\1/\1/g
25	s/&/\&amp;/g
26	s/_</\&lt;/g
27	s/<</\&lt;/g
28	s/</\&lt;/g
29	s/_>/\&gt;/g
30	s/>>/\&gt;/g
31	s/>/\&gt;/g
32	s;_\([^_]\);<i>\1</i>;g
33	s;.\(.\);<b>\1</b>;g
34
35	s;</i>\( *\)<i>;\1;g
36	s;</b>\( *\)<b>;\1;g
37
38	# Skip the redundant readme/html_directory blurb. The
39	# document names that follow will be hyperlinked.
40	/^<b>README FILES/{
41		h
42		N
43		N
44		g
45	}
46' "$@"
47
48echo '</pre> </body> </html>'
49