1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#!/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\"
\"http://www.w3.org/TR/html4/loose.dtd\">
<html> <head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=us-ascii\">
<title> $title </title>
</head> <body> <pre>"
#ESC=`echo x | tr '[x]' '[\033]'`
sed '
s/\([<>&]\)\1/\1/g
s/&/\&/g
s/_</\</g
s/<</\</g
s/</\</g
s/_>/\>/g
s/>>/\>/g
s/>/\>/g
s;_\([^_]\);<i>\1</i>;g
s;.\(.\);<b>\1</b>;g
# Begin incomplete workarounds for grotty SGR escape sequences.
#/'$ESC'\[0m$/{
# /'$ESC'\[1m[^'$ESC']*'$ESC'\[0m$/{
# # Here, ESC[0m means end-of-bold.
# s;0m$;22m;
# }
# /'$ESC'\[4m[^'$ESC']*'$ESC'\[0m$/{
# # Here, ESC[0m means end-of-italic.
# s;0m$;24m;
# }
#}
#s;'$ESC'\[1m;<b>;g
#s;'$ESC'\[22m;</b>;g
#s;'$ESC'\[4m;<i>;g
#s;'$ESC'\[24m;</i>;g
# Undo gratuitous whitespace changes.
#s;\( *\)\(</[bi]>\);\2\1;g
# End workarounds for grotty SGR escape sequences.
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
}
' "$@"
echo '</pre> </body> </html>'
|