aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/map.pm
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2012-08-03 12:53:25 +0100
committerSimon McVittie <smcv@debian.org>2013-02-24 13:10:24 +0000
commitaf8712cfac73d7668e509abf97eeabb5e824c29b (patch)
tree429f6e4529e2a8f47ef0ac433e618ac139e11bcc /IkiWiki/Plugin/map.pm
parent12ca01fd5c67c158e916c9068453271235a2a0e7 (diff)
downloadikiwiki-af8712cfac73d7668e509abf97eeabb5e824c29b.tar
ikiwiki-af8712cfac73d7668e509abf97eeabb5e824c29b.tar.gz
map: postprocess to collapse useless </ul><ul> sequences
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.
Diffstat (limited to 'IkiWiki/Plugin/map.pm')
-rw-r--r--IkiWiki/Plugin/map.pm6
1 files changed, 4 insertions, 2 deletions
diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm
index 6567331fa..4a9bf58db 100644
--- a/IkiWiki/Plugin/map.pm
+++ b/IkiWiki/Plugin/map.pm
@@ -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;
}