2 # -*- coding: utf-8; -*-
4 ### texi2html customization script for LilyPond
5 ### Author: Reinhold Kainhofer <reinhold@kainhofer.com>, 2008.
6 ### Some code parts copied from texi2html and adapted. These functions
7 ### were written mainly by Patrice Dumas
11 ### Features implemented here:
12 ### -) For split manuals, the main page is index.html.
13 ### -) All @unnumbered* sections are placed into the same file
14 ### (implemented by split_at_numbered_sections)
15 ### -) Use our custom CSS file, with IE-specific fixes in another CSS file,
16 ### impelmented by lilypond_css_lines
17 ### -) TOC (folded, with the current page highlighted) in an overflown <div>
18 ### is added to every page; implemented by:
19 ### lilypond_print_element_header -- building of the TOC
20 ### lilypond_toc_body -- generation of customized TOC output
21 ### lilypond_print_page_head -- start <div id="main">
22 ### print_lilypond_page_foot -- closing id=main, output of footer & TOC
23 ### -) External refs are formatted only as "Text of the node" (not as >>see
24 ### "NODE" section "SECTION" in "BOOK"<< like with default texi2html). Also,
25 ### the leading "(book-name)" is removed.
26 ### Implemented by overriding lilypond_external_ref
27 ### -) Navigation bars on top/bottom of the page and between sections are not
28 ### left-aligned, but use a combination of left/center/right aligned table
29 ### cells; For this, I heavily extend the texi2html code to allow for
30 ### differently aligned cells and for multi-line tables);
31 ### Implemented in lilypond_print_navigation
32 ### -) Different formatting than the default: example uses the same formatting
34 ### -) Allow translated section titles: All section titles can be translated,
35 ### the original (English) title is associated with @translationof. This is
36 ### needed, because the file name / anchor is generated from the original
37 ### English title, since otherwise language-autoselection would break with
39 ### Since it is then no longer possible to obtain the file name from the
40 ### section title, I keep a sectionname<=>filename/anchor around. This way,
41 ### xrefs from other manuals can simply load that map and retrieve the
42 ### correct file name for the link. Implemented in:
43 ### lilypond_unknown (handling of @translationof, in case
44 ### extract_texi_filenames.py messes up...)
45 ### lilypond_element_file_name (correct file name: use the map)
46 ### lilypond_element_target_name (correct anchor: use the map)
47 ### lilypond_init_map (read in the externally created map from disk)
48 ### lilypond_external_href (load the map for xrefs, use the correct
50 ### -) The HTML anchors for all sections are derived from the node name /
51 ### section title (pre-generated in the .xref-map file). Implemented by:
52 ### lilypond_element_target_name (adjust section anchors)
53 ### -) Use the standard footnote format "<sup>nr</sup> text" instead of the
54 ### ugly format of texi2html (<h3>(nr)</h3><p>text</p>). Implemented in
55 ### makeinfo_like_foot_line_and_ref
56 ### makeinfo_like_foot_lines
57 ### makeinfo_like_paragraph
60 ### Useful helper functions:
61 ### -) texinfo_file_name($node_name): returns a texinfo-compatible file name
62 ### for the given string $node_name (whitespace trimmed/replaced by -,
63 ### non-standard chars replaced by _xxxx (ascii char code) and forced to
64 ### start with a letter by prepending t_g if necessary)
67 package Texi2HTML::Config;
69 #############################################################################
71 #############################################################################
74 my $LY_LANGUAGES = {};
75 $LY_LANGUAGES->{'fr'} = {
76 'Back to Documentation Index' => 'Retour à l\'accueil de la documentation',
78 $LY_LANGUAGES->{'es'} = {
79 'Back to Documentation Index' => 'Volver al índice de la documentación',
81 $LY_LANGUAGES->{'de'} = {
82 'Back to Documentation Index' => 'Zur Dokumentationsübersicht',
84 $LY_LANGUAGES->{'ja'} = {
85 'Back to Documentation Index' => 'ドキュメント インデックスに戻る',
89 sub ly_get_string () {
90 my $lang = $Texi2HTML::THISDOC{current_lang};
92 if ($lang and $lang ne "en" and $LY_LANGUAGES->{$lang}->{$string}) {
93 return $LY_LANGUAGES->{$lang}->{$string};
100 #############################################################################
101 ### SETTINGS FOR TEXI2HTML
102 #############################################################################
104 # Validation fix for texi2html<=1.82
105 $Texi2HTML::Config::DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
107 @Texi2HTML::Config::CSS_REFS = (
108 {FILENAME => "lilypond-web.css", TITLE => "Default style"},
109 {FILENAME => "lilypond-web-alt1.css", TITLE => "Alternate style 1"},
112 # GOP tweak: We don't have alternate stylesheets right now
113 #@Texi2HTML::Config::ALT_CSS_REFS = (
114 # {FILENAME => "lilypond.css", TITLE => "Andrew Hawryluk's design" },
115 # {FILENAME => "lilypond-blue.css", TITLE => "Kurt Kroon's blue design" },
118 $Texi2HTML::Config::USE_ACCESSKEY = 1;
119 $Texi2HTML::Config::USE_LINKS = 1;
120 $Texi2HTML::Config::USE_REL_REV = 1;
121 $Texi2HTML::Config::SPLIT_INDEX = 0;
122 $Texi2HTML::Config::SEPARATED_FOOTNOTES = 0; # Print footnotes on same page, not separated
123 # FIXME: remove for GOP
124 #if ($Texi2HTML::Config::SPLIT eq 'section') {
125 # $Texi2HTML::Config::element_file_name = \&lilypond_element_file_name;
129 # FIXME: creates duplicate anchors, which causes Opera to barf;
130 # should be fixed in lilypond-texi2html.init too
131 # $Texi2HTML::Config::element_target_name = \&lilypond_element_target_name;
132 $default_print_element_header = $Texi2HTML::Config::print_element_header;
133 $Texi2HTML::Config::print_element_header = \&lilypond_print_element_header;
134 $Texi2HTML::Config::print_page_foot = \&print_lilypond_page_foot;
135 $Texi2HTML::Config::print_navigation = \&lilypond_print_navigation;
136 $Texi2HTML::Config::external_ref = \&lilypond_external_ref;
137 $default_external_href = $Texi2HTML::Config::external_href;
138 $Texi2HTML::Config::external_href = \&lilypond_external_href;
139 $default_toc_body = $Texi2HTML::Config::toc_body;
140 $Texi2HTML::Config::toc_body = \&lilypond_toc_body;
141 $Texi2HTML::Config::css_lines = \&lilypond_css_lines;
142 $default_unknown = $Texi2HTML::Config::unknown;
143 $Texi2HTML::Config::unknown = \&lilypond_unknown;
144 $default_print_page_head = $Texi2HTML::Config::print_page_head;
145 $Texi2HTML::Config::print_page_head = \&lilypond_print_page_head;
146 # $Texi2HTML::Config::foot_line_and_ref = \&lilypond_foot_line_and_ref;
147 $Texi2HTML::Config::foot_line_and_ref = \&makeinfo_like_foot_line_and_ref;
148 $Texi2HTML::Config::foot_lines = \&makeinfo_like_foot_lines;
149 $Texi2HTML::Config::paragraph = \&makeinfo_like_paragraph;
153 # Examples should be formatted similar to quotes:
154 $Texi2HTML::Config::complex_format_map->{'example'} = {
155 'begin' => q{"<blockquote>"},
156 'end' => q{"</blockquote>\n"},
160 %Texi2HTML::config::misc_pages_targets = (
161 'Overview' => 'Overview',
162 'Contents' => 'Contents',
167 my @section_to_filename;
172 #############################################################################
174 #############################################################################
177 $Data::Dumper::Maxdepth = 2;
179 sub print_element_info($)
182 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
183 print "Element: $element\n";
184 print Dumper($element);
191 #############################################################################
193 #############################################################################
195 # Convert a given node name to its proper file name (normalization as explained
196 # in the texinfo manual:
197 # http://www.gnu.org/software/texinfo/manual/texinfo/html_node/HTML-Xref-Node-Name-Expansion.html
198 sub texinfo_file_name($)
202 # File name normalization by texinfo:
203 # 1/2: letters and numbers are left unchanged
204 # 3/4: multiple, leading and trailing whitespace is removed
205 $text = main::normalise_space($text);
206 # 5/6: all remaining spaces are converted to '-', all other 7- or 8-bit
207 # chars are replaced by _xxxx (xxxx=ascii character code)
208 while ($text ne '') {
209 if ($text =~ s/^([A-Za-z0-9]+)//o) { # number or letter stay unchanged
211 } elsif ($text =~ s/^ //o) { # space -> '-'
213 } elsif ($text =~ s/^(.)//o) { # Otherwise use _xxxx (ascii char code)
215 if ( $ccode <= 0xFFFF ) {
216 $result .= sprintf("_%04x", $ccode);
218 $result .= sprintf("__%06x", $ccode);
222 # 7: if name does not begin with a letter, prepend 't_g' (so it starts with a letter)
223 if ($result !~ /^[a-zA-Z]/) {
224 $result = 't_g' . $result;
231 # Load a file containing a nodename<=>filename map (tab-sepatared, i.e.
232 # NODENAME\tFILENAME\tANCHOR
233 # Returns a ref to a hash "Node title" => ["FilenameWithoutExt", "Anchor"]
234 sub load_map_file ($)
239 if (open(XREFFILE, $mapfile)) {
241 while ( $line = <XREFFILE> ) {
242 # parse the tab-separated entries and insert them into the map:
244 my @entries = split(/\t/, $line);
245 if (scalar (@entries) == 3) {
246 $node_map->{$entries[0]} = [$entries[1], $entries[2]];
248 print STDERR "Invalid entry in the node file $mapfile: $line\n";
253 print STDERR "WARNING: Unable to load the map file $mapfile\n";
259 # Split the given path into dir and basename (with .texi removed). Used mainly
260 # to get the path/basename of the original texi input file
261 sub split_texi_filename ($)
264 my ($docu_dir, $docu_name);
265 if ($docu =~ /(.*\/)/) {
266 chop($docu_dir = $1);
268 $docu_name =~ s/.*\///;
273 $docu_name =~ s/\.te?x(i|info)?$//;
274 return ($docu_dir, $docu_name);
281 #############################################################################
283 #############################################################################
285 # Include our standard CSS file, not hard-coded CSS code directly in the HTML!
286 # For IE, conditionally include the lilypond-ie-fixes.css style sheet
287 sub lilypond_css_lines ($$)
289 my $import_lines = shift;
290 my $rule_lines = shift;
291 return if (defined($Texi2HTML::THISDOC{'CSS_LINES'}));
292 if (@$rule_lines or @$import_lines)
294 $Texi2HTML::THISDOC{'CSS_LINES'} = "<style type=\"text/css\">\n<!--\n";
295 $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$import_lines) . "\n" if (@$import_lines);
296 $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$rule_lines) . "\n" if (@$rule_lines);
297 $Texi2HTML::THISDOC{'CSS_LINES'} .= "-->\n</style>\n";
299 foreach my $ref (@CSS_REFS)
301 $Texi2HTML::THISDOC{'CSS_LINES'} .= "<link rel=\"stylesheet\" type=\"text/css\" title=\"$ref->{TITLE}\" href=\"$ref->{FILENAME}\">\n";
304 # GOP tweak: We don't have alternate stylesheets
305 #foreach my $ref (@Texi2HTML::Config::ALT_CSS_REFS)
307 # $Texi2HTML::THISDOC{'CSS_LINES'} .= "<link rel=\"alternate stylesheet\" type=\"text/css\" href=\"$ref->{FILENAME}\" title=\"$ref->{TITLE}\">\n";
310 # GOP tweak: We aren't using an IE-specific stylesheet
311 #$Texi2HTML::THISDOC{'CSS_LINES'} .= "<!--[if lte IE 7]>\n<link href=\"lilypond-ie-fixes.css\" rel=\"stylesheet\" type=\"text/css\">\n<![endif]-->\n";
318 #############################################################################
319 ### SPLITTING BASED ON NUMBERED SECTIONS
320 #############################################################################
322 # FIXME: removed for GOP.
325 #############################################################################
326 ### CLEANER LINK TITLE FOR EXTERNAL REFS
327 #############################################################################
329 # The default formatting of external refs returns e.g.
330 # "(lilypond-internals)Timing_translator", so we remove all (...) from the
331 # file_and_node argument. Also, we want only a very simple format, so we don't
332 # even call the default handler!
333 sub lilypond_external_ref($$$$$$)
338 my $file_node = shift;
340 my $cross_ref = shift;
342 my $displaytext = '';
344 # 1) if we have a cross ref name, that's the text to be displayed:
345 # 2) For the top node, use the (printable) name of the manual, unless we
346 # have an explicit cross ref name
347 # 3) In all other cases use the section name
348 if ($cross_ref ne '') {
349 $displaytext = $cross_ref;
350 } elsif (($section eq '') or ($section eq 'Top')) {
351 $displaytext = $book;
353 $displaytext = $section;
356 $displaytext = &$anchor('', $href, $displaytext) if ($displaytext ne '');
357 return &$I('%{node_file_href}', { 'node_file_href' => $displaytext });
364 #############################################################################
365 ### HANDLING TRANSLATED SECTIONS: handle @translationof, secname<->filename
366 ### map stored on disk, xrefs in other manuals load that map
367 #############################################################################
370 # Try to make use of @translationof to generate files according to the original
371 # English section title...
372 sub lilypond_unknown($$$$$)
380 # the @translationof macro provides the original English section title,
381 # which should be used for file/anchor naming, while the title will be
382 # translated to each language
383 # It is already used by extract_texi_filenames.py, so this should not be
384 # necessary here at all. Still, I'll leave the code in just in case the
385 # python script messed up ;-)
386 if ($pass == 1 and $macro eq "translationof") {
387 if (ref($state->{'element'}) eq 'HASH') {
388 $state->{'element'}->{'translationof'} = main::normalise_space($line);
390 return ('', 1, undef, undef);
392 return &$default_unknown($macro, $line, $pass, $stack, $state);
399 my %translated_books = ();
400 # Construct a href to an external source of information.
401 # node is the node with texinfo @-commands
402 # node_id is the node transliterated and transformed as explained in the
404 # node_xhtml_id is the node transformed such that it is unique and can
405 # be used to make an html cross ref as explained in the texinfo manual
406 # file is the file in '(file)node'
407 sub lilypond_external_href($$$)
411 my $node_hxmlt_id = shift;
414 # 1) Keep a hash of book->section_map
415 # 2) if not file in keys hash => try to load the map (assign empty map if
416 # non-existent => will load only once!)
417 # 3) if node in the section=>(file, anchor) map, replace node_id and
418 # node_xhtml_id by the map's values
419 # 4) call the default_external_href with these values (or the old ones if not found)
421 if (($node_id ne '') and defined($file) and ($node_id ne 'Top')) {
422 my $map_name = $file;
423 $map_name =~ s/-big-page//;
425 # Load the map if we haven't done so already
426 if (!exists($translated_books{$map_name})) {
427 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
428 my $map_filename = main::locate_include_file ("${map_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
429 || main::locate_include_file ("${map_name}.xref-map");
430 $translated_books{$map_name} = load_map_file ($map_filename);
433 # look up translation. use these values instead of the old filename/anchor
434 my $section_name_map = $translated_books{$map_name};
435 my $node_text = main::remove_texi($node);
436 if (defined($section_name_map->{$node_text})) {
437 ($node_id, $node_hxmlt_id) = @{$section_name_map->{$node_text}};
439 print STDERR "WARNING: Unable to find node '$node_text' in book $map_name.\n";
444 return &$default_external_href($node, $node_id, $node_hxmlt_id, $file);
446 return &$default_external_href($node, $node_id, $node_hxmlt_id);
454 #############################################################################
455 ### CUSTOM TOC FOR EACH PAGE (in a frame on the left)
456 #############################################################################
458 my $page_toc_depth = 2;
459 my @default_toc = [];
462 # Initialize the toc_depth to 1 if the command-line option -D=short_toc is given
463 sub lilypond_init_toc_depth ()
465 if (exists($main::value{'short_toc'}) and not exists($main::value{'bigpage'})) {
469 # Set the TOC-depth (depending on a texinfo variable short_toc) in a
470 # command-handler, so we have them available when creating the pages
471 push @Texi2HTML::Config::command_handler_process, \&lilypond_init_toc_depth;
474 # recursively generate the TOC entries for the element and its children (which
475 # are only shown up to maxlevel. All ancestors of the current element are also
476 # shown with their immediate children, irrespective of their level.
477 # Unnumbered entries are only printed out if they are at top-level or 2nd level
478 # or their parent element is an ancestor of the currently viewed node.
479 # The conditions to call this method to print the entry for a child node is:
480 # -) the parent is an ancestor of the current page node
481 # -) the parent is a numbered element at top-level toplevel (i.e. show numbered
482 # and unnumbered 2nd-level children of numbered nodes)
483 # -) the child element is a numbered node below level maxlevel
484 sub generate_ly_toc_entries($$$)
487 my $element_path = shift;
489 #my $maxlevel = shift;
491 # Skip undefined sections, plus all sections generated by index splitting
492 return() if (not defined($element) or exists($element->{'index_page'}));
494 my $level = $element->{'toc_level'};
495 my $is_parent_of_current = $element->{'id'} && $element_path->{$element->{'id'}};
496 my $ind = ' ' x $level;
497 # GDP hack: leave this open for color
498 my $this_css_class = " class=\"";
499 $this_css_class .= $is_parent_of_current ? " toc_current" : "";
501 # GDP tweak: if the node name is in the color_X list
502 # TODO: use a hash, load from file?
503 # FIXME: load from file, to allow for translations!
507 "Learning", "Glossary", "Essay",
508 "Contact", "Tiny examples", "Bug reports"
511 "Features", "Examples", "Freedom",
512 "Unix", "MacOS X", "Windows",
513 "Notation", "Usage", "Snippets",
514 "Help us", "Development", "Authors"
517 "Productions", "Testimonials",
518 "Source", "Old downloads",
519 "FAQ", "Changes", "Internals",
520 "Publications", "Old news"
525 "Translated", "Old", "FDL"
528 my $addColor = " colorDefault";
529 foreach $color (@color_1) {
530 if ($element->{'text'} eq $color) {
531 $addColor = " color1";
534 foreach $color (@color_2) {
535 if ($element->{'text'} eq $color) {
536 $addColor = " color2";
539 foreach $color (@color_3) {
540 if ($element->{'text'} eq $color) {
541 $addColor = " color3";
544 foreach $color (@color_4) {
545 if ($element->{'text'} eq $color) {
546 $addColor = " color4";
550 $this_css_class .= $addColor . "\"";
555 my $entry = "$ind<li$this_css_class>" . &$anchor ($element->{'tocid'}, "$element->{'file'}#$element->{'target'}",$element->{'text'});
557 push (@result, $entry);
558 my $children = $element->{'section_childs'};
559 if (defined($children) and (ref($children) eq "ARRAY")) {
560 my $force_children = $is_parent_of_current or ($level == 1 and $element->{'number'});
561 my @child_result = ();
562 foreach my $c (@$children) {
563 my $is_numbered_child = defined ($c->{'number'});
564 my $below_maxlevel = $c->{'toc_level'} le $maxlevel;
565 if ($force_children or ($is_numbered_child and $below_maxlevel)) {
566 my @child_res = generate_ly_toc_entries($c, $element_path, $maxlevel);
567 push (@child_result, @child_res);
570 # if no child nodes were generated, e.g. for the index, where expanded pages
571 # are ignored, don't generate a list at all...
573 push (@result, "\n$ind<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
575 # GOP tweak: (next 2 lines; alternates)
576 push (@result, "$ind<li$this_css_class>" . &$anchor ($element->{'tocid'}, "$element->{'file'}#$element->{'target'}","(main)"));
577 #push (@result, "$ind<li$this_css_class>" . &$anchor ($element->{'tocid'}, "$element->{'file'}#$element->{'target'}","(".$element->{'text'}." main)"));
578 push (@result, @child_result);
579 push (@result, "$ind</ul>\n");
582 push (@result, "$ind</li>\n");
587 # Print a customized TOC, containing only the first two levels plus the whole
588 # path to the current page
589 sub lilypond_generate_page_toc_body($)
592 my $current_element = $element;
594 $parentelements{$element->{'id'}} = 1;
595 # Find the path to the current element
596 while ( defined($current_element->{'sectionup'}) and
597 ($current_element->{'sectionup'} ne $current_element) )
599 $parentelements{$current_element->{'sectionup'}->{'id'}} = 1
600 if ($current_element->{'sectionup'}->{'id'} ne '');
601 $current_element = $current_element->{'sectionup'};
603 return () if not defined($current_element);
604 # Create the toc entries recursively
606 my @toc_entries = ("<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
607 # my @toc_entries = ("<div class=\"contents\">\n", "<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
609 # FIXME: add link to main page, really hackily.
610 if ($element->{'sectionup'}) {
611 # it's not the top element
612 push (@toc_entries, "<li><a href=\"index.html\">Main</a></li>\n");
614 push (@toc_entries, "<li class=\"toc_current\"><a href=\"index.html\">Main</a></li>\n");
617 my $children = $current_element->{'section_childs'};
618 # FIXME: generate toc
619 foreach ( @$children ) {
620 push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth));
622 # FIXME: add search entry box
623 push (@toc_entries, "<li><form action=\"#\" method=\"get\"><input onfocus=\"this.value=''\" type=\"text\" name=\"search\" id=\"search\" value=\"Search\"></form></li>\n");
625 push (@toc_entries, "</ul>\n");
627 # push (@toc_entries, "</div>\n");
628 push (@toc_entries, "\n");
632 sub lilypond_print_toc_div ($$)
636 my @lines = @$tocref;
637 # use default TOC if no custom lines have been generated
638 @lines = @default_toc if (not @lines);
641 print $fh "\n\n<div id=\"tocframe\">\n";
642 #print $fh "<div class=\"contents\">\n";
644 # Remove the leading "GNU LilyPond --- " from the manual title
645 my $topname = $Texi2HTML::NAME{'Top'};
646 $topname =~ s/^GNU LilyPond(:| &[mn]dash;) //;
648 # construct the top-level Docs index (relative path and including language!)
649 my $lang = $Texi2HTML::THISDOC{current_lang};
650 if ($lang and $lang ne "en") {
656 $reldir = "../" if ($Texi2HTML::Config::SPLIT eq 'section');
657 my $uplink = $reldir."index.${lang}html";
659 # print $fh "<p class=\"toc_uplink\"><a href=\"$uplink\"
660 # title=\"Documentation Index\"><< " .
661 # &ly_get_string ('Back to Documentation Index') .
664 # print $fh '<h4 class="toc_header"> ' . &$anchor('',
665 # $Texi2HTML::HREF{'Top'},
667 # 'title="Start of the manual"'
671 foreach my $line (@lines) {
675 print $fh "</div>\n\n";
679 # Create the custom TOC for this page (partially folded, current page is
680 # highlighted) and store it in a global variable. The TOC is written out after
681 # the html contents (but positioned correctly using CSS), so that browsers with
682 # css turned off still show the contents first.
683 our @this_page_toc = ();
684 sub lilypond_print_element_header
686 my $first_in_page = shift;
687 my $previous_is_top = shift;
688 if ($first_in_page and not @this_page_toc) {
689 if (defined($Texi2HTML::THIS_ELEMENT)) {
690 # Create the TOC for this page
691 @this_page_toc = lilypond_generate_page_toc_body($Texi2HTML::THIS_ELEMENT);
694 return &$default_print_element_header( $first_in_page, $previous_is_top);
697 # Generate the HTML output for the TOC
698 sub lilypond_toc_body($)
700 my $elements_list = shift;
701 # Generate a default TOC for pages without THIS_ELEMENT
702 @default_toc = lilypond_generate_page_toc_body(@$elements_list[0]);
703 return &$default_toc_body($elements_list);
706 # Print out the TOC in a <div> at the beginning of the page
707 sub lilypond_print_page_head($)
710 &$default_print_page_head($fh);
711 print $fh "<div id=\"main\">\n";
714 # Print out the TOC in a <div>, which will be formatted as a
715 # sidebar mimicking a TOC frame
716 sub print_lilypond_page_foot($)
719 my $program_string = &$program_string();
720 # print $fh "<p><font size='-1'>$program_string</font><br>$PRE_BODY_CLOSE</p>\n";
722 # Do not include language selection in div#main
723 print $fh "<!-- end div#main here -->\n</div>\n\n";
725 print $fh "<!-- FOOTER -->\n\n";
726 print $fh "<div id=\"footer\">\n";
727 print $fh "<div id=\"language\">\n";
728 print $fh "<h3>Other languages</h3>\n";
729 print $fh "<p><a href=\"\">Deutsch</a>, Español, Français, Magyar.</p>\n";
730 print $fh "<p>About automatic language selection.</p>\n";
731 print $fh "</div>\n";
733 print $fh "<div id=\"verifier_texinfo\">\n";
734 print $fh "<h3>Validation</h3>\n";
735 print $fh "<p>Thanks to <a href=\"http://www.webdev.nl/\">webdev.nl</a>";
736 print $fh " for hosting <code>lilypond.org</code>.\n";
737 print $fh "<a href=\"http://validator.w3.org/check?uri=referer\">\n";
738 print $fh "<img src=\"http://www.w3.org/Icons/valid-html401\"\n";
739 print $fh " alt=\"Valid HTML 4.01 Transitional\"\n";
740 print $fh " height=\"31\" width=\"88\"></a></p>\n";
741 print $fh "<p>Web pages created with";
742 print $fh " <a href=\"http://www.gnu.org/software/texinfo/\">";
743 print $fh " GNU Texinfo</a>\n";
744 print $fh " and <a href=\"http://www.nongnu.org/texi2html/\">";
745 print $fh " texi2html</a>.</p>\n";
749 # Print the TOC frame and reset the TOC:
750 lilypond_print_toc_div ($fh, \@this_page_toc);
754 print $fh "</body>\n</html>\n";
761 #############################################################################
762 ### NICER / MORE FLEXIBLE NAVIGATION PANELS
763 #############################################################################
765 sub get_navigation_text
768 my $text = $NAVIGATION_TEXT{$button};
769 if ( ($button eq 'Back') or ($button eq 'FastBack') ) {
770 $text = $text . $Texi2HTML::NODE{$button} . " ";
771 } elsif ( ($button eq 'Forward') or ($button eq 'FastForward') ) {
772 $text = " " . $Texi2HTML::NODE{$button} . $text;
773 } elsif ( $button eq 'Up' ) {
774 $text = " ".$text.": " . $Texi2HTML::NODE{$button} . " ";
780 # Don't automatically create left-aligned table cells for every link, but
781 # instead create a <td> only on an appropriate '(left|right|center)-aligned-cell-n'
782 # button text. It's alignment as well as the colspan will be taken from the
783 # name of the button. Also, add 'newline' button text to create a new table
784 # row. The texts of the buttons are generated by get_navigation_text and
785 # will contain the name of the next/previous section/chapter.
786 sub lilypond_print_navigation
789 my $vertical = shift;
791 my $result = "<table class=\"nav_table\">\n";
793 $result .= "<tr>" unless $vertical;
795 foreach my $button (@$buttons)
797 $result .= qq{<tr valign="top" align="left">\n} if $vertical;
798 # Allow (left|right|center)-aligned-cell and newline as buttons!
799 if ( $button =~ /^(.*)-aligned-cell-(.*)$/ )
801 $result .= qq{</td>} unless $beginofline;
802 $result .= qq{<td valign="middle" align="$1" colspan="$2">};
805 elsif ( $button eq 'newline' )
807 $result .= qq{</td>} unless $beginofline;
808 $result .= qq{</tr>};
813 elsif (ref($button) eq 'CODE')
815 $result .= &$button($vertical);
817 elsif (ref($button) eq 'SCALAR')
819 $result .= "$$button" if defined($$button);
821 elsif (ref($button) eq 'ARRAY')
823 my $text = $button->[1];
824 my $button_href = $button->[0];
825 # verify that $button_href is simple text and text is a reference
826 if (defined($button_href) and !ref($button_href)
827 and defined($text) and (ref($text) eq 'SCALAR') and defined($$text))
829 if ($Texi2HTML::HREF{$button_href})
831 my $anchor_attributes = '';
832 if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button_href})) and ($BUTTONS_ACCESSKEY{$button_href} ne ''))
834 $anchor_attributes = "accesskey=\"$BUTTONS_ACCESSKEY{$button_href}\"";
836 if ($USE_REL_REV and (defined($BUTTONS_REL{$button_href})) and ($BUTTONS_REL{$button_href} ne ''))
838 $anchor_attributes .= " rel=\"$BUTTONS_REL{$button_href}\"";
842 $Texi2HTML::HREF{$button_href},
843 get_navigation_text($$text),
849 $result .= get_navigation_text($$text);
853 elsif ($button eq ' ')
854 { # handle space button
856 ($ICONS && $ACTIVE_ICONS{' '}) ?
857 &$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{' '}) :
858 $NAVIGATION_TEXT{' '};
861 elsif ($Texi2HTML::HREF{$button})
863 my $btitle = $BUTTONS_GOTO{$button} ?
864 'title="' . $BUTTONS_GOTO{$button} . '"' : '';
865 if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button})) and ($BUTTONS_ACCESSKEY{$button} ne ''))
867 $btitle .= " accesskey=\"$BUTTONS_ACCESSKEY{$button}\"";
869 if ($USE_REL_REV and (defined($BUTTONS_REL{$button})) and ($BUTTONS_REL{$button} ne ''))
871 $btitle .= " rel=\"$BUTTONS_REL{$button}\"";
873 if ($ICONS && $ACTIVE_ICONS{$button})
877 $Texi2HTML::HREF{$button},
878 &$button_icon_img($BUTTONS_NAME{$button},
879 $ACTIVE_ICONS{$button},
880 $Texi2HTML::SIMPLE_TEXT{$button}),
889 $Texi2HTML::HREF{$button},
890 get_navigation_text($button),
897 { # button is passive
899 $ICONS && $PASSIVE_ICONS{$button} ?
900 &$button_icon_img($BUTTONS_NAME{$button},
901 $PASSIVE_ICONS{$button},
902 $Texi2HTML::SIMPLE_TEXT{$button}) :
904 "[" . get_navigation_text($button) . "]";
906 $result .= "</td>\n" if $vertical;
907 $result .= "</tr>\n" if $vertical;
909 $result .= "</td>" unless $beginofline;
910 $result .= "</tr>" unless $vertical;
911 $result .= "</table>\n";
917 @Texi2HTML::Config::SECTION_BUTTONS =
918 ('left-aligned-cell-1', 'FastBack',
919 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
920 'right-aligned-cell-1', 'FastForward',
922 'left-aligned-cell-2', 'Back',
923 'center-aligned-cell-1', 'Up',
924 'right-aligned-cell-2', 'Forward'
927 # buttons for misc stuff
928 @Texi2HTML::Config::MISC_BUTTONS = ('center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About');
930 # buttons for chapter file footers
931 # (and headers but only if SECTION_NAVIGATION is false)
932 @Texi2HTML::Config::CHAPTER_BUTTONS =
933 ('left-aligned-cell-1', 'FastBack',
934 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
935 'right-aligned-cell-1', 'FastForward',
938 # buttons for section file footers
939 @Texi2HTML::Config::SECTION_FOOTER_BUTTONS =
940 ('left-aligned-cell-1', 'FastBack',
941 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
942 'right-aligned-cell-1', 'FastForward',
944 'left-aligned-cell-2', 'Back',
945 'center-aligned-cell-1', 'Up',
946 'right-aligned-cell-2', 'Forward'
949 @Texi2HTML::Config::NODE_FOOTER_BUTTONS =
950 ('left-aligned-cell-1', 'FastBack',
951 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
952 'right-aligned-cell-1', 'FastForward',
954 'left-aligned-cell-2', 'Back',
955 'center-aligned-cell-1', 'Up',
956 'right-aligned-cell-2', 'Forward'
963 #############################################################################
964 ### FOOTNOTE FORMATTING
965 #############################################################################
967 # Format footnotes in a nicer way: Instead of printing the number in a separate
968 # (nr) heading line, use the standard way of prepending <sup>nr</sup> immediately
969 # before the fn text.
972 # The following code is copied from texi2html's examples/makeinfo.init and
973 # should be updated when texi2html makes some changes there!
975 my $makekinfo_like_footnote_absolute_number = 0;
977 sub makeinfo_like_foot_line_and_ref($$$$$$$$)
979 my $foot_num = shift;
980 my $relative_num = shift;
983 my $from_file = shift;
984 my $footnote_file = shift;
988 $makekinfo_like_footnote_absolute_number++;
990 # this is a bit obscure, this allows to add an anchor only if formatted
991 # as part of the document.
992 $docid = '' if ($state->{'outside_document'} or $state->{'multiple_pass'});
994 if ($from_file eq $footnote_file)
996 $from_file = $footnote_file = '';
999 my $foot_anchor = "<sup>" . &$anchor($docid, "$footnote_file#$footid", $relative_num) . "</sup>";
1000 $foot_anchor = &$anchor($docid, "$footnote_file#$footid", "($relative_num)") if ($state->{'preformatted'});
1002 # unshift @$lines, "<li>";
1003 # push @$lines, "</li>\n";
1004 return ($lines, $foot_anchor);
1007 sub makeinfo_like_foot_lines($)
1010 unshift @$lines, "<hr>\n<h4>$Texi2HTML::I18n::WORDS->{'Footnotes_Title'}</h4>\n";
1011 #<ol type=\"1\">\n";
1012 # push @$lines, "</ol>";
1016 my %makekinfo_like_paragraph_in_footnote_nr;
1018 sub makeinfo_like_paragraph ($$$$$$$$$$$$$)
1023 my $paragraph_command = shift;
1024 my $paragraph_command_formatted = shift;
1025 my $paragraph_number = shift;
1027 my $item_nr = shift;
1028 my $enumerate_style = shift;
1030 my $command_stack_at_end = shift;
1031 my $command_stack_at_begin = shift;
1033 #print STDERR "format: $format\n" if (defined($format));
1034 #print STDERR "paragraph @$command_stack_at_end; @$command_stack_at_begin\n";
1035 $paragraph_command_formatted = '' if (!defined($paragraph_command_formatted) or
1036 exists($special_list_commands{$format}->{$paragraph_command}));
1037 return '' if ($text =~ /^\s*$/);
1038 foreach my $style(t2h_collect_styles($command_stack_at_begin))
1040 $text = t2h_begin_style($style, $text);
1042 foreach my $style(t2h_collect_styles($command_stack_at_end))
1044 $text = t2h_end_style($style, $text);
1046 if (defined($paragraph_number) and defined($$paragraph_number))
1048 $$paragraph_number++;
1049 return $text if (($format eq 'itemize' or $format eq 'enumerate') and
1050 ($$paragraph_number == 1));
1055 $open .= " align=\"$paragraph_style{$align}\"";
1057 my $footnote_text = '';
1058 if (defined($command_stack_at_begin->[0]) and $command_stack_at_begin->[0] eq 'footnote')
1060 my $state = $Texi2HTML::THISDOC{'state'};
1061 $makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number}++;
1062 if ($makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number} <= 1)
1064 $open.=' class="footnote"';
1065 my $document_file = $state->{'footnote_document_file'};
1066 if ($document_file eq $state->{'footnote_footnote_file'})
1068 $document_file = '';
1070 my $docid = $state->{'footnote_place_id'};
1071 my $doc_state = $state->{'footnote_document_state'};
1072 $docid = '' if ($doc_state->{'outside_document'} or $doc_state->{'multiple_pass'});
1073 my $foot_label = &$anchor($state->{'footnote_footnote_id'},
1074 $document_file . "#$state->{'footnote_place_id'}",
1075 "$state->{'footnote_number_in_page'}");
1076 $footnote_text = "<small>[${foot_label}]</small> ";
1079 return $open.'>'.$footnote_text.$text.'</p>';
1083 #############################################################################
1085 #############################################################################
1087 # For split pages, use index.html as start page!
1088 if ($Texi2HTML::Config::SPLIT eq 'section') {
1089 $Texi2HTML::Config::TOP_FILE = 'index.html';