Invalid code, that validator produces

Knock, knock.

Consider following:
  http://validator.w3.org/check?uri=http%3A%2F%2Fwww.success.com.ua%2Fhowto.html&verbose=1&outline=1
This is website, made by me and validated by validator.

And then!
  http://validator.w3.org/check?uri=http%3A%2F%2Fvalidator.w3.org%2Fcheck%3Furi%3Dhttp%253A%252F%252Fwww.success.com.ua%252Fhowto.html%26verbose%3D1%26outline%3D1&charset=%28detect+automatically%29&doctype=%28detect+automatically%29&outline=1&verbose=1
This is the page validator produced to show me that I've got valid
XHTML 1.1 on my site. I've checked what causes the problem and found
that it outputs invalid ul/li pairs when showing the outline of my page.
I modified script I've got at home (downloaded from your page) and wanted to
give you diff output, maybe it would help you to solve the problem with yours.

===== cut =====
[dennis@scout docroot]# diff -u check check.original
--- check       Tue Jul  8 09:39:19 2003
+++ check.original      Sat Jul  5 02:39:38 2003
@@ -1780,16 +1780,12 @@
     $prevlevel = $level;
     $level     = $1;

-    print "</ul></li>\n"x($prevlevel - $level) if ($level!=1);
-    print "</ul>"x($prevlevel - $level) if ($level==1);
-    if ($level == 1) {
-       print "<ul>\n"
-       } elsif (($level - $prevlevel == 1) && $level!=1) {
-               print "<li><ul>\n";
-       } elsif ($level - $prevlevel > 1) {
-               print "Error!\n"; # here I cut "... missing headings..." section
-       }
-
+    print "    </ul>\n" x ($prevlevel - $level); # perl is so cool.
+    if ($level - $prevlevel == 1) {print "    <ul>\n"};
+    foreach my $i (($prevlevel + 1) .. ($level - 1)) {
+      print qq(  <ul>\n    <li class="warning">A level $i heading is missing!</li>\n);
+    }
+    if ($level - $prevlevel > 1) {print "    <ul>\n"};

     $line       = '';
     my $heading = '';
@@ -1813,8 +1809,7 @@
     $heading = &ent($heading);
     print "    <li>$heading</li>\n";
   }
-  print "    </ul></li>\n" x ($level-1);
-  print "    </ul>\n";
+  print "    </ul>\n" x $level;
   print <<'EOF';
     <p>
       If this does not look like a real outline, it is likely that the
===== cut =====

When I finished, I noticed that I pulled away the part, that wrote something
about missing headers, if there are some, but I think it's not a problem for you
to put it back.
       
-- 
Dennis Krupenik

Received on Tuesday, 8 July 2003 08:44:38 UTC