From de97e4a3ea306b61bf250910c349d9f7efe3ec60 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Thu, 26 Mar 2009 17:56:40 +0100 Subject: [PATCH] Texi2html: Allow -D short_toc or @set short_toc 1 for texi2html to expand the TOC only to second level Otherwise the TOC of the snippets page would be way too long. --- input/lsr/GNUmakefile | 2 ++ lilypond-texi2html.init | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/input/lsr/GNUmakefile b/input/lsr/GNUmakefile index e479c09c0e..9f06be94de 100644 --- a/input/lsr/GNUmakefile +++ b/input/lsr/GNUmakefile @@ -18,6 +18,8 @@ endif include $(depth)/make/stepmake.make +TEXI2HTML_FLAGS += -D short_toc + IN_ITELY_FILES = $(call src-wildcard,*-intro.itely) GENERATED_ITELY_FILES = $(IN_ITELY_FILES:%-intro.itely=$(outdir)/%.itely) diff --git a/lilypond-texi2html.init b/lilypond-texi2html.init index cf9a6df30c..cb57e6b7a0 100644 --- a/lilypond-texi2html.init +++ b/lilypond-texi2html.init @@ -130,6 +130,7 @@ $Texi2HTML::Config::print_page_head = \&lilypond_print_page_head; $Texi2HTML::Config::foot_line_and_ref = \&makeinfo_like_foot_line_and_ref; $Texi2HTML::Config::foot_lines = \&makeinfo_like_foot_lines; $Texi2HTML::Config::paragraph = \&makeinfo_like_paragraph; +$Texi2HTML::Config::init_out = \&lilypond_init_out; @@ -564,6 +565,26 @@ sub lilypond_external_href($$$) my $page_toc_depth = 2; my @default_toc = []; + +# Initialize the toc_depth to 1 if the command-line option -D=short_toc is given +sub lilypond_init_toc_depth () +{ + if (exists($main::value{'short_toc'}) and not exists($main::value{'bigpage'})) { + $page_toc_depth = 1; + } +} +# We can't use a command-handler, because texinfo variables are not yet +# available at that stage: +# push @Texi2HTML::Config::command_handler_init, \&lilypond_init_toc_depth; + +# Initialize the toc_depth to 1 if the command-line option -D=short_toc is given +sub lilypond_init_out() +{ + my $rval = t2h_default_init_out(); + lilypond_init_toc_depth (); + return $rval; +} + # 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. @@ -708,6 +729,9 @@ sub lilypond_print_element_header sub lilypond_toc_body($) { my $elements_list = shift; + # Workaround: Initialize the toc-depth here, because init_out is called + # only later in texi2html 1.83 + lilypond_init_toc_depth (); # Generate a default TOC for pages without THIS_ELEMENT @default_toc = lilypond_generate_page_toc_body(@$elements_list[0]); return T2H_GPL_toc_body($elements_list); -- 2.39.2