eval 'exec perl -Ssw $0 "$@"' if 0; # Usage $0 manpage # Parse my man page formats. die "Usage: $0 [ manpage ] \n" unless $#ARGV <= 0; $firstSH = 1; $inDL = 0; warn "Doing $ARGV[0]\n"; open(STDIN, "$ARGV[0]") if ($#ARGV == 0); while (<>) { next if (/^\.\\"/); if (/^\.TH\s/) { # .TH BW_MEM_CP 8 "$Date$" "(c)1994 Larry McVoy" "LMBENCH" split; print "
\n"; next; } if (/^\.TP/) { # treat as a DT list $_ = <>; &html; chop; print "
\n\n"; next; } next if (/^\.in/ || /^\.ps/); # skip this stuff. if (/^\.br/) { print "
\n"; while (<>) { last if /^\.fi/; last if /^\.DE/; next if /^\./; &html; print "\t$_"; # XXX - a screwy way of indenting } print "\n"; next; } if (/^\.ft C[WB]/) { local($pre) = 0; print "
\n";
while (<>) {
last if /^\.ft\s*$/;
if (/^\.nf/) {
$pre = 1;
print "\n";
next;
}
if ($pre && /^\.fi/) {
print "
\n";
$pre = 0;
next;
}
next if /^\.br/;
&html;
print;
}
print "
\n";
next;
}
if (/\\f\(C[WB]/) {
&html;
s/\\f\(C[WB]//;
while (!/\\f/) {
&html;
print;
$_ = <>;
}
s/\\fP/<\/CODE>/;
print;
next;
}
if (/\\fB/) {
&html;
s/\\fB//;
while (!/\\f/) {
print;
$_ = <>;
&html;
}
s/\\fP/<\/STRONG>/;
print;
next;
}
if (/\\fI/) {
&html;
s/\\fB//;
while (!/\\f/) {
print;
$_ = <>;
&html;
}
s/\\fP/<\/EM>/;
print;
next;
}
if (/^\.ti/) { # one line display
print "\n";
$_ = <>;
&html;
print;
print "
\n";
next;
}
if (/^\.de\s+/) {
s/^\.de\s+//;
warn "$ARGV[0]: Ignoring definition: $_";
while (<>) {
last if /^\.\./;
}
next;
}
# Warn about unimplemented troff/man commands
if (/^\./) {
chop;
warn "$ARGV[0] unimp: \"$_\"\n";
next;
}
if (/\\f/) {
warn "$ARGV[0]: missed font: \"$_\"\n";
}
# Catchall for all the weirdball things I do.
s/^\\\&\.\\\|\.\\\|\./.../;
s/\\-/-/;
&html;
print;
}
exit 0;
sub html
{
# HTML things that I've encountered.
s/"/"/g;
s/</g;
s/>/>/g;
}
sub fontfont {
if (/^\.BI\s/) {
s/.BI\s+//;
chop;
split;
print "$_[0]$_[1]\n";
return 1;
}
if (/^\.IB\s/) {
s/.IB\s+//;
chop;
split;
print "$_[0]$_[1]\n";
return 1;
}
if (/^\.IR\s/) {
s/.IR\s+//;
chop;
split;
print "$_[0]$_[1]\n";
return 1;
}
if (/^\.BR\s/) {
s/.BR\s+//;
chop;
split;
print "$_[0]$_[1]\n";
return 1;
}
if (/^\.B\s/) {
s/.B\s+//;
chop;
print "$_\n";
return 1;
}
if (/^\.I\s/) {
s/.I\s+//;
chop;
print "$_\n";
return 1;
}
return 0;
}