From: Reinhold Kainhofer Date: Mon, 21 Jul 2008 18:09:32 +0000 (+0200) Subject: texi2html: Show 2nd-level entries in TOC only if numbered or parent of current X-Git-Tag: release/2.11.58-1~32^2~107 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=84ae5ced609599942f9ded2582ff625142d36e60;p=lilypond.git texi2html: Show 2nd-level entries in TOC only if numbered or parent of current --- diff --git a/lilypond-texi2html.init b/lilypond-texi2html.init index 74160e41a0..989a6a42c1 100644 --- a/lilypond-texi2html.init +++ b/lilypond-texi2html.init @@ -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" . &$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 = ("
", ""); 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, ""); push (@toc_entries, "
");