my $esc="\\";
my @a;
+print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n";
+print " \"http://www.w3.org/TR/html4/strict.dtd\">\n";
+print "<html>\n";
+print "<head>\n";
+
line: while (<>) {
chomp; # strip record separator
- s/([^\\](\\\\)*)\\\".*/$1/g;# strip comments
+ s/([^\\](\\\\)*)\\\".*/$1/g; # strip comments
@a = req($_);
-
if (!@a) {
if ($dome) {
while ($_ =~ /[A-Za-z0-9\-\.]+/g) {
if ($a[1] eq "TH") {
@a = checkarg(2, @a);
$a[3] = htmlify($a[3]);
- print "<title>$a[2] : $a[3]</title><h1>$a[2] : $a[3]</h1>\n";
+ print "<title>$a[2] : $a[3]</title>\n";
+ print "</head>\n";
+ print "<body>\n";
+ print "<h1>$a[2] : $a[3]</h1>\n";
+ print "<p>\n";
next line;
}
next line;
}
- if ($a[1] =~ "eo") { $esc = 0; next line; }
- if ($a[1] =~ "ec") { $esc = $#a == 1 ? "\\" : $a[2]; next line; }
+ if ($a[1] eq "eo") { $esc = 0; next line; }
+ if ($a[1] eq "ec") { $esc = $#a == 1 ? "\\" : $a[2]; next line; }
- if (/^\.(NF|nf)/) { $dome = 1; printf (("<p><pre>\n")); next line; }
- if (/^\.(FI|fi)/) { $dome = 0; printf (("</pre><p>\n")); next line; }
- if (/^\.s3/) { printf (("<p>\n")); next line; }
- if (/^\.s1/) { printf (("<hr> \n")); next line; }
- if (/^\.br/) { printf "<br>\n"; next line; }
+ if ($a[1] =~ /NF|nf/i) { $dome = 1; printf (("<p><pre>\n")); next line; }
+ if ($a[1] =~ /FI|fi/i) { $dome = 0; printf (("</pre><p>\n")); next line; }
+ if ($a[1] eq "s1") { printf (("<hr><p>\n")); next line; }
+ if ($a[1] eq "br") { printf "<br>\n"; next line; }
if ($a[1] eq "SA") {
@a = checkarg(1, @a);
# ignore unknown request
}
+print "</body>\n";
+print "</html>\n";
+
sub req {
local ($_) = @_;
- if (/^([\.\'])[ \t]*([^ ]+) *(.*)/) {
+ if (/^([\.\'])[ \t]*([^ ]*) *(.*)/) {
my @a = ($1, $2);
$_ = $3;
- while (/(\"((\\.|[^\\\"])*)(\"|$))|(([^ ]|\\.)+) */g) {
+ while (/\G(\"((\\.|[^\\\"])*)(\"|\Z))|\G(([^ ]|\\.)+) */g) {
push(@a, $2 || $5);
}
return @a;
# Translate HTML special characters into escape sequences
sub htmlify {
- local ($_) = @_;
- die "funny escape character `$esc' not supported"
- if $esc && $esc ne "\\";
- # translate some troff escapes
- s/\\&//g if $esc; # zero width space character
- # escape HTML special characters
- s/\&/&/g;
- s/\</</g;
- s/\>/>/g;
- return $_ unless $esc;
- # translate more troff escapes
- s/\\e/&\#92;/g; # escape character
- # turn quoted strings that look like info names into links
- # tacky...
- while (/(\\\*Q)([A-Za-z0-9\-\.]+)(\\\*U)/) {
- $_ = $` . anchor($2) . "$'";
- }
- while (/(\"info )([A-Za-z0-9\-\.]+)/) {
- $_ = "$`\"info " . anchor($2) . "$'";
- }
- # tranlate more troff escapes and strings
- s/\\\*Q/<em>/g;
- s/\\\*U/<\/em>/g;
- s/\\fI/<em>/g;
- s/\\fR/<\/em><\/em>/g;
- s/\\fB/<strong>/g;
- s/\\fP/<\/strong><\/em>/g;
- s/\\\*\(bF/<strong>/g; # bold font
- s/\\\*\(pF/<\/strong><\/em>/g; # pica font
- s/\\\*\(nF/<\/strong><\/em>/g; # normal font
- s/\\\*\(iF/<em>/g; # italic font
- s/\\\(mu/x/g; # multiply symbol
- s/\\ / /g; # non breaking space
- return $_;
+ local ($_) = @_;
+ die "funny escape character `$esc' not supported"
+ if $esc && $esc ne "\\";
+ # translate some troff escapes
+ s/\\&//g if $esc; # zero width space character
+ # escape HTML special characters
+ s/\&/&/g;
+ s/\</</g;
+ s/\>/>/g;
+ # delete form feed
+ s/\f//g;
+ return $_ unless $esc;
+ # translate more troff escapes
+ s/\\e/&\#92;/g; # escape character
+ # turn quoted strings that look like info names into links
+ # tacky...
+ while (/(\\\*Q)([A-Za-z0-9\-\.]+)(\\\*U)/) {
+ $_ = $` . anchor($2) . "$'";
+ }
+ while (/(\"info )([A-Za-z0-9\-\.]+)/) {
+ $_ = "$`\"info " . anchor($2) . "$'";
+ }
+ # tranlate more troff escapes and strings
+ s/\\\*Q/<em>/g;
+ s/\\\*U/<\/em>/g;
+ s/\\fI/<em>/g;
+ s/\\fR/<\/em><\/em>/g;
+ s/\\fB/<strong>/g;
+ s/\\fP/<\/strong><\/em>/g;
+ s/\\\*\(bF/<strong>/g; # bold font
+ s/\\\*\(pF/<\/strong><\/em>/g; # pica font
+ s/\\\*\(nF/<\/strong><\/em>/g; # normal font
+ s/\\\*\(iF/<em>/g; # italic font
+ s/\\\(mu/x/g; # multiply symbol
+ s/\\ / /g; # non breaking space
+ return $_;
}