Commits

shl...@7081e830-ea04-0410-ae62-fb6148e2d9db  committed 434bc0a

xhtml/1.x/std/toc: made the prev_sects handling more modular.

Also added a proper die if something is wrong.

  • Participants
  • Parent commits 133b304

Comments (0)

Files changed (1)

File xhtml/1.x/std/toc/toc.wml.tt2

         $my_body .= $token->as_is();
     }
 }
-push @{$wml_xhtml_std_toc_section[% inner_refs %]->{'subs'}}, { 'id' => $id, 'body' => $my_body, 'subs' => [],};
+
+my @prev_sects = ($wml_xhtml_std_toc_section);
+foreach my $idx (3 .. [% index %])
+{
+    if (! exists($prev_sects[-1]->{'subs'}))
+    {
+        use Data::Dumper;
+        print {*STDERR} Dumper(\@prev_sects);
+        die "Cannot find a subs in the last prev_sects!";
+    }
+    push @prev_sects, $prev_sects[-1]->{'subs'}->[-1];
+}
+push @{$prev_sects[-1]->{subs}}, { 'id' => $id, 'body' => $my_body, 'subs' => [],};
 }:>
 <restore id />
 </define-tag>