]> sipb.mit.edu Git - ikiwiki.git/commitdiff
map: postprocess to collapse useless </ul><ul> sequences
authorSimon McVittie <smcv@debian.org>
Fri, 3 Aug 2012 11:53:25 +0000 (12:53 +0100)
committerSimon McVittie <smcv@debian.org>
Sun, 24 Feb 2013 13:10:24 +0000 (13:10 +0000)
This re-fixes the same bug as 2d5c2f30, but without introducing
malformed HTML in some situations. This is not a very elegant
solution, but it has the advantage of passing more tests.

IkiWiki/Plugin/map.pm

index 6567331fa41dca1ebdfa6895cab386814a8382ae..4a9bf58dbc1a446ae72f37f13089af05fdc7b221 100644 (file)
@@ -103,7 +103,7 @@ sub preprocess (@) {
                        $addparent="";
                        $map .= ($spaces x $indent) . "</li>\n";
                        if ($indent > 1) {
-                               $map .= ($spaces x $indent) . "</ul>\n";
+                               $map .= ($spaces x $indent) . "</ul><map:collapse>\n";
                        }
                        $indent--;
                }
@@ -120,7 +120,7 @@ sub preprocess (@) {
                while ($depth > $indent) {
                        $indent++;
                        if ($indent > 1) {
-                               $map .= ($spaces x $indent) . "<ul>\n";
+                               $map .= ($spaces x $indent) . "<ul><map:collapse>\n";
                        }
                        if ($depth > $indent) {
                                $p.="/".shift(@bits);
@@ -154,6 +154,8 @@ sub preprocess (@) {
                $indent--;
                $map .= ($spaces x $indent) . "</ul>\n";
        }
+       $map =~ s{\n *</ul><map:collapse>\n *<ul><map:collapse>\n}{\n}gs;
+       $map =~ s{<map:collapse>}{}g;
        $map .= "</div>\n";
        return $map;
 }