]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/map_fails_to_close_ul_element_for_empty_list.mdwn
0edba438c8aa3c3b60895890b1110a70b05b8ce9
[ikiwiki.git] / doc / bugs / map_fails_to_close_ul_element_for_empty_list.mdwn
1 input:
2
3     before.
4     \[[!map pages="sdfsdfsdfsd/*"]]
5     after.
6
7 Presuming that the pagespec does not match, output:
8
9     <p>before.
10     <div class="map">
11     <ul>
12     </div></p>
13
14 The UL element is not closed.
15
16 Patch[[!tag patch]]:
17
18     --- /usr/share/perl5/IkiWiki/Plugin/map.pm  2009-05-06 00:56:55.000000000 +0100
19     +++ IkiWiki/Plugin/map.pm   2009-06-15 12:23:54.000000000 +0100
20     @@ -137,11 +137,11 @@
21             $openli=1;
22             $parent=$item;
23         }
24     -   while ($indent > 0) {
25     +   while ($indent > 1) {
26             $indent--;
27             $map .= "</li>\n</ul>\n";
28         }
29     -   $map .= "</div>\n";
30     +   $map .= "</ul>\n</div>\n";
31         return $map;
32      }
33      
34
35 -- [[Jon]]
36
37 > Strictly speaking, a `<ul>` with no `<li>`s isn't valid HTML either...
38 > could `map` instead delay emitting the first `<ul>` until it determines that
39 > it will have at least one item? Perhaps refactoring that function into
40 > something easier to regression-test would be useful. --[[smcv]]
41
42 >> You are right (just checked 4.01 DTD to confirm). I suspect refactoring
43 >> the function would be wise. From my brief look at it to formulate the
44 >> above I thought it was a bit icky.  I'm not a good judge of what would
45 >> be regression-test friendly but I might have a go at reworking it. With
46 >> this variety of problem I have a strong inclination to use HOFs like map,
47 >> grep. - [[Jon]]