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 ### split_at_numbered_sections (correct file name: use the map)
44 ### lilypond_init_map (read in the externally created map from disk)
45 ### lilypond_external_href (load the map for xrefs, use the correct
47 ### -) The HTML anchors for all sections are derived from the node name /
48 ### section title (pre-generated in the .xref-map file). Implemented by:
49 ### split_at_numbered_sections (adjust section anchors)
50 ### -) Use the standard footnote format "<sup>nr</sup> text" instead of the
51 ### ugly format of texi2html (<h3>(nr)</h3><p>text</p>). Implemented in
52 ### lilypond_foot_line_and_ref
55 ### Useful helper functions:
56 ### -) texinfo_file_name($node_name): returns a texinfo-compatible file name
57 ### for the given string $node_name (whitespace trimmed/replaced by -,
58 ### non-standard chars replaced by _xxxx (ascii char code) and forced to
59 ### start with a letter by prepending t_g if necessary)
62 package Texi2HTML::Config;
68 #############################################################################
69 ### SETTINGS FOR TEXI2HTML
70 #############################################################################
72 @Texi2HTML::Config::CSS_REFS = ("lilypond.css");
73 $Texi2HTML::Config::USE_ACCESSKEY = 1;
74 $Texi2HTML::Config::USE_LINKS = 1;
75 $Texi2HTML::Config::USE_REL_REV = 1;
76 $Texi2HTML::Config::SEPARATED_FOOTNOTES = 0; # Print footnotes on same page, not separated
77 $Texi2HTML::Config::element_file_name = \&split_at_numbered_sections;
78 $Texi2HTML::Config::print_element_header = \&lilypond_print_element_header;
79 $Texi2HTML::Config::print_page_foot = \&print_lilypond_page_foot;
80 $Texi2HTML::Config::print_navigation = \&lilypond_print_navigation;
81 $Texi2HTML::Config::external_ref = \&lilypond_external_ref;
82 $Texi2HTML::Config::external_href = \&lilypond_external_href;
83 $Texi2HTML::Config::toc_body = \&lilypond_toc_body;
84 $Texi2HTML::Config::css_lines = \&lilypond_css_lines;
85 $Texi2HTML::Config::unknown = \&lilypond_unknown;
86 $Texi2HTML::Config::print_page_head = \&lilypond_print_page_head;
87 $Texi2HTML::Config::foot_line_and_ref = \&lilypond_foot_line_and_ref;
89 # Examples should be formatted similar to quotes:
90 $Texi2HTML::Config::complex_format_map->{'example'} = {
91 'begin' => q{"<blockquote><pre class=\"example\">"},
92 'end' => q{"</pre></blockquote>\n"},
95 %Texi2HTML::config::misc_pages_targets = (
96 'Overview' => 'Overview',
97 'Contents' => 'Contents',
102 my @section_to_filename;
107 #############################################################################
109 #############################################################################
112 $Data::Dumper::Maxdepth = 2;
114 sub print_element_info($)
117 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
118 print "Element: $element\n";
119 print Dumper($element);
126 #############################################################################
128 #############################################################################
130 # Convert a given node name to its proper file name (normalization as explained
131 # in the texinfo manual:
132 # http://www.gnu.org/software/texinfo/manual/texinfo/html_node/HTML-Xref-Node-Name-Expansion.html
133 sub texinfo_file_name($)
137 # File name normalization by texinfo:
138 # 1/2: letters and numbers are left unchanged
139 # 3/4: multiple, leading and trailing whitespace is removed
140 $text = main::normalise_space($text);
141 # 5/6: all remaining spaces are converted to '-', all other 7- or 8-bit
142 # chars are replaced by _xxxx (xxxx=ascii character code)
143 while ($text ne '') {
144 if ($text =~ s/^([A-Za-z0-9]+)//o) { # number or letter stay unchanged
146 } elsif ($text =~ s/^ //o) { # space -> '-'
148 } elsif ($text =~ s/^(.)//o) { # Otherwise use _xxxx (ascii char code)
150 if ( $ccode <= 0xFFFF ) {
151 $result .= sprintf("_%04x", $ccode);
153 $result .= sprintf("__%06x", $ccode);
157 # 7: if name does not begin with a letter, prepend 't_g' (so it starts with a letter)
158 if ($result !~ /^[a-zA-Z]/) {
159 $result = 't_g' . $result;
166 # Load a file containing a nodename<=>filename map (tab-sepatared, i.e.
167 # NODENAME\tFILENAME\tANCHOR
168 # Returns a ref to a hash "Node title" => ["FilenameWithoutExt", "Anchor"]
169 sub load_map_file ($)
174 if (open(XREFFILE, $mapfile)) {
176 while ( $line = <XREFFILE> ) {
177 # parse the tab-separated entries and insert them into the map:
179 my @entries = split(/\t/, $line);
180 if (scalar (@entries) == 3) {
181 $node_map->{$entries[0]} = [$entries[1], $entries[2]];
183 print STDERR "Invalid entry in the node file $mapfile: $line\n";
188 print STDERR "WARNING: Unable to load the map file $mapfile\n";
194 # Split the given path into dir and basename (with .texi removed). Used mainly
195 # to get the path/basename of the original texi input file
196 sub split_texi_filename ($)
199 my $docu_dir, $docu_name;
200 if ($docu =~ /(.*\/)/) {
201 chop($docu_dir = $1);
203 $docu_name =~ s/.*\///;
208 $docu_name =~ s/\.te?x(i|info)?$//;
209 return ($docu_dir, $docu_name);
216 #############################################################################
218 #############################################################################
220 # Include our standard CSS file, not hard-coded CSS code directly in the HTML!
221 # For IE, conditionally include the lilypond-ie-fixes.css style sheet
222 sub lilypond_css_lines ($$)
224 my $import_lines = shift;
225 my $rule_lines = shift;
226 return if (defined($CSS_LINES));
227 if (@$rule_lines or @$import_lines)
229 $CSS_LINES = "<style type=\"text/css\">\n<!--\n";
230 $CSS_LINES .= join('',@$import_lines) . "\n" if (@$import_lines);
231 $CSS_LINES .= join('',@$rule_lines) . "\n" if (@$rule_lines);
232 $CSS_LINES .= "-->\n</style>\n";
234 foreach my $ref (@CSS_REFS)
236 $CSS_LINES .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"$ref\">\n";
238 $CSS_LINES .= "<!--[if lte IE 7]>\n<link href=\"lilypond-ie-fixes.css\" rel=\"stylesheet\" type=\"text/css\">\n<![endif]-->\n";
245 #############################################################################
246 ### SPLITTING BASED ON NUMBERED SECTIONS
247 #############################################################################
251 my $node_to_filename_map = ();
254 # This function makes sure that files are only generated for numbered sections,
255 # but not for unnumbered ones. It is called after texi2html has done its own
256 # splitting and simply returns the filename for the node given as first argument
257 # Nodes with the same filename will be printed out to the same filename, so
258 # this really all we need. Also, make sure that the file names for sections
259 # are derived from the section title. We also might want to name the anchors
260 # according to node titles, which works by simply overriding the id element of
262 # If an external nodename<=>filename/anchor map file is found (loaded in
263 # lilypond_init_out, use the externally created values, otherwise use the
265 sub split_at_numbered_sections($$$)
269 my $docu_name = shift;
270 my $docu_ext = $Texi2HTML::Config::EXTENSION;
272 my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
273 # the snippets page does not use nodes for the snippets, so in this case
274 # we'll have to use the section name!
275 if ($node_name eq '') {
276 $node_name = main::remove_texi($element->{'texi'});
279 # If we have an entry in the section<=>filename map, use that one, otherwise
280 # generate the filename/anchor here. In the latter case, external manuals
281 # will not be able to retrieve the file name for xrefs!!! Still, I already
282 # had that code, so I'll leave it in in case something goes wrong with the
283 # extract_texi_filenames.py script in the lilypond build process!
284 if (exists ($node_to_filename_map->{$node_name})) {
285 (my $filename, my $anchor) = @{$node_to_filename_map->{$node_name}};
286 $filename .= ".$docu_ext" if (defined($docu_ext));
288 # need to override both target (used as anchor in links to this section) and
289 # id (used in the <a name=..> tag for this section)!
290 $element->{'id'} = $element->{'target'} = $anchor;
292 # unnumbered sections (except those at top-level!) always go to the same
293 # file as the previous numbered section
294 if (not ($element->{number}) and not ($lastfilename eq '') and ($element->{level} > 1)) {
295 $filename = $lastfilename;
297 if (($filename eq $lastfilename)) {
298 $$element{doc_nr} = $docnr;
301 $$element{doc_nr} = $docnr;
302 $lastfilename = $filename;
306 } 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 # TOC, footer, about etc. are called with undefined $element and $type == "toc"|"stoc"|"foot"|"about"
308 if ($type eq "top") {
309 $element->{'id'} = $element->{'target'} = "Top";
313 print STDERR "WARNING: Node '$node_name' was NOT found in the map\n"
314 unless ($node_name eq '') or ($element->{'tag'} eq 'unnumberedsec')
315 or ($node_name =~ /NOT REALLY USED/);
317 # derive the name of the anchor (i.e. the part after # in the links!),
318 # don't use texi2html's SECx.x default!
319 my $sec_name = main::remove_texi($element->{'texi'});
320 # if we have a node, use its name:
321 if ($element->{'node_ref'}->{'texi'} ne '') {
322 $sec_name = main::remove_texi($element->{'node_ref'}->{'texi'});
324 my $anchor = $sec_name;
325 if ($element->{translationof}) {
326 $anchor = main::remove_texi($$element{translationof});
328 # normalize to the same file name as texinfo
329 $anchor = texinfo_file_name($anchor);
330 # need to override both target (used as anchor in links to this section) and
331 # id (used in the <a name=..> tag for this section)!
332 $element->{'id'} = $element->{'target'} = $anchor;
333 # Numbered sections will get a filename Node_title, unnumbered sections will use
334 # the file name of the previous numbered section:
335 if (($element->{number}) or ($lastfilename eq '') or ($element->{level} == 1)) {
336 my $filename = $anchor;
337 $filename .= ".$docu_ext" if (defined($docu_ext));
339 $$element{doc_nr} = $docnr;
340 $lastfilename = $filename;
343 $$element{doc_nr} = $docnr;
344 return $lastfilename;
352 ## Load the map file for the corrently processed texi file. We do this
353 # using a command init handler, since texi2html does not have any
354 # other hooks that are called after THISDOC is filled but before phase 2
355 # of the texi2html conversion.
356 sub lilypond_init_map ()
358 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
359 my $map_filename = main::locate_include_file ("${docu_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
360 || main::locate_include_file ("${docu_name}.xref-map");
361 $node_to_filename_map = load_map_file ($map_filename);
363 push @Texi2HTML::Config::command_handler_init, \&lilypond_init_map;
367 #############################################################################
368 ### CLEANER LINK TITLE FOR EXTERNAL REFS
369 #############################################################################
371 # The default formatting of external refs returns e.g.
372 # "(lilypond-internals)Timing_translator", so we remove all (...) from the
373 # file_and_node argument. Also, we want only a very simple format, so we don't
374 # even call the default handler!
375 sub lilypond_external_ref($$$$$$)
380 my $file_node = shift;
382 my $cross_ref = shift;
384 my $displaytext = '';
386 # 1) if we have a cross ref name, that's the text to be displayed:
387 # 2) For the top node, use the (printable) name of the manual, unless we
388 # have an explicit cross ref name
389 # 3) In all other cases use the section name
390 if ($cross_ref ne '') {
391 $displaytext = $cross_ref;
392 } elsif (($section eq '') or ($section eq 'Top')) {
393 $displaytext = $book;
395 $displaytext = $section;
398 $displaytext = &$anchor('', $href, $displaytext) if ($displaytext ne '');
399 return &$I('%{node_file_href}', { 'node_file_href' => $displaytext });
401 # Default: format as "see <a ..>NODE</a> section 'SECTION' in BOOK". We don't want this!
402 # return t2h_default_external_ref($type, $section, $book, $file_node, $href, $cross_ref);
409 #############################################################################
410 ### HANDLING TRANSLATED SECTIONS: handle @translationof, secname<->filename
411 ### map stored on disk, xrefs in other manuals load that map
412 #############################################################################
415 # Try to make use of @translationof to generate files according to the original
416 # English section title...
417 sub lilypond_unknown($$$$$)
425 # the @translationof macro provides the original English section title,
426 # which should be used for file/anchor naming, while the title will be
427 # translated to each language
428 # It is already used by extract_texi_filenames.py, so this should not be
429 # necessary here at all. Still, I'll leave the code in just in case the
430 # python script messed up ;-)
431 if ($pass == 1 and $macro eq "translationof") {
432 if (ref($state->{'element'}) eq 'HASH') {
433 $state->{'element'}->{'translationof'} = main::normalise_space($line);
435 return ('', true, undef, undef);
437 return t2h_default_unknown($macro, $line, $pass, $stack, $state);
444 my %translated_books = ();
445 # Construct a href to an external source of information.
446 # node is the node with texinfo @-commands
447 # node_id is the node transliterated and transformed as explained in the
449 # node_xhtml_id is the node transformed such that it is unique and can
450 # be used to make an html cross ref as explained in the texinfo manual
451 # file is the file in '(file)node'
452 sub lilypond_external_href($$$)
456 my $node_hxmlt_id = shift;
458 my $original_func = \&t2h_default_external_href;
460 # 1) Keep a hash of book->section_map
461 # 2) if not file in keys hash => try to load the map (assign empty map if
462 # non-existent => will load only once!)
463 # 3) if node in the section=>(file, anchor) map, replace node_id and
464 # node_xhtml_id by the map's values
465 # 4) call the t2h_default_external_href with these values (or the old ones if not found)
467 if (($node_id ne '') and defined($file) and ($node_id ne 'Top')) {
468 my $map_name = $file;
469 $map_name =~ s/-big-page//;
471 # Load the map if we haven't done so already
472 if (!exists($translated_books{$map_name})) {
473 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
474 my $map_filename = main::locate_include_file ("${map_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
475 || main::locate_include_file ("${map_name}.xref-map");
476 $translated_books{$map_name} = load_map_file ($map_filename);
479 # look up translation. use these values instead of the old filename/anchor
480 my $section_name_map = $translated_books{$map_name};
481 my $node_text = main::remove_texi($node);
482 if (defined($section_name_map->{$node_text})) {
483 ($node_id, $node_hxmlt_id) = @{$section_name_map->{$node_text}};
485 print STDERR "WARNING: Unable to find node '$node_text' in book $map_name.\n";
490 return &$original_func($node, $node_id, $node_hxmlt_id, $file);
492 return &$original_func($node, $node_id, $node_hxmlt_id);
500 #############################################################################
501 ### CUSTOM TOC FOR EACH PAGE (in a frame on the left)
502 #############################################################################
504 my $page_toc_depth = 2;
505 my @default_toc = [];
507 # recursively generate the TOC entries for the element and its children (which
508 # are only shown up to maxlevel. All ancestors of the current element are also
509 # shown with their immediate children, irrespective of their level.
510 # Unnumbered entries are only printed out if they are at top-level or their
511 # parent element is an ancestor of the currently viewed node.
512 sub generate_ly_toc_entries($$$$)
515 my $element_path = shift;
516 my $maxlevel = shift;
517 my $always_show_unnumbered_children = shift;
518 # Skip undefined sections, plus all sections generated by index splitting
519 return() if (not defined($element) or exists($element->{'index_page'}));
521 my $level = $element->{'toc_level'};
522 my $is_parent_of_current = $element->{'id'} && $element_path->{$element->{'id'}};
523 my $print_children = ( ($level < $maxlevel) or $is_parent_of_current );
524 my $ind = ' ' x $level;
525 my $this_css_class = $is_parent_of_current ? " class=\"toc_current\"" : "";
527 my $entry = "$ind<li$this_css_class>" . &$anchor ($element->{'tocid'}, "$element->{'file'}#$element->{'id'}",$element->{'text'});
529 my $children = $element->{'section_childs'};
530 # Don't add unnumbered entries, unless they are at top-level or a parent of the current!
531 if (not ($element->{'number'} or $always_show_unnumbered_children)) {
534 if ( $print_children and defined($children) and (ref($children) eq "ARRAY") ) {
535 push (@result, $entry);
536 my @child_result = ();
537 foreach (@$children) {
538 push (@child_result, generate_ly_toc_entries($_, $element_path, $maxlevel, $is_parent_of_current));
540 # if no child nodes were generated, e.g. for the index, where expanded pages
541 # are ignored, don't generate a list at all...
543 push (@result, "\n$ind<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
544 push (@result, @child_result);
545 push (@result, "$ind</ul></li>\n");
548 push (@result, $entry . "</li>\n");
554 # Print a customized TOC, containing only the first two levels plus the whole
555 # path to the current page
556 sub lilypond_generate_page_toc_body($)
559 my $current_element = $element;
561 $parentelements{$element->{'id'}} = 1;
562 # Find the path to the current element
563 while ( defined($current_element->{'sectionup'}) and
564 ($current_element->{'sectionup'} ne $current_element) )
566 $parentelements{$current_element->{'sectionup'}->{'id'}} = 1
567 if ($current_element->{'sectionup'}->{'id'} ne '');
568 $current_element = $current_element->{'sectionup'};
570 return () if not defined($current_element);
571 # Create the toc entries recursively
572 my @toc_entries = ("<div class=\"contents\">\n", "<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
573 my $children = $current_element->{'section_childs'};
574 foreach ( @$children ) {
575 push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth, False));
577 push (@toc_entries, "</ul>\n");
578 push (@toc_entries, "</div>\n");
582 sub lilypond_print_toc_div ($$)
586 my @lines = @$tocref;
587 # use default TOC if no custom lines have been generated
588 @lines = @default_toc if (not @lines);
590 print $fh "\n\n<div id=\"tocframe\">\n";
591 print $fh '<h4> ' . $Texi2HTML::NAME{'Contents'} . "</h4>\n";
592 foreach my $line (@lines) {
595 print $fh "</div>\n\n";
599 # Create the custom TOC for this page (partially folded, current page is
600 # highlighted) and store it in a global variable. The TOC is written out after
601 # the html contents (but positioned correctly using CSS), so that browsers with
602 # css turned off still show the contents first.
603 our @this_page_toc = ();
604 sub lilypond_print_element_header
607 my $first_in_page = shift;
608 my $previous_is_top = shift;
609 if ($first_in_page and not @this_page_toc) {
610 if (defined($Texi2HTML::THIS_ELEMENT)) {
611 # Create the TOC for this page
612 @this_page_toc = lilypond_generate_page_toc_body($Texi2HTML::THIS_ELEMENT);
615 return T2H_DEFAULT_print_element_header( $fh, $first_in_page, $previous_is_top);
618 # Generate the HTML output for the TOC
619 sub lilypond_toc_body($)
621 my $elements_list = shift;
622 # Generate a default TOC for pages without THIS_ELEMENT
623 @default_toc = lilypond_generate_page_toc_body(@$elements_list[0]);
624 return T2H_GPL_toc_body($elements_list);
627 # Print out the TOC in a <div> at the beginning of the page
628 sub lilypond_print_page_head($)
631 T2H_DEFAULT_print_page_head($fh);
632 print $fh "<div id=\"main\">\n";
635 # Print out the TOC in a <div> at the end of th page, which will be formatted as a
636 # sidebar mimicking a TOC frame
637 sub print_lilypond_page_foot($)
640 my $program_string = &$program_string();
641 print $fh "<p><font size='-1'>$program_string</font><br>$PRE_BODY_CLOSE</p>\n";
642 print $fh "<!-- FOOTER -->\n\n";
643 print $fh "<!-- end div#main here -->\n</div>\n\n";
645 # Print the TOC frame and reset the TOC:
646 lilypond_print_toc_div ($fh, \@this_page_toc);
650 print $fh "</body>\n</html>\n";
657 #############################################################################
658 ### NICER / MORE FLEXIBLE NAVIGATION PANELS
659 #############################################################################
661 sub get_navigation_text
664 my $text = $NAVIGATION_TEXT{$button};
665 if ( ($button eq 'Back') or ($button eq 'FastBack') ) {
666 $text = $text . $Texi2HTML::NODE{$button} . " ";
667 } elsif ( ($button eq 'Forward') or ($button eq 'FastForward') ) {
668 $text = " " . $Texi2HTML::NODE{$button} . $text;
669 } elsif ( $button eq 'Up' ) {
670 $text = " ".$text.": " . $Texi2HTML::NODE{$button} . " ";
676 # Don't automatically create left-aligned table cells for every link, but
677 # instead create a <td> only on an appropriate '(left|right|center)-aligned-cell-n'
678 # button text. It's alignment as well as the colspan will be taken from the
679 # name of the button. Also, add 'newline' button text to create a new table
680 # row. The texts of the buttons are generated by get_navigation_text and
681 # will contain the name of the next/previous section/chapter.
682 sub lilypond_print_navigation
686 my $vertical = shift;
688 # print $fh '<table cellpadding="', $spacing, '" cellspacing="', $spacing,
689 # "\" border=\"0\" class=\"nav_table\">\n";
690 print $fh "<table class=\"nav_table\">\n";
692 print $fh "<tr>" unless $vertical;
694 foreach my $button (@$buttons)
696 print $fh qq{<tr valign="top" align="left">\n} if $vertical;
697 # Allow (left|right|center)-aligned-cell and newline as buttons!
698 if ( $button =~ /^(.*)-aligned-cell-(.*)$/ )
700 print $fh qq{</td>} unless $beginofline;
701 print $fh qq{<td valign="middle" align="$1" colspan="$2">};
704 elsif ( $button eq 'newline' )
706 print $fh qq{</td>} unless $beginofline;
712 elsif (ref($button) eq 'CODE')
714 &$button($fh, $vertical);
716 elsif (ref($button) eq 'SCALAR')
718 print $fh "$$button" if defined($$button);
720 elsif (ref($button) eq 'ARRAY')
722 my $text = $button->[1];
723 my $button_href = $button->[0];
724 # verify that $button_href is simple text and text is a reference
725 if (defined($button_href) and !ref($button_href)
726 and defined($text) and (ref($text) eq 'SCALAR') and defined($$text))
728 if ($Texi2HTML::HREF{$button_href})
730 my $anchor_attributes = '';
731 if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button_href})) and ($BUTTONS_ACCESSKEY{$button_href} ne ''))
733 $anchor_attributes = "accesskey=\"$BUTTONS_ACCESSKEY{$button_href}\"";
735 if ($USE_REL_REV and (defined($BUTTONS_REL{$button_href})) and ($BUTTONS_REL{$button_href} ne ''))
737 $anchor_attributes .= " rel=\"$BUTTONS_REL{$button_href}\"";
741 $Texi2HTML::HREF{$button_href},
742 get_navigation_text($$text),
748 print $fh get_navigation_text($$text);
752 elsif ($button eq ' ')
753 { # handle space button
755 ($ICONS && $ACTIVE_ICONS{' '}) ?
756 &$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{' '}) :
757 $NAVIGATION_TEXT{' '};
760 elsif ($Texi2HTML::HREF{$button})
762 my $btitle = $BUTTONS_GOTO{$button} ?
763 'title="' . $BUTTONS_GOTO{$button} . '"' : '';
764 if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button})) and ($BUTTONS_ACCESSKEY{$button} ne ''))
766 $btitle .= " accesskey=\"$BUTTONS_ACCESSKEY{$button}\"";
768 if ($USE_REL_REV and (defined($BUTTONS_REL{$button})) and ($BUTTONS_REL{$button} ne ''))
770 $btitle .= " rel=\"$BUTTONS_REL{$button}\"";
772 if ($ICONS && $ACTIVE_ICONS{$button})
776 $Texi2HTML::HREF{$button},
777 &$button_icon_img($BUTTONS_NAME{$button},
778 $ACTIVE_ICONS{$button},
779 $Texi2HTML::SIMPLE_TEXT{$button}),
788 $Texi2HTML::HREF{$button},
789 get_navigation_text ($button),
796 { # button is passive
798 $ICONS && $PASSIVE_ICONS{$button} ?
799 &$button_icon_img($BUTTONS_NAME{$button},
800 $PASSIVE_ICONS{$button},
801 $Texi2HTML::SIMPLE_TEXT{$button}) :
803 "[" . get_navigation_text($button) . "]";
805 print $fh "</td>\n" if $vertical;
806 print $fh "</tr>\n" if $vertical;
808 print $fh "</td>" unless $beginofline;
809 print $fh "</tr>" unless $vertical;
810 print $fh "</table>\n";
814 @Texi2HTML::Config::SECTION_BUTTONS =
815 ('left-aligned-cell-1', 'FastBack',
816 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
817 'right-aligned-cell-1', 'FastForward',
819 'left-aligned-cell-2', 'Back',
820 'center-aligned-cell-1', 'Up',
821 'right-aligned-cell-2', 'Forward'
824 # buttons for misc stuff
825 @Texi2HTML::Config::MISC_BUTTONS = ('center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About');
827 # buttons for chapter file footers
828 # (and headers but only if SECTION_NAVIGATION is false)
829 @Texi2HTML::Config::CHAPTER_BUTTONS =
830 ('left-aligned-cell-1', 'FastBack',
831 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
832 'right-aligned-cell-1', 'FastForward',
835 # buttons for section file footers
836 @Texi2HTML::Config::SECTION_FOOTER_BUTTONS =
837 ('left-aligned-cell-1', 'FastBack',
838 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
839 'right-aligned-cell-1', 'FastForward',
841 'left-aligned-cell-2', 'Back',
842 'center-aligned-cell-1', 'Up',
843 'right-aligned-cell-2', 'Forward'
846 @Texi2HTML::Config::NODE_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'
860 #############################################################################
861 ### FOOTNOTE FORMATTING
862 #############################################################################
864 # Format footnotes in a nicer way: Instead of printing the number in a separate
865 # (nr) heading line, use the standard way of prepending <sup>nr</sup> immediately
866 # before the fn text.
867 sub lilypond_foot_line_and_ref($$$$$$$)
869 my $number_in_doc = shift;
870 my $number_in_page = shift;
871 my $footnote_id = shift;
872 my $place_id = shift;
873 my $document_file = shift;
874 my $footnote_file = shift;
878 if ($document_file eq $footnote_file)
880 $document_file = $footnote_file = '';
882 # FN number printed before the fn text:
883 my $tmptxt = &$anchor($footnote_id, $document_file . "#$place_id",
884 "<sup>$number_in_doc</sup>");
885 # unfortunately, the @$lines contain the already formatted footnote in the
886 # from <p>...</p>. This means that we have to modify this string and
887 # insert the FN number manually. The default (nr) on a separate line before
888 # the FN text is just plain ugly:
889 $lines->[0] =~ s/^<p>/<p>$tmptxt /;
890 # this is a bit obscure, this allows to add an anchor only if formatted
891 # as part of the document.
892 $place_id = '' if ($state->{'outside_document'} or $state->{'multiple_pass'});
893 # return FN lines and text to be inserted in the running text (link to FN)
894 return ($lines, &$anchor($place_id, $footnote_file . "#$footnote_id",
895 "<sup>$number_in_doc</sup>"));
900 #############################################################################
902 #############################################################################
904 # For split pages, use index.html as start page!
905 if ($Texi2HTML::Config::SPLIT eq 'section') {
906 $Texi2HTML::Config::TOP_FILE = 'index.html';