1
0
Fork 0
postfix/mantools/man2html
Daniel Baumann 75cf244379
Adding upstream version 3.10.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-21 14:19:32 +02:00

62 lines
1.2 KiB
Bash
Executable file
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
# Crude script to convert formatted manpages to HTML. Requires GROFF_NO_SGR.
while :
do
case $1 in
-t) title=$2; shift; shift;;
-*) echo "Usage: $0 [-t title] [file(s)]" 1>&2; exit 1;;
*) break;;
esac
done
echo "<!doctype html public \"-//W3C//DTD HTML 4.01 Transitional//EN\"
\"https://www.w3.org/TR/html4/loose.dtd\">
<html> <head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
<link rel='stylesheet' type='text/css' href='postfix-doc.css'>
<title> $title </title>
</head> <body> <pre>"
#ESC=`echo x | tr '[x]' '[\033]'`
sed '
s/\([<>&]\)\1/\1/g
s/&/\&amp;/g
s/_</\&lt;/g
s/<</\&lt;/g
s/</\&lt;/g
s/_>/\&gt;/g
s/>>/\&gt;/g
s/>/\&gt;/g
s;_\([^_]\);<i>\1</i>;g
s;.\(.\);<b>\1</b>;g
s;</i>\( *\)<i>;\1;g
s;</b>\( *\)<b>;\1;g
# Skip the redundant readme/html_directory blurb. The
# document names that follow will be hyperlinked.
/^<b>README FILES/{
h
N
N
g
}
# Generate anchors for sections.
/^<b>\([A-Z][-_A-Z0-9 ]*\)<\/b>/{
s//\1/
s/[ ]*$//
h
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ /abcdefghijklmnopqrstuvwxyz_/
s/^/<b><a name="/
s/$/">/
G
s/\n//
s;$;</a></b>;
}
' "$@"
echo '</pre> </body> </html>'