man2html

#!/bin/sed -f
# converts man page to HTML fragment
# <http://plan9.bell-labs.com/magic/man2html/6/man>
s/&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/g
s%\\-%\—%g
s%^\.B \(.*\)$%<b>\1</b>%g
s%^\.BI \(\S*\) \(.*\)$%<b>\1</b> <i>\2</i>%g
s%^\.BR \(\S*\)$%<b>\1</b>%g
s%^\.BR \(\S*\) \(.*\)$%<b>\1</b>\2%g
s%^\.EE%</samp>%g
s%^\.EX%<samp>%g
s%^\.I \(.*\)$%<i>\1</i>%g
s%^\.IB \(\S*\) \(.*\)$%<i>\1</i> <b>\2</b>%g
s%^\.IP%<br/>%g
s%^\.IR \(\S*\)$%<i>\1</i>%g
s%^\.IR \(\S*\) \(.*\)$%<i>\1</i>\2%g
s%^\.L \(.*\)$%<samp>\1</samp>%g
s%^\.LR \(\S*\) \(.*\)%<samp>\1</samp>\2%g
s%^\.LP%<br/>%g
s%^\.PD$%%g
s%^\.PD \(.*\)$%%g
s%^\.PP%<br/>%g
s%^\.RI \(\S*\) \(.*\)$%\1<i>\2</i>%g
s%^\.RL \(\S*\) \(.*\)$%\1\2%g
s%^\.RB \(\S*\) \(.*\)$%\1<b>\2</b>%g
s%^\.SH \(.*\)$%<h1>\1</h1>%g
s%^\.SS \(.*\)$%<h2>\1</h2>%g
s%^\.TH \(\S*\) \(\S*\)$%<title>\1 (\2)</title>%g
s%^\.TP\(.*\)$%<br/>%g
s%\\f.%%g
s%\\\*[R]%®%g
s%\\\*[Tm]%™%g
s%\\\*[lq]%“%g
s%\\\*[rq]%”%g
s%\\\*.%%g