]> git.donarmstrong.com Git - lilypond.git/commitdiff
texi2html: Show 2nd-level entries in TOC only if numbered or parent of current
authorReinhold Kainhofer <reinhold@kainhofer.com>
Mon, 21 Jul 2008 18:09:32 +0000 (20:09 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Mon, 21 Jul 2008 18:09:32 +0000 (20:09 +0200)
lilypond-texi2html.init

index 74160e41a02ebf4c883367ef65d6e94dfb600caf..989a6a42c13ed7091ccf42838bee0e1175411f2e 100644 (file)
@@ -558,11 +558,12 @@ my @default_toc = [];
 # recursively generate the TOC entries for the element and its children (which
 # are only shown up to maxlevel. All ancestors of the current element are also
 # shown with their immediate children, irrespective of their level.
-sub generate_ly_toc_entries($$$)
+sub generate_ly_toc_entries($$$$)
 {
   my $element = shift;
   my $element_path = shift;
   my $maxlevel = shift;
+  my $always_show_unnumbered_children = shift;
   # Skip undefined sections, plus all sections generated by index splitting
   return() if (not defined($element) or exists($element->{'index_page'}));
   my @result = ();
@@ -575,11 +576,15 @@ sub generate_ly_toc_entries($$$)
   my $entry = "$ind<li$this_css_class>" . &$anchor ($element->{'tocid'}, "$element->{'file'}#$element->{'id'}",$element->{'text'});
 
   my $children = $element->{'section_childs'};
+  # Don't add unnumbered entries, unless they are at top-level or a parent of the current!
+  if (not ($element->{'number'} or $always_show_unnumbered_children)) {
+    return @result;
+  }
   if ( $print_children and defined($children) and (ref($children) eq "ARRAY") ) {
     push (@result, $entry);
     my @child_result = ();
     foreach (@$children) {
-      push (@child_result, generate_ly_toc_entries($_, $element_path, $maxlevel));
+      push (@child_result, generate_ly_toc_entries($_, $element_path, $maxlevel, $is_parent_of_current));
     }
     # if no child nodes were generated, e.g. for the index, where expanded pages
     # are ignored, don't generate a list at all...
@@ -616,7 +621,7 @@ sub lilypond_generate_page_toc_body($)
     my @toc_entries = ("<div class=\"contents\">", "<ul$NO_BULLET_LIST_ATTRIBUTE>");
     my $children = $current_element->{'section_childs'};
     foreach ( @$children ) {
-      push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth));
+      push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth, False));
     }
     push (@toc_entries, "</ul>");
     push (@toc_entries, "</div>");