Permalink
Browse files

nestify even the last element in a sequence

  • Loading branch information...
1 parent bca33e3 commit 0a7fd52221a6f4014ba6e261911aa5aa09f90e7e @rjbs committed May 5, 2012
Showing with 14 additions and 5 deletions.
  1. +3 −0 Changes
  2. +11 −5 lib/Pod/Elemental/Transformer/Nester.pm
View
@@ -1,6 +1,9 @@
Revision history for {{$dist->name}}
{{$NEXT}}
+ do not fail to nestify elements at the end of a sequence just because
+ they couldn't get any new children; it can break things down the
+ line; q.v., [rt.cpan.org #69189]
0.102361 2011-08-05 10:32:02 America/New_York
the Pod5 transformer no longer loses vertical whitespace after Data
@@ -99,10 +99,16 @@ sub _is_containable {
sub transform_node {
my ($self, $node) = @_;
- # We use -2 because if we're already at the last element, we can't nest
- # anything -- there's nothing subsequent to the potential top-level element
- # to nest! -- rjbs, 2009-10-18
- PASS: for my $i (0 .. $node->children->length - 2) {
+ # We used to say (length -2) because "if we're already at the last element,
+ # we can't nest anything -- there's nothing subsequent to the potential
+ # top-level element to nest!" -- my (rjbs's) reasoning in 2009.
+ #
+ # This was an unneeded optimization, and therefore stupid. Worse, it was a
+ # bug. It meant that a nestable element that was the last element in a
+ # sequence wouldn't be upgraded to a Nested element, so later munging could
+ # barf. In fact, that's what happened in [rt.cpan.org #69189]
+ # -- rjbs, 2012-05-04
+ PASS: for my $i (0 .. $node->children->length - 1) {
last PASS if $i >= $node->children->length;
my $para = $node->children->[ $i ];
@@ -126,7 +132,7 @@ sub transform_node {
}
if (@to_nest) {
- my @to_nest_elem =
+ my @to_nest_elem =
splice @{ $node->children }, $to_nest[0], scalar(@to_nest);
$para->children->push(@to_nest_elem);

0 comments on commit 0a7fd52

Please sign in to comment.