]> git.pond.sub.org Git - empserver/blobdiff - info/subj2html.pl
New info Hvy-Plastic
[empserver] / info / subj2html.pl
index f23819a54459b2ab5ec4ec8ff57c2a0cbbca7377..e5d8cceebef16224558e0d54653a18e242ff7966 100644 (file)
@@ -7,12 +7,16 @@ my $dome = 0;
 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
 
     @a = req($_);
-
     if (!@a) {
        if ($dome) {
            while ($_ =~ /[A-Za-z0-9\-\.]+/g) {
@@ -30,7 +34,11 @@ line: while (<>) {
     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;
     }
 
@@ -53,14 +61,13 @@ line: while (<>) {
        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);
@@ -74,12 +81,15 @@ line: while (<>) {
     # ignore unknown request
 }
 
+print "</body>\n";
+print "</html>\n";
+
 sub req {
     local ($_) = @_;
-    if (/^([\.\'])[ \t]*([^ ]+) *(.*)/) {
+    if (/^([\.\'])[ \t]*([^ ]*) *(.*)/) {
        my @a = ($1, $2);
        $_ = $3;
-       while (/(\"((\\.|[^\\\"])*)(\"|\Z))|(([^ ]|\\.)+) */g) {
+       while (/\G(\"((\\.|[^\\\"])*)(\"|\Z))|\G(([^ ]|\\.)+) */g) {
            push(@a, $2 || $5);
        }
        return @a;
@@ -114,6 +124,8 @@ sub htmlify {
     s/\&/&amp;/g;
     s/\</&lt;/g;
     s/\>/&gt;/g;
+    # delete form feed
+    s/\f//g;
     return $_ unless $esc;
     # translate more troff escapes
     s/\\e/&\#92;/g;            # escape character