-title=$(basename $1)
-
-echo "<html>"
-echo " <head>"
-if $stdhead; then
- echo "@include{stdhead}@"
-fi
-echo " <title>$title</title>"
-echo " </head>"
-echo " <body>"
-if $stdhead; then
- echo "@include{@label{menu}@}@"
-fi
-printf " <pre class=manpage>"
-# this is kind of painful using only BREs
-nroff -man "$1" | sed \
- '1d;$d;
- s/&/\&/g;
- s/</\</g;
- s/>/\>/g;
- s/@/\@/g;
- s!\(.\)\b\1!<b>\1</b>!g;
- s!\(&[#0-9a-z][0-9a-z]*;\)\b\1!<b>\1</b>!g;
- s!_\b\(.\)!<i>\1</i>!g;
- s!_\b\(&[#0-9a-z][0-9a-z]*;\)!<i>\1</i>!g;
- s!</\([bi]\)><\1>!!g'
-echo "</pre>"
-if $stdhead; then
- echo "@include{@label{menu}@end}@"
-fi
-echo " </body>"
-echo "</html>"
+for page; do
+ title=$(basename $page)
+ output=$page.$extension
+ echo "$page -> $output" >&2
+ exec > $output.new
+ echo "<html>"
+ echo " <head>"
+ if $stdhead; then
+ echo "@quiethead@#"
+ fi
+ echo " <title>$title</title>"
+ echo " </head>"
+ echo " <body>"
+ if $stdhead; then
+ echo "@stdmenu{}@#"
+ fi
+ printf " <pre class=manpage>"
+ # this is kind of painful using only BREs
+ nroff -Tascii -man "$page" | ${GNUSED} \
+ '1d;$d;
+ 1,/./{/^$/d};
+ s/&/\&/g;
+ s/</\</g;
+ s/>/\>/g;
+ s/@/\@/g;
+ s!\(.\)\b\1!<b>\1</b>!g;
+ s!\(&[#0-9a-z][0-9a-z]*;\)\b\1!<b>\1</b>!g;
+ s!_\b\(.\)!<i>\1</i>!g;
+ s!_\b\(&[#0-9a-z][0-9a-z]*;\)!<i>\1</i>!g;
+ s!</\([bi]\)><\1>!!g'
+ echo "</pre>"
+ if $stdhead; then
+ echo "@credits"
+ fi
+ echo " </body>"
+ echo "</html>"
+ mv $output.new $output
+done