#!/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 " $title
"

#ESC=`echo x | tr '[x]' '[\033]'`

sed '
	s/\([<>&]\)\1/\1/g
	s/&/\&/g
	s/_/\>/g
	s/>>/\>/g
	s/>/\>/g
	s;_\([^_]\);\1;g
	s;.\(.\);\1;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;;g
	#s;'$ESC'\[22m;;g
	#s;'$ESC'\[4m;;g
	#s;'$ESC'\[24m;;g
	# Undo gratuitous whitespace changes.
	#s;\(  *\)\(\);\2\1;g
	# End workarounds for grotty SGR escape sequences.

	s;\( *\);\1;g
	s;\( *\);\1;g

	# Skip the redundant readme/html_directory blurb. The
	# document names that follow will be hyperlinked.
	/^README FILES/{
		h
		N
		N
		g
	}
' "$@"

echo '
'