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/&/\&/g 26 s/_</\</g 27 s/<</\</g 28 s/</\</g 29 s/_>/\>/g 30 s/>>/\>/g 31 s/>/\>/g 32 s;_\([^_]\);<i>\1</i>;g 33 s;.\(.\);<b>\1</b>;g 34 35 # Begin incomplete workarounds for grotty SGR escape sequences. 36 #/'$ESC'\[0m$/{ 37 # /'$ESC'\[1m[^'$ESC']*'$ESC'\[0m$/{ 38 # # Here, ESC[0m means end-of-bold. 39 # s;0m$;22m; 40 # } 41 # /'$ESC'\[4m[^'$ESC']*'$ESC'\[0m$/{ 42 # # Here, ESC[0m means end-of-italic. 43 # s;0m$;24m; 44 # } 45 #} 46 #s;'$ESC'\[1m;<b>;g 47 #s;'$ESC'\[22m;</b>;g 48 #s;'$ESC'\[4m;<i>;g 49 #s;'$ESC'\[24m;</i>;g 50 # Undo gratuitous whitespace changes. 51 #s;\( *\)\(</[bi]>\);\2\1;g 52 # End workarounds for grotty SGR escape sequences. 53 54 s;</i>\( *\)<i>;\1;g 55 s;</b>\( *\)<b>;\1;g 56 57 # Skip the redundant readme/html_directory blurb. The 58 # document names that follow will be hyperlinked. 59 /^<b>README FILES/{ 60 h 61 N 62 N 63 g 64 } 65' "$@" 66 67echo '</pre> </body> </html>' 68