xref: /netbsd-src/external/ibm-public/postfix/dist/mantools/man2html (revision 059c16a85b0b39d60ad6d18f53c09510815afa2b)
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=utf-8\">
18<link rel='stylesheet' type='text/css' href='postfix-doc.css'>
19<title> $title </title>
20</head> <body> <pre>"
21
22#ESC=`echo x | tr '[x]' '[\033]'`
23
24sed '
25	s/\([<>&]\)\1/\1/g
26	s/&/\&amp;/g
27	s/_</\&lt;/g
28	s/<</\&lt;/g
29	s/</\&lt;/g
30	s/_>/\&gt;/g
31	s/>>/\&gt;/g
32	s/>/\&gt;/g
33	s;_\([^_]\);<i>\1</i>;g
34	s;.\(.\);<b>\1</b>;g
35
36	s;</i>\( *\)<i>;\1;g
37	s;</b>\( *\)<b>;\1;g
38
39	# Skip the redundant readme/html_directory blurb. The
40	# document names that follow will be hyperlinked.
41	/^<b>README FILES/{
42		h
43		N
44		N
45		g
46	}
47' "$@"
48
49echo '</pre> </body> </html>'
50