3 ### texi2html customization script for Lilypond
4 ### Author: Reinhold Kainhofer <reinhold@kainhofer.com>, 2008.
5 ### Some code parts copied from texi2html and adapted.
9 ### Features implemented here:
10 ### -) For split manuals, the main page is index.html.
11 ### -) All @unnumbered* sections are placed into the same file
12 ### (implemented by split_at_numbered_sections)
13 ### -) Use our custom CSS file, with IE-specific fixes in another CSS file,
14 ### impelmented by lilypond_css_lines
15 ### -) TOC (folded, with the current page highlighted) in an overflown <div>
16 ### is added to every page; implemented by:
17 ### lilypond_print_element_header -- building of the TOC
18 ### lilypond_toc_body -- generation of customized TOC output
19 ### lilypond_print_page_head -- start <div id="main">
20 ### print_lilypond_page_foot -- closing id=main, output of footer & TOC
21 ### -) External refs are formatted only as "Text of the node" (not as >>see
22 ### "NODE" section "SECTION" in "BOOK"<< like with default texi2html). Also,
23 ### the leading "(book-name)" is removed.
24 ### Implemented by overriding lilypond_external_ref
25 ### -) Navigation bars on top/bottom of the page and between sections are not
26 ### left-aligned, but use a combination of left/center/right aligned table
27 ### cells; For this, I heavily extend the texi2html code to allow for
28 ### differently aligned cells and for multi-line tables);
29 ### Implemented in lilypond_print_navigation
30 ### -) Different formatting than the default: example uses the same formatting
32 ### -) Allow translated section titles: All section titles can be translated,
33 ### the original (English) title is associated with @translationof. This is
34 ### needed, because the file name / anchor is generated from the original
35 ### English title, since otherwise language-autoselection would break with
37 ### Since it is then no longer possible to obtain the file name from the
38 ### section title, I keep a sectionname<=>filename/anchor around. This way,
39 ### xrefs from other manuals can simply load that map and retrieve the
40 ### correct file name for the link. Implemented in:
41 ### lilypond_unknown (handling of @translationof, in case
42 ### extract_texi_filenames.py messes up...)
43 ### lilypond_element_file_name (correct file name: use the map)
44 ### lilypond_element_target_name (correct anchor: use the map)
45 ### lilypond_init_map (read in the externally created map from disk)
46 ### lilypond_external_href (load the map for xrefs, use the correct
48 ### -) The HTML anchors for all sections are derived from the node name /
49 ### section title (pre-generated in the .xref-map file). Implemented by:
50 ### lilypond_element_target_name (adjust section anchors)
51 ### -) Use the standard footnote format "<sup>nr</sup> text" instead of the
52 ### ugly format of texi2html (<h3>(nr)</h3><p>text</p>). Implemented in
53 ### lilypond_foot_line_and_ref
56 ### Useful helper functions:
57 ### -) texinfo_file_name($node_name): returns a texinfo-compatible file name
58 ### for the given string $node_name (whitespace trimmed/replaced by -,
59 ### non-standard chars replaced by _xxxx (ascii char code) and forced to
60 ### start with a letter by prepending t_g if necessary)
63 package Texi2HTML::Config;
69 #############################################################################
70 ### SETTINGS FOR TEXI2HTML
71 #############################################################################
73 @Texi2HTML::Config::CSS_REFS = ("lilypond.css");
74 $Texi2HTML::Config::USE_ACCESSKEY = 1;
75 $Texi2HTML::Config::USE_LINKS = 1;
76 $Texi2HTML::Config::USE_REL_REV = 1;
77 $Texi2HTML::Config::SEPARATED_FOOTNOTES = 0; # Print footnotes on same page, not separated
78 $Texi2HTML::Config::element_file_name = \&lilypond_element_file_name;
79 $Texi2HTML::Config::element_target_name = \&lilypond_element_target_name;
80 $Texi2HTML::Config::print_element_header = \&lilypond_print_element_header;
81 $Texi2HTML::Config::print_page_foot = \&print_lilypond_page_foot;
82 $Texi2HTML::Config::print_navigation = \&lilypond_print_navigation;
83 $Texi2HTML::Config::external_ref = \&lilypond_external_ref;
84 $Texi2HTML::Config::external_href = \&lilypond_external_href;
85 $Texi2HTML::Config::toc_body = \&lilypond_toc_body;
86 $Texi2HTML::Config::css_lines = \&lilypond_css_lines;
87 $Texi2HTML::Config::unknown = \&lilypond_unknown;
88 $Texi2HTML::Config::print_page_head = \&lilypond_print_page_head;
89 $Texi2HTML::Config::foot_line_and_ref = \&lilypond_foot_line_and_ref;
91 # Examples should be formatted similar to quotes:
92 $Texi2HTML::Config::complex_format_map->{'example'} = {
93 'begin' => q{"<blockquote><pre class=\"example\">"},
94 'end' => q{"</pre></blockquote>\n"},
97 %Texi2HTML::config::misc_pages_targets = (
98 'Overview' => 'Overview',
99 'Contents' => 'Contents',
104 my @section_to_filename;
109 #############################################################################
111 #############################################################################
114 $Data::Dumper::Maxdepth = 2;
116 sub print_element_info($)
119 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
120 print "Element: $element\n";
121 print Dumper($element);
128 #############################################################################
130 #############################################################################
132 # Convert a given node name to its proper file name (normalization as explained
133 # in the texinfo manual:
134 # http://www.gnu.org/software/texinfo/manual/texinfo/html_node/HTML-Xref-Node-Name-Expansion.html
135 sub texinfo_file_name($)
139 # File name normalization by texinfo:
140 # 1/2: letters and numbers are left unchanged
141 # 3/4: multiple, leading and trailing whitespace is removed
142 $text = main::normalise_space($text);
143 # 5/6: all remaining spaces are converted to '-', all other 7- or 8-bit
144 # chars are replaced by _xxxx (xxxx=ascii character code)
145 while ($text ne '') {
146 if ($text =~ s/^([A-Za-z0-9]+)//o) { # number or letter stay unchanged
148 } elsif ($text =~ s/^ //o) { # space -> '-'
150 } elsif ($text =~ s/^(.)//o) { # Otherwise use _xxxx (ascii char code)
152 if ( $ccode <= 0xFFFF ) {
153 $result .= sprintf("_%04x", $ccode);
155 $result .= sprintf("__%06x", $ccode);
159 # 7: if name does not begin with a letter, prepend 't_g' (so it starts with a letter)
160 if ($result !~ /^[a-zA-Z]/) {
161 $result = 't_g' . $result;
168 # Load a file containing a nodename<=>filename map (tab-sepatared, i.e.
169 # NODENAME\tFILENAME\tANCHOR
170 # Returns a ref to a hash "Node title" => ["FilenameWithoutExt", "Anchor"]
171 sub load_map_file ($)
176 if (open(XREFFILE, $mapfile)) {
178 while ( $line = <XREFFILE> ) {
179 # parse the tab-separated entries and insert them into the map:
181 my @entries = split(/\t/, $line);
182 if (scalar (@entries) == 3) {
183 $node_map->{$entries[0]} = [$entries[1], $entries[2]];
185 print STDERR "Invalid entry in the node file $mapfile: $line\n";
190 print STDERR "WARNING: Unable to load the map file $mapfile\n";
196 # Split the given path into dir and basename (with .texi removed). Used mainly
197 # to get the path/basename of the original texi input file
198 sub split_texi_filename ($)
201 my $docu_dir, $docu_name;
202 if ($docu =~ /(.*\/)/) {
203 chop($docu_dir = $1);
205 $docu_name =~ s/.*\///;
210 $docu_name =~ s/\.te?x(i|info)?$//;
211 return ($docu_dir, $docu_name);
218 #############################################################################
220 #############################################################################
222 # Include our standard CSS file, not hard-coded CSS code directly in the HTML!
223 # For IE, conditionally include the lilypond-ie-fixes.css style sheet
224 sub lilypond_css_lines ($$)
226 my $import_lines = shift;
227 my $rule_lines = shift;
228 return if (defined($CSS_LINES));
229 if (@$rule_lines or @$import_lines)
231 $CSS_LINES = "<style type=\"text/css\">\n<!--\n";
232 $CSS_LINES .= join('',@$import_lines) . "\n" if (@$import_lines);
233 $CSS_LINES .= join('',@$rule_lines) . "\n" if (@$rule_lines);
234 $CSS_LINES .= "-->\n</style>\n";
236 foreach my $ref (@CSS_REFS)
238 $CSS_LINES .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"$ref\">\n";
240 $CSS_LINES .= "<!--[if lte IE 7]>\n<link href=\"lilypond-ie-fixes.css\" rel=\"stylesheet\" type=\"text/css\">\n<![endif]-->\n";
247 #############################################################################
248 ### SPLITTING BASED ON NUMBERED SECTIONS
249 #############################################################################
253 my $node_to_filename_map = ();
256 # This function makes sure that files are only generated for numbered sections,
257 # but not for unnumbered ones. It is called after texi2html has done its own
258 # splitting and simply returns the filename for the node given as first argument
259 # Nodes with the same filename will be printed out to the same filename, so
260 # this really all we need. Also, make sure that the file names for sections
261 # are derived from the section title. We also might want to name the anchors
262 # according to node titles, which works by simply overriding the id element of
264 # If an external nodename<=>filename/anchor map file is found (loaded in
265 # lilypond_init_out, use the externally created values, otherwise use the
267 sub lilypond_element_file_name($$$)
271 my $docu_name = shift;
272 my $docu_ext = $Texi2HTML::Config::EXTENSION;
274 my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
275 # the snippets page does not use nodes for the snippets, so in this case
276 # we'll have to use the section name!
277 if ($node_name eq '') {
278 $node_name = main::remove_texi($element->{'texi'});
281 # If we have an entry in the section<=>filename map, use that one, otherwise
282 # generate the filename/anchor here. In the latter case, external manuals
283 # will not be able to retrieve the file name for xrefs!!! Still, I already
284 # had that code, so I'll leave it in in case something goes wrong with the
285 # extract_texi_filenames.py script in the lilypond build process!
286 if (exists ($node_to_filename_map->{$node_name})) {
287 (my $filename, my $anchor) = @{$node_to_filename_map->{$node_name}};
288 $filename .= ".$docu_ext" if (defined($docu_ext));
290 # unnumbered sections (except those at top-level!) always go to the same
291 # file as the previous numbered section
292 if (not ($element->{number}) and not ($lastfilename eq '') and ($element->{level} > 1)) {
293 $filename = $lastfilename;
295 if (($filename eq $lastfilename)) {
296 $$element{doc_nr} = $docnr;
299 $$element{doc_nr} = $docnr;
300 $lastfilename = $filename;
304 } elsif ($type eq "top" or $type eq "toc" or $type eq "doc" or $type eq "stoc" or $type eq "foot" or $type eq "about") {
307 print STDERR "WARNING: Node '$node_name' was NOT found in the map\n"
308 unless ($node_name eq '') or ($element->{'tag'} eq 'unnumberedsec')
309 or ($node_name =~ /NOT REALLY USED/);
311 # Numbered sections will get a filename Node_title, unnumbered sections will use
312 # the file name of the previous numbered section:
313 if (($element->{number}) or ($lastfilename eq '') or ($element->{level} == 1)) {
314 # normalize to the same file name as texinfo
315 if ($element->{translationof}) {
316 $node_name = main::remove_texi($element->{translationof});
318 my $filename = texinfo_file_name($node_name);
319 $filename .= ".$docu_ext" if (defined($docu_ext));
321 $$element{doc_nr} = $docnr;
322 $lastfilename = $filename;
325 $$element{doc_nr} = $docnr;
326 return $lastfilename;
333 sub lilypond_element_target_name($$$)
338 # Target is based on node name (or sec name for secs without node attached)
339 my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
340 if ($node_name eq '') {
341 $node_name = main::remove_texi($element->{'texi'});
344 # If we have an entry in the section<=>filename map, use that one, otherwise
345 # generate the anchor here.
346 if (exists ($node_to_filename_map->{$node_name})) {
347 (my $filename, $target) = @{$node_to_filename_map->{$node_name}};
349 my $anchor = $node_name;
350 if ($element->{translationof}) {
351 $anchor = main::remove_texi($element->{translationof});
353 # normalize to the same file name as texinfo
354 $target = texinfo_file_name($anchor);
356 # TODO: Once texi2html correctly prints out the target and not the id for
357 # the sections, change this back to ($id, $target)
358 return ($target, $target);
362 ## Load the map file for the corrently processed texi file. We do this
363 # using a command init handler, since texi2html does not have any
364 # other hooks that are called after THISDOC is filled but before phase 2
365 # of the texi2html conversion.
366 sub lilypond_init_map ()
368 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
369 my $map_filename = main::locate_include_file ("${docu_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
370 || main::locate_include_file ("${docu_name}.xref-map");
371 $node_to_filename_map = load_map_file ($map_filename);
373 push @Texi2HTML::Config::command_handler_init, \&lilypond_init_map;
377 #############################################################################
378 ### CLEANER LINK TITLE FOR EXTERNAL REFS
379 #############################################################################
381 # The default formatting of external refs returns e.g.
382 # "(lilypond-internals)Timing_translator", so we remove all (...) from the
383 # file_and_node argument. Also, we want only a very simple format, so we don't
384 # even call the default handler!
385 sub lilypond_external_ref($$$$$$)
390 my $file_node = shift;
392 my $cross_ref = shift;
394 my $displaytext = '';
396 # 1) if we have a cross ref name, that's the text to be displayed:
397 # 2) For the top node, use the (printable) name of the manual, unless we
398 # have an explicit cross ref name
399 # 3) In all other cases use the section name
400 if ($cross_ref ne '') {
401 $displaytext = $cross_ref;
402 } elsif (($section eq '') or ($section eq 'Top')) {
403 $displaytext = $book;
405 $displaytext = $section;
408 $displaytext = &$anchor('', $href, $displaytext) if ($displaytext ne '');
409 return &$I('%{node_file_href}', { 'node_file_href' => $displaytext });
411 # Default: format as "see <a ..>NODE</a> section 'SECTION' in BOOK". We don't want this!
412 # return t2h_default_external_ref($type, $section, $book, $file_node, $href, $cross_ref);
419 #############################################################################
420 ### HANDLING TRANSLATED SECTIONS: handle @translationof, secname<->filename
421 ### map stored on disk, xrefs in other manuals load that map
422 #############################################################################
425 # Try to make use of @translationof to generate files according to the original
426 # English section title...
427 sub lilypond_unknown($$$$$)
435 # the @translationof macro provides the original English section title,
436 # which should be used for file/anchor naming, while the title will be
437 # translated to each language
438 # It is already used by extract_texi_filenames.py, so this should not be
439 # necessary here at all. Still, I'll leave the code in just in case the
440 # python script messed up ;-)
441 if ($pass == 1 and $macro eq "translationof") {
442 if (ref($state->{'element'}) eq 'HASH') {
443 $state->{'element'}->{'translationof'} = main::normalise_space($line);
445 return ('', true, undef, undef);
447 return t2h_default_unknown($macro, $line, $pass, $stack, $state);
454 my %translated_books = ();
455 # Construct a href to an external source of information.
456 # node is the node with texinfo @-commands
457 # node_id is the node transliterated and transformed as explained in the
459 # node_xhtml_id is the node transformed such that it is unique and can
460 # be used to make an html cross ref as explained in the texinfo manual
461 # file is the file in '(file)node'
462 sub lilypond_external_href($$$)
466 my $node_hxmlt_id = shift;
468 my $original_func = \&t2h_default_external_href;
470 # 1) Keep a hash of book->section_map
471 # 2) if not file in keys hash => try to load the map (assign empty map if
472 # non-existent => will load only once!)
473 # 3) if node in the section=>(file, anchor) map, replace node_id and
474 # node_xhtml_id by the map's values
475 # 4) call the t2h_default_external_href with these values (or the old ones if not found)
477 if (($node_id ne '') and defined($file) and ($node_id ne 'Top')) {
478 my $map_name = $file;
479 $map_name =~ s/-big-page//;
481 # Load the map if we haven't done so already
482 if (!exists($translated_books{$map_name})) {
483 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
484 my $map_filename = main::locate_include_file ("${map_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
485 || main::locate_include_file ("${map_name}.xref-map");
486 $translated_books{$map_name} = load_map_file ($map_filename);
489 # look up translation. use these values instead of the old filename/anchor
490 my $section_name_map = $translated_books{$map_name};
491 my $node_text = main::remove_texi($node);
492 if (defined($section_name_map->{$node_text})) {
493 ($node_id, $node_hxmlt_id) = @{$section_name_map->{$node_text}};
495 print STDERR "WARNING: Unable to find node '$node_text' in book $map_name.\n";
500 return &$original_func($node, $node_id, $node_hxmlt_id, $file);
502 return &$original_func($node, $node_id, $node_hxmlt_id);
510 #############################################################################
511 ### CUSTOM TOC FOR EACH PAGE (in a frame on the left)
512 #############################################################################
514 my $page_toc_depth = 2;
515 my @default_toc = [];
517 # recursively generate the TOC entries for the element and its children (which
518 # are only shown up to maxlevel. All ancestors of the current element are also
519 # shown with their immediate children, irrespective of their level.
520 # Unnumbered entries are only printed out if they are at top-level or their
521 # parent element is an ancestor of the currently viewed node.
522 sub generate_ly_toc_entries($$$$)
525 my $element_path = shift;
526 my $maxlevel = shift;
527 my $always_show_unnumbered_children = shift;
528 # Skip undefined sections, plus all sections generated by index splitting
529 return() if (not defined($element) or exists($element->{'index_page'}));
531 my $level = $element->{'toc_level'};
532 my $is_parent_of_current = $element->{'id'} && $element_path->{$element->{'id'}};
533 my $print_children = ( ($level < $maxlevel) or $is_parent_of_current );
534 my $ind = ' ' x $level;
535 my $this_css_class = $is_parent_of_current ? " class=\"toc_current\"" : "";
537 my $entry = "$ind<li$this_css_class>" . &$anchor ($element->{'tocid'}, "$element->{'file'}#$element->{'target'}",$element->{'text'});
539 my $children = $element->{'section_childs'};
540 # Don't add unnumbered entries, unless they are at top-level or a parent of the current!
541 if (not ($element->{'number'} or $always_show_unnumbered_children)) {
544 if ( $print_children and defined($children) and (ref($children) eq "ARRAY") ) {
545 push (@result, $entry);
546 my @child_result = ();
547 foreach (@$children) {
548 push (@child_result, generate_ly_toc_entries($_, $element_path, $maxlevel, $is_parent_of_current));
550 # if no child nodes were generated, e.g. for the index, where expanded pages
551 # are ignored, don't generate a list at all...
553 push (@result, "\n$ind<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
554 push (@result, @child_result);
555 push (@result, "$ind</ul></li>\n");
558 push (@result, $entry . "</li>\n");
564 # Print a customized TOC, containing only the first two levels plus the whole
565 # path to the current page
566 sub lilypond_generate_page_toc_body($)
569 my $current_element = $element;
571 $parentelements{$element->{'id'}} = 1;
572 # Find the path to the current element
573 while ( defined($current_element->{'sectionup'}) and
574 ($current_element->{'sectionup'} ne $current_element) )
576 $parentelements{$current_element->{'sectionup'}->{'id'}} = 1
577 if ($current_element->{'sectionup'}->{'id'} ne '');
578 $current_element = $current_element->{'sectionup'};
580 return () if not defined($current_element);
581 # Create the toc entries recursively
582 my @toc_entries = ("<div class=\"contents\">\n", "<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
583 my $children = $current_element->{'section_childs'};
584 foreach ( @$children ) {
585 push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth, False));
587 push (@toc_entries, "</ul>\n");
588 push (@toc_entries, "</div>\n");
592 sub lilypond_print_toc_div ($$)
596 my @lines = @$tocref;
597 # use default TOC if no custom lines have been generated
598 @lines = @default_toc if (not @lines);
600 print $fh "\n\n<div id=\"tocframe\">\n";
601 print $fh '<h4> ' . $Texi2HTML::NAME{'Contents'} . "</h4>\n";
602 foreach my $line (@lines) {
605 print $fh "</div>\n\n";
609 # Create the custom TOC for this page (partially folded, current page is
610 # highlighted) and store it in a global variable. The TOC is written out after
611 # the html contents (but positioned correctly using CSS), so that browsers with
612 # css turned off still show the contents first.
613 our @this_page_toc = ();
614 sub lilypond_print_element_header
617 my $first_in_page = shift;
618 my $previous_is_top = shift;
619 if ($first_in_page and not @this_page_toc) {
620 if (defined($Texi2HTML::THIS_ELEMENT)) {
621 # Create the TOC for this page
622 @this_page_toc = lilypond_generate_page_toc_body($Texi2HTML::THIS_ELEMENT);
625 return T2H_DEFAULT_print_element_header( $fh, $first_in_page, $previous_is_top);
628 # Generate the HTML output for the TOC
629 sub lilypond_toc_body($)
631 my $elements_list = shift;
632 # Generate a default TOC for pages without THIS_ELEMENT
633 @default_toc = lilypond_generate_page_toc_body(@$elements_list[0]);
634 return T2H_GPL_toc_body($elements_list);
637 # Print out the TOC in a <div> at the beginning of the page
638 sub lilypond_print_page_head($)
641 T2H_DEFAULT_print_page_head($fh);
642 print $fh "<div id=\"main\">\n";
645 # Print out the TOC in a <div> at the end of th page, which will be formatted as a
646 # sidebar mimicking a TOC frame
647 sub print_lilypond_page_foot($)
650 my $program_string = &$program_string();
651 print $fh "<p><font size='-1'>$program_string</font><br>$PRE_BODY_CLOSE</p>\n";
652 print $fh "<!-- FOOTER -->\n\n";
653 print $fh "<!-- end div#main here -->\n</div>\n\n";
655 # Print the TOC frame and reset the TOC:
656 lilypond_print_toc_div ($fh, \@this_page_toc);
660 print $fh "</body>\n</html>\n";
667 #############################################################################
668 ### NICER / MORE FLEXIBLE NAVIGATION PANELS
669 #############################################################################
671 sub get_navigation_text
674 my $text = $NAVIGATION_TEXT{$button};
675 if ( ($button eq 'Back') or ($button eq 'FastBack') ) {
676 $text = $text . $Texi2HTML::NODE{$button} . " ";
677 } elsif ( ($button eq 'Forward') or ($button eq 'FastForward') ) {
678 $text = " " . $Texi2HTML::NODE{$button} . $text;
679 } elsif ( $button eq 'Up' ) {
680 $text = " ".$text.": " . $Texi2HTML::NODE{$button} . " ";
686 # Don't automatically create left-aligned table cells for every link, but
687 # instead create a <td> only on an appropriate '(left|right|center)-aligned-cell-n'
688 # button text. It's alignment as well as the colspan will be taken from the
689 # name of the button. Also, add 'newline' button text to create a new table
690 # row. The texts of the buttons are generated by get_navigation_text and
691 # will contain the name of the next/previous section/chapter.
692 sub lilypond_print_navigation
696 my $vertical = shift;
698 # print $fh '<table cellpadding="', $spacing, '" cellspacing="', $spacing,
699 # "\" border=\"0\" class=\"nav_table\">\n";
700 print $fh "<table class=\"nav_table\">\n";
702 print $fh "<tr>" unless $vertical;
704 foreach my $button (@$buttons)
706 print $fh qq{<tr valign="top" align="left">\n} if $vertical;
707 # Allow (left|right|center)-aligned-cell and newline as buttons!
708 if ( $button =~ /^(.*)-aligned-cell-(.*)$/ )
710 print $fh qq{</td>} unless $beginofline;
711 print $fh qq{<td valign="middle" align="$1" colspan="$2">};
714 elsif ( $button eq 'newline' )
716 print $fh qq{</td>} unless $beginofline;
722 elsif (ref($button) eq 'CODE')
724 &$button($fh, $vertical);
726 elsif (ref($button) eq 'SCALAR')
728 print $fh "$$button" if defined($$button);
730 elsif (ref($button) eq 'ARRAY')
732 my $text = $button->[1];
733 my $button_href = $button->[0];
734 # verify that $button_href is simple text and text is a reference
735 if (defined($button_href) and !ref($button_href)
736 and defined($text) and (ref($text) eq 'SCALAR') and defined($$text))
738 if ($Texi2HTML::HREF{$button_href})
740 my $anchor_attributes = '';
741 if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button_href})) and ($BUTTONS_ACCESSKEY{$button_href} ne ''))
743 $anchor_attributes = "accesskey=\"$BUTTONS_ACCESSKEY{$button_href}\"";
745 if ($USE_REL_REV and (defined($BUTTONS_REL{$button_href})) and ($BUTTONS_REL{$button_href} ne ''))
747 $anchor_attributes .= " rel=\"$BUTTONS_REL{$button_href}\"";
751 $Texi2HTML::HREF{$button_href},
752 get_navigation_text($$text),
758 print $fh get_navigation_text($$text);
762 elsif ($button eq ' ')
763 { # handle space button
765 ($ICONS && $ACTIVE_ICONS{' '}) ?
766 &$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{' '}) :
767 $NAVIGATION_TEXT{' '};
770 elsif ($Texi2HTML::HREF{$button})
772 my $btitle = $BUTTONS_GOTO{$button} ?
773 'title="' . $BUTTONS_GOTO{$button} . '"' : '';
774 if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button})) and ($BUTTONS_ACCESSKEY{$button} ne ''))
776 $btitle .= " accesskey=\"$BUTTONS_ACCESSKEY{$button}\"";
778 if ($USE_REL_REV and (defined($BUTTONS_REL{$button})) and ($BUTTONS_REL{$button} ne ''))
780 $btitle .= " rel=\"$BUTTONS_REL{$button}\"";
782 if ($ICONS && $ACTIVE_ICONS{$button})
786 $Texi2HTML::HREF{$button},
787 &$button_icon_img($BUTTONS_NAME{$button},
788 $ACTIVE_ICONS{$button},
789 $Texi2HTML::SIMPLE_TEXT{$button}),
798 $Texi2HTML::HREF{$button},
799 get_navigation_text ($button),
806 { # button is passive
808 $ICONS && $PASSIVE_ICONS{$button} ?
809 &$button_icon_img($BUTTONS_NAME{$button},
810 $PASSIVE_ICONS{$button},
811 $Texi2HTML::SIMPLE_TEXT{$button}) :
813 "[" . get_navigation_text($button) . "]";
815 print $fh "</td>\n" if $vertical;
816 print $fh "</tr>\n" if $vertical;
818 print $fh "</td>" unless $beginofline;
819 print $fh "</tr>" unless $vertical;
820 print $fh "</table>\n";
824 @Texi2HTML::Config::SECTION_BUTTONS =
825 ('left-aligned-cell-1', 'FastBack',
826 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
827 'right-aligned-cell-1', 'FastForward',
829 'left-aligned-cell-2', 'Back',
830 'center-aligned-cell-1', 'Up',
831 'right-aligned-cell-2', 'Forward'
834 # buttons for misc stuff
835 @Texi2HTML::Config::MISC_BUTTONS = ('center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About');
837 # buttons for chapter file footers
838 # (and headers but only if SECTION_NAVIGATION is false)
839 @Texi2HTML::Config::CHAPTER_BUTTONS =
840 ('left-aligned-cell-1', 'FastBack',
841 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
842 'right-aligned-cell-1', 'FastForward',
845 # buttons for section file footers
846 @Texi2HTML::Config::SECTION_FOOTER_BUTTONS =
847 ('left-aligned-cell-1', 'FastBack',
848 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
849 'right-aligned-cell-1', 'FastForward',
851 'left-aligned-cell-2', 'Back',
852 'center-aligned-cell-1', 'Up',
853 'right-aligned-cell-2', 'Forward'
856 @Texi2HTML::Config::NODE_FOOTER_BUTTONS =
857 ('left-aligned-cell-1', 'FastBack',
858 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
859 'right-aligned-cell-1', 'FastForward',
861 'left-aligned-cell-2', 'Back',
862 'center-aligned-cell-1', 'Up',
863 'right-aligned-cell-2', 'Forward'
870 #############################################################################
871 ### FOOTNOTE FORMATTING
872 #############################################################################
874 # Format footnotes in a nicer way: Instead of printing the number in a separate
875 # (nr) heading line, use the standard way of prepending <sup>nr</sup> immediately
876 # before the fn text.
877 sub lilypond_foot_line_and_ref($$$$$$$)
879 my $number_in_doc = shift;
880 my $number_in_page = shift;
881 my $footnote_id = shift;
882 my $place_id = shift;
883 my $document_file = shift;
884 my $footnote_file = shift;
888 if ($document_file eq $footnote_file)
890 $document_file = $footnote_file = '';
892 # FN number printed before the fn text:
893 my $tmptxt = &$anchor($footnote_id, $document_file . "#$place_id",
894 "<sup>$number_in_doc</sup>");
895 # unfortunately, the @$lines contain the already formatted footnote in the
896 # from <p>...</p>. This means that we have to modify this string and
897 # insert the FN number manually. The default (nr) on a separate line before
898 # the FN text is just plain ugly:
899 $lines->[0] =~ s/<p>/<p>$tmptxt /;
900 # this is a bit obscure, this allows to add an anchor only if formatted
901 # as part of the document.
902 $place_id = '' if ($state->{'outside_document'} or $state->{'multiple_pass'});
903 # return FN lines and text to be inserted in the running text (link to FN)
904 return ($lines, &$anchor($place_id, $footnote_file . "#$footnote_id",
905 "<sup>$number_in_doc</sup>"));
910 #############################################################################
912 #############################################################################
914 # For split pages, use index.html as start page!
915 if ($Texi2HTML::Config::SPLIT eq 'section') {
916 $Texi2HTML::Config::TOP_FILE = 'index.html';