X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/af3e7a30ce3308ff11bc63f8c92ec79f9ebe3021..246678fe46bfcacc7f8cadb52807305bb04890de:/IkiWiki/Plugin/map.pm?ds=inline diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm index 38f090ff7..4a9bf58db 100644 --- a/IkiWiki/Plugin/map.pm +++ b/IkiWiki/Plugin/map.pm @@ -72,6 +72,9 @@ sub preprocess (@) { $common_prefix=IkiWiki::dirname($common_prefix); } + # Set this to 1 or more spaces to pretty-print maps for debugging + my $spaces = ""; + # Create the map. my $parent=""; my $indent=0; @@ -94,33 +97,37 @@ sub preprocess (@) { if defined $common_prefix && length $common_prefix; my $depth = ($item =~ tr/\//\//) + 1; my $baseitem=IkiWiki::dirname($item); - my $parentbase=IkiWiki::dirname($parent); - while (length $parentbase && length $baseitem && $baseitem !~ /^\Q$parentbase\E(\/|$)/) { - $parentbase=IkiWiki::dirname($parentbase); + while (length $parent && length $baseitem && $baseitem !~ /^\Q$parent\E(\/|$)/) { + $parent=IkiWiki::dirname($parent); last if length $addparent && $baseitem =~ /^\Q$addparent\E(\/|$)/; $addparent=""; - $indent--; - $map .= "\n"; - if ($indent > 0) { - $map .= "\n"; + $map .= ($spaces x $indent) . "\n"; + if ($indent > 1) { + $map .= ($spaces x $indent) . "\n"; } + $indent--; } while ($depth < $indent) { - $indent--; - $map .= "\n"; - if ($indent > 0) { - $map .= "\n"; + $map .= ($spaces x $indent) . "\n"; + if ($indent > 1) { + $map .= ($spaces x $indent) . "\n"; } + $indent--; } my @bits=split("/", $item); my $p=""; - $indent++ unless length $parent; $p.="/".shift(@bits) for 1..$indent; while ($depth > $indent) { - if (@bits && !(length $parent && "/$parent" eq $p)) { + $indent++; + if ($indent > 1) { + $map .= ($spaces x $indent) . "\n"; } + $map =~ s{\n *\n *