3 ### texi2html customization script for Lilypond
4 ### Author: Reinhold Kainhofer <reinhold@kainhofer.com>, 2008.
5 ### Some code parts copied from texi2html and adapted. These functions
6 ### were written mainly by Patrice Dumas
10 ### Features implemented here:
11 ### -) For split manuals, the main page is index.html.
12 ### -) All @unnumbered* sections are placed into the same file
13 ### (implemented by split_at_numbered_sections)
14 ### -) Use our custom CSS file, with IE-specific fixes in another CSS file,
15 ### impelmented by lilypond_css_lines
16 ### -) TOC (folded, with the current page highlighted) in an overflown <div>
17 ### is added to every page; implemented by:
18 ### lilypond_print_element_header -- building of the TOC
19 ### lilypond_toc_body -- generation of customized TOC output
20 ### lilypond_print_page_head -- start <div id="main">
21 ### print_lilypond_page_foot -- closing id=main, output of footer & TOC
22 ### -) External refs are formatted only as "Text of the node" (not as >>see
23 ### "NODE" section "SECTION" in "BOOK"<< like with default texi2html). Also,
24 ### the leading "(book-name)" is removed.
25 ### Implemented by overriding lilypond_external_ref
26 ### -) Navigation bars on top/bottom of the page and between sections are not
27 ### left-aligned, but use a combination of left/center/right aligned table
28 ### cells; For this, I heavily extend the texi2html code to allow for
29 ### differently aligned cells and for multi-line tables);
30 ### Implemented in lilypond_print_navigation
31 ### -) Different formatting than the default: example uses the same formatting
33 ### -) Allow translated section titles: All section titles can be translated,
34 ### the original (English) title is associated with @translationof. This is
35 ### needed, because the file name / anchor is generated from the original
36 ### English title, since otherwise language-autoselection would break with
38 ### Since it is then no longer possible to obtain the file name from the
39 ### section title, I keep a sectionname<=>filename/anchor around. This way,
40 ### xrefs from other manuals can simply load that map and retrieve the
41 ### correct file name for the link. Implemented in:
42 ### lilypond_unknown (handling of @translationof, in case
43 ### extract_texi_filenames.py messes up...)
44 ### lilypond_element_file_name (correct file name: use the map)
45 ### lilypond_element_target_name (correct anchor: use the map)
46 ### lilypond_init_map (read in the externally created map from disk)
47 ### lilypond_external_href (load the map for xrefs, use the correct
49 ### -) The HTML anchors for all sections are derived from the node name /
50 ### section title (pre-generated in the .xref-map file). Implemented by:
51 ### lilypond_element_target_name (adjust section anchors)
52 ### -) Use the standard footnote format "<sup>nr</sup> text" instead of the
53 ### ugly format of texi2html (<h3>(nr)</h3><p>text</p>). Implemented in
54 ### makeinfo_like_foot_line_and_ref
55 ### makeinfo_like_foot_lines
56 ### makeinfo_like_paragraph
59 ### Useful helper functions:
60 ### -) texinfo_file_name($node_name): returns a texinfo-compatible file name
61 ### for the given string $node_name (whitespace trimmed/replaced by -,
62 ### non-standard chars replaced by _xxxx (ascii char code) and forced to
63 ### start with a letter by prepending t_g if necessary)
66 package Texi2HTML::Config;
72 #############################################################################
73 ### SETTINGS FOR TEXI2HTML
74 #############################################################################
76 @Texi2HTML::Config::CSS_REFS = (
77 {FILENAME => "lilypond.css", TITLE => "Default Style" }
79 @Texi2HTML::Config::ALT_CSS_REFS = (
80 {FILENAME => "lilypond-mccarty.css", TITLE => "Patrick McCarty's design"}
82 $Texi2HTML::Config::USE_ACCESSKEY = 1;
83 $Texi2HTML::Config::USE_LINKS = 1;
84 $Texi2HTML::Config::USE_REL_REV = 1;
85 $Texi2HTML::Config::SEPARATED_FOOTNOTES = 0; # Print footnotes on same page, not separated
86 if ($Texi2HTML::Config::SPLIT eq 'section') {
87 $Texi2HTML::Config::element_file_name = \&lilypond_element_file_name;
89 $Texi2HTML::Config::element_target_name = \&lilypond_element_target_name;
90 $Texi2HTML::Config::print_element_header = \&lilypond_print_element_header;
91 $Texi2HTML::Config::print_page_foot = \&print_lilypond_page_foot;
92 $Texi2HTML::Config::print_navigation = \&lilypond_print_navigation;
93 $Texi2HTML::Config::external_ref = \&lilypond_external_ref;
94 $Texi2HTML::Config::external_href = \&lilypond_external_href;
95 $Texi2HTML::Config::toc_body = \&lilypond_toc_body;
96 $Texi2HTML::Config::css_lines = \&lilypond_css_lines;
97 $Texi2HTML::Config::unknown = \&lilypond_unknown;
98 $Texi2HTML::Config::print_page_head = \&lilypond_print_page_head;
99 # $Texi2HTML::Config::foot_line_and_ref = \&lilypond_foot_line_and_ref;
100 $Texi2HTML::Config::foot_line_and_ref = \&makeinfo_like_foot_line_and_ref;
101 $Texi2HTML::Config::foot_lines = \&makeinfo_like_foot_lines;
102 $Texi2HTML::Config::paragraph = \&makeinfo_like_paragraph;
106 # Examples should be formatted similar to quotes:
107 $Texi2HTML::Config::complex_format_map->{'example'} = {
108 'begin' => q{"<blockquote><pre class=\"example\">"},
109 'end' => q{"</pre></blockquote>\n"},
112 %Texi2HTML::config::misc_pages_targets = (
113 'Overview' => 'Overview',
114 'Contents' => 'Contents',
119 my @section_to_filename;
124 #############################################################################
126 #############################################################################
129 $Data::Dumper::Maxdepth = 2;
131 sub print_element_info($)
134 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
135 print "Element: $element\n";
136 print Dumper($element);
143 #############################################################################
145 #############################################################################
147 # Convert a given node name to its proper file name (normalization as explained
148 # in the texinfo manual:
149 # http://www.gnu.org/software/texinfo/manual/texinfo/html_node/HTML-Xref-Node-Name-Expansion.html
150 sub texinfo_file_name($)
154 # File name normalization by texinfo:
155 # 1/2: letters and numbers are left unchanged
156 # 3/4: multiple, leading and trailing whitespace is removed
157 $text = main::normalise_space($text);
158 # 5/6: all remaining spaces are converted to '-', all other 7- or 8-bit
159 # chars are replaced by _xxxx (xxxx=ascii character code)
160 while ($text ne '') {
161 if ($text =~ s/^([A-Za-z0-9]+)//o) { # number or letter stay unchanged
163 } elsif ($text =~ s/^ //o) { # space -> '-'
165 } elsif ($text =~ s/^(.)//o) { # Otherwise use _xxxx (ascii char code)
167 if ( $ccode <= 0xFFFF ) {
168 $result .= sprintf("_%04x", $ccode);
170 $result .= sprintf("__%06x", $ccode);
174 # 7: if name does not begin with a letter, prepend 't_g' (so it starts with a letter)
175 if ($result !~ /^[a-zA-Z]/) {
176 $result = 't_g' . $result;
183 # Load a file containing a nodename<=>filename map (tab-sepatared, i.e.
184 # NODENAME\tFILENAME\tANCHOR
185 # Returns a ref to a hash "Node title" => ["FilenameWithoutExt", "Anchor"]
186 sub load_map_file ($)
191 if (open(XREFFILE, $mapfile)) {
193 while ( $line = <XREFFILE> ) {
194 # parse the tab-separated entries and insert them into the map:
196 my @entries = split(/\t/, $line);
197 if (scalar (@entries) == 3) {
198 $node_map->{$entries[0]} = [$entries[1], $entries[2]];
200 print STDERR "Invalid entry in the node file $mapfile: $line\n";
205 print STDERR "WARNING: Unable to load the map file $mapfile\n";
211 # Split the given path into dir and basename (with .texi removed). Used mainly
212 # to get the path/basename of the original texi input file
213 sub split_texi_filename ($)
216 my $docu_dir, $docu_name;
217 if ($docu =~ /(.*\/)/) {
218 chop($docu_dir = $1);
220 $docu_name =~ s/.*\///;
225 $docu_name =~ s/\.te?x(i|info)?$//;
226 return ($docu_dir, $docu_name);
233 #############################################################################
235 #############################################################################
237 # Include our standard CSS file, not hard-coded CSS code directly in the HTML!
238 # For IE, conditionally include the lilypond-ie-fixes.css style sheet
239 sub lilypond_css_lines ($$)
241 my $import_lines = shift;
242 my $rule_lines = shift;
243 return if (defined($Texi2HTML::THISDOC{'CSS_LINES'}));
244 if (@$rule_lines or @$import_lines)
246 $Texi2HTML::THISDOC{'CSS_LINES'} = "<style type=\"text/css\">\n<!--\n";
247 $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$import_lines) . "\n" if (@$import_lines);
248 $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$rule_lines) . "\n" if (@$rule_lines);
249 $Texi2HTML::THISDOC{'CSS_LINES'} .= "-->\n</style>\n";
251 foreach my $ref (@CSS_REFS)
253 $Texi2HTML::THISDOC{'CSS_LINES'} .= "<link rel=\"stylesheet\" type=\"text/css\" title=\"$ref->{TITLE}\" href=\"$ref->{FILENAME}\">\n";
255 foreach my $ref (@ALT_CSS_REFS)
257 $Texi2HTML::THISDOC{'CSS_LINES'} .= "<link rel=\"alternate stylesheet\" type=\"text/css\" href=\"$ref->{FILENAME}\" title=\"$ref->{TITLE}\">\n";
259 $Texi2HTML::THISDOC{'CSS_LINES'} .= "<!--[if lte IE 7]>\n<link href=\"lilypond-ie-fixes.css\" rel=\"stylesheet\" type=\"text/css\">\n<![endif]-->\n";
266 #############################################################################
267 ### SPLITTING BASED ON NUMBERED SECTIONS
268 #############################################################################
272 my $node_to_filename_map = ();
275 # This function makes sure that files are only generated for numbered sections,
276 # but not for unnumbered ones. It is called after texi2html has done its own
277 # splitting and simply returns the filename for the node given as first argument
278 # Nodes with the same filename will be printed out to the same filename, so
279 # this really all we need. Also, make sure that the file names for sections
280 # are derived from the section title. We also might want to name the anchors
281 # according to node titles, which works by simply overriding the id element of
283 # If an external nodename<=>filename/anchor map file is found (loaded in
284 # lilypond_init_out, use the externally created values, otherwise use the
286 sub lilypond_element_file_name($$$)
290 my $docu_name = shift;
291 my $docu_ext = $Texi2HTML::Config::EXTENSION;
293 my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
294 # the snippets page does not use nodes for the snippets, so in this case
295 # we'll have to use the section name!
296 if ($node_name eq '') {
297 $node_name = main::remove_texi($element->{'texi'});
300 # If we have an entry in the section<=>filename map, use that one, otherwise
301 # generate the filename/anchor here. In the latter case, external manuals
302 # will not be able to retrieve the file name for xrefs!!! Still, I already
303 # had that code, so I'll leave it in in case something goes wrong with the
304 # extract_texi_filenames.py script in the lilypond build process!
305 if (exists ($node_to_filename_map->{$node_name})) {
306 (my $filename, my $anchor) = @{$node_to_filename_map->{$node_name}};
307 $filename .= ".$docu_ext" if (defined($docu_ext));
309 # unnumbered sections (except those at top-level!) always go to the same
310 # file as the previous numbered section
311 if (not ($element->{number}) and not ($lastfilename eq '') and ($element->{level} > 1)) {
312 $filename = $lastfilename;
314 if (($filename eq $lastfilename)) {
315 $$element{doc_nr} = $docnr;
318 $$element{doc_nr} = $docnr;
319 $lastfilename = $filename;
323 } elsif ($type eq "top" or $type eq "toc" or $type eq "doc" or $type eq "stoc" or $type eq "foot" or $type eq "about") {
326 print STDERR "WARNING: Node '$node_name' was NOT found in the map\n"
327 unless ($node_name eq '') or ($element->{'tag'} eq 'unnumberedsec')
328 or ($node_name =~ /NOT REALLY USED/);
330 # Numbered sections will get a filename Node_title, unnumbered sections will use
331 # the file name of the previous numbered section:
332 if (($element->{number}) or ($lastfilename eq '') or ($element->{level} == 1)) {
333 # normalize to the same file name as texinfo
334 if ($element->{translationof}) {
335 $node_name = main::remove_texi($element->{translationof});
337 my $filename = texinfo_file_name($node_name);
338 $filename .= ".$docu_ext" if (defined($docu_ext));
340 $$element{doc_nr} = $docnr;
341 $lastfilename = $filename;
344 $$element{doc_nr} = $docnr;
345 return $lastfilename;
352 sub lilypond_element_target_name($$$)
357 # Target is based on node name (or sec name for secs without node attached)
358 my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
359 if ($node_name eq '') {
360 $node_name = main::remove_texi($element->{'texi'});
363 # If we have an entry in the section<=>filename map, use that one, otherwise
364 # generate the anchor here.
365 if (exists ($node_to_filename_map->{$node_name})) {
366 (my $filename, $target) = @{$node_to_filename_map->{$node_name}};
368 my $anchor = $node_name;
369 if ($element->{translationof}) {
370 $anchor = main::remove_texi($element->{translationof});
372 # normalize to the same file name as texinfo
373 $target = texinfo_file_name($anchor);
375 # TODO: Once texi2html correctly prints out the target and not the id for
376 # the sections, change this back to ($id, $target)
377 return ($target, $target);
381 ## Load the map file for the corrently processed texi file. We do this
382 # using a command init handler, since texi2html does not have any
383 # other hooks that are called after THISDOC is filled but before phase 2
384 # of the texi2html conversion.
385 sub lilypond_init_map ()
387 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
388 my $map_filename = main::locate_include_file ("${docu_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
389 || main::locate_include_file ("${docu_name}.xref-map");
390 $node_to_filename_map = load_map_file ($map_filename);
392 push @Texi2HTML::Config::command_handler_init, \&lilypond_init_map;
396 #############################################################################
397 ### CLEANER LINK TITLE FOR EXTERNAL REFS
398 #############################################################################
400 # The default formatting of external refs returns e.g.
401 # "(lilypond-internals)Timing_translator", so we remove all (...) from the
402 # file_and_node argument. Also, we want only a very simple format, so we don't
403 # even call the default handler!
404 sub lilypond_external_ref($$$$$$)
409 my $file_node = shift;
411 my $cross_ref = shift;
413 my $displaytext = '';
415 # 1) if we have a cross ref name, that's the text to be displayed:
416 # 2) For the top node, use the (printable) name of the manual, unless we
417 # have an explicit cross ref name
418 # 3) In all other cases use the section name
419 if ($cross_ref ne '') {
420 $displaytext = $cross_ref;
421 } elsif (($section eq '') or ($section eq 'Top')) {
422 $displaytext = $book;
424 $displaytext = $section;
427 $displaytext = &$anchor('', $href, $displaytext) if ($displaytext ne '');
428 return &$I('%{node_file_href}', { 'node_file_href' => $displaytext });
430 # Default: format as "see <a ..>NODE</a> section 'SECTION' in BOOK". We don't want this!
431 # return t2h_default_external_ref($type, $section, $book, $file_node, $href, $cross_ref);
438 #############################################################################
439 ### HANDLING TRANSLATED SECTIONS: handle @translationof, secname<->filename
440 ### map stored on disk, xrefs in other manuals load that map
441 #############################################################################
444 # Try to make use of @translationof to generate files according to the original
445 # English section title...
446 sub lilypond_unknown($$$$$)
454 # the @translationof macro provides the original English section title,
455 # which should be used for file/anchor naming, while the title will be
456 # translated to each language
457 # It is already used by extract_texi_filenames.py, so this should not be
458 # necessary here at all. Still, I'll leave the code in just in case the
459 # python script messed up ;-)
460 if ($pass == 1 and $macro eq "translationof") {
461 if (ref($state->{'element'}) eq 'HASH') {
462 $state->{'element'}->{'translationof'} = main::normalise_space($line);
464 return ('', true, undef, undef);
466 return t2h_default_unknown($macro, $line, $pass, $stack, $state);
473 my %translated_books = ();
474 # Construct a href to an external source of information.
475 # node is the node with texinfo @-commands
476 # node_id is the node transliterated and transformed as explained in the
478 # node_xhtml_id is the node transformed such that it is unique and can
479 # be used to make an html cross ref as explained in the texinfo manual
480 # file is the file in '(file)node'
481 sub lilypond_external_href($$$)
485 my $node_hxmlt_id = shift;
487 my $original_func = \&t2h_default_external_href;
489 # 1) Keep a hash of book->section_map
490 # 2) if not file in keys hash => try to load the map (assign empty map if
491 # non-existent => will load only once!)
492 # 3) if node in the section=>(file, anchor) map, replace node_id and
493 # node_xhtml_id by the map's values
494 # 4) call the t2h_default_external_href with these values (or the old ones if not found)
496 if (($node_id ne '') and defined($file) and ($node_id ne 'Top')) {
497 my $map_name = $file;
498 $map_name =~ s/-big-page//;
500 # Load the map if we haven't done so already
501 if (!exists($translated_books{$map_name})) {
502 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
503 my $map_filename = main::locate_include_file ("${map_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
504 || main::locate_include_file ("${map_name}.xref-map");
505 $translated_books{$map_name} = load_map_file ($map_filename);
508 # look up translation. use these values instead of the old filename/anchor
509 my $section_name_map = $translated_books{$map_name};
510 my $node_text = main::remove_texi($node);
511 if (defined($section_name_map->{$node_text})) {
512 ($node_id, $node_hxmlt_id) = @{$section_name_map->{$node_text}};
514 print STDERR "WARNING: Unable to find node '$node_text' in book $map_name.\n";
519 return &$original_func($node, $node_id, $node_hxmlt_id, $file);
521 return &$original_func($node, $node_id, $node_hxmlt_id);
529 #############################################################################
530 ### CUSTOM TOC FOR EACH PAGE (in a frame on the left)
531 #############################################################################
533 my $page_toc_depth = 2;
534 my @default_toc = [];
536 # recursively generate the TOC entries for the element and its children (which
537 # are only shown up to maxlevel. All ancestors of the current element are also
538 # shown with their immediate children, irrespective of their level.
539 # Unnumbered entries are only printed out if they are at top-level or their
540 # parent element is an ancestor of the currently viewed node.
541 sub generate_ly_toc_entries($$$$)
544 my $element_path = shift;
545 my $maxlevel = shift;
546 my $always_show_unnumbered_children = shift;
547 # Skip undefined sections, plus all sections generated by index splitting
548 return() if (not defined($element) or exists($element->{'index_page'}));
550 my $level = $element->{'toc_level'};
551 my $is_parent_of_current = $element->{'id'} && $element_path->{$element->{'id'}};
552 my $print_children = ( ($level < $maxlevel) or $is_parent_of_current );
553 my $ind = ' ' x $level;
554 my $this_css_class = $is_parent_of_current ? " class=\"toc_current\"" : "";
556 my $entry = "$ind<li$this_css_class>" . &$anchor ($element->{'tocid'}, "$element->{'file'}#$element->{'target'}",$element->{'text'});
558 my $children = $element->{'section_childs'};
559 # Don't add unnumbered entries, unless they are at top-level or a parent of the current!
560 if (not ($element->{'number'} or $always_show_unnumbered_children)) {
563 if ( $print_children and defined($children) and (ref($children) eq "ARRAY") ) {
564 push (@result, $entry);
565 my @child_result = ();
566 foreach (@$children) {
567 push (@child_result, generate_ly_toc_entries($_, $element_path, $maxlevel, $is_parent_of_current));
569 # if no child nodes were generated, e.g. for the index, where expanded pages
570 # are ignored, don't generate a list at all...
572 push (@result, "\n$ind<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
573 push (@result, @child_result);
574 push (@result, "$ind</ul></li>\n");
577 push (@result, $entry . "</li>\n");
583 # Print a customized TOC, containing only the first two levels plus the whole
584 # path to the current page
585 sub lilypond_generate_page_toc_body($)
588 my $current_element = $element;
590 $parentelements{$element->{'id'}} = 1;
591 # Find the path to the current element
592 while ( defined($current_element->{'sectionup'}) and
593 ($current_element->{'sectionup'} ne $current_element) )
595 $parentelements{$current_element->{'sectionup'}->{'id'}} = 1
596 if ($current_element->{'sectionup'}->{'id'} ne '');
597 $current_element = $current_element->{'sectionup'};
599 return () if not defined($current_element);
600 # Create the toc entries recursively
601 my @toc_entries = ("<div class=\"contents\">\n", "<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
602 my $children = $current_element->{'section_childs'};
603 foreach ( @$children ) {
604 push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth, False));
606 push (@toc_entries, "</ul>\n");
607 push (@toc_entries, "</div>\n");
611 sub lilypond_print_toc_div ($$)
615 my @lines = @$tocref;
616 # use default TOC if no custom lines have been generated
617 @lines = @default_toc if (not @lines);
620 print $fh "\n\n<div id=\"tocframe\">\n";
621 print $fh '<h4 class="toc_header"> ' . &$anchor('',
622 $Texi2HTML::HREF{'Top'},
623 $Texi2HTML::NAME{'Top'},
624 'title="Start of the manual"'
626 foreach my $line (@lines) {
629 print $fh "</div>\n\n";
633 # Create the custom TOC for this page (partially folded, current page is
634 # highlighted) and store it in a global variable. The TOC is written out after
635 # the html contents (but positioned correctly using CSS), so that browsers with
636 # css turned off still show the contents first.
637 our @this_page_toc = ();
638 sub lilypond_print_element_header
640 my $first_in_page = shift;
641 my $previous_is_top = shift;
642 if ($first_in_page and not @this_page_toc) {
643 if (defined($Texi2HTML::THIS_ELEMENT)) {
644 # Create the TOC for this page
645 @this_page_toc = lilypond_generate_page_toc_body($Texi2HTML::THIS_ELEMENT);
648 return T2H_DEFAULT_print_element_header( $first_in_page, $previous_is_top);
651 # Generate the HTML output for the TOC
652 sub lilypond_toc_body($)
654 my $elements_list = shift;
655 # Generate a default TOC for pages without THIS_ELEMENT
656 @default_toc = lilypond_generate_page_toc_body(@$elements_list[0]);
657 return T2H_GPL_toc_body($elements_list);
660 # Print out the TOC in a <div> at the beginning of the page
661 sub lilypond_print_page_head($)
664 T2H_DEFAULT_print_page_head($fh);
665 print $fh "<div id=\"main\">\n";
668 # Print out the TOC in a <div> at the end of th page, which will be formatted as a
669 # sidebar mimicking a TOC frame
670 sub print_lilypond_page_foot($)
673 my $program_string = &$program_string();
674 # print $fh "<p><font size='-1'>$program_string</font><br>$PRE_BODY_CLOSE</p>\n";
675 print $fh "<!-- FOOTER -->\n\n";
676 print $fh "<!-- end div#main here -->\n</div>\n\n";
678 # Print the TOC frame and reset the TOC:
679 lilypond_print_toc_div ($fh, \@this_page_toc);
683 print $fh "</body>\n</html>\n";
690 #############################################################################
691 ### NICER / MORE FLEXIBLE NAVIGATION PANELS
692 #############################################################################
694 sub get_navigation_text
697 my $text = $NAVIGATION_TEXT{$button};
698 if ( ($button eq 'Back') or ($button eq 'FastBack') ) {
699 $text = $text . $Texi2HTML::NODE{$button} . " ";
700 } elsif ( ($button eq 'Forward') or ($button eq 'FastForward') ) {
701 $text = " " . $Texi2HTML::NODE{$button} . $text;
702 } elsif ( $button eq 'Up' ) {
703 $text = " ".$text.": " . $Texi2HTML::NODE{$button} . " ";
709 # Don't automatically create left-aligned table cells for every link, but
710 # instead create a <td> only on an appropriate '(left|right|center)-aligned-cell-n'
711 # button text. It's alignment as well as the colspan will be taken from the
712 # name of the button. Also, add 'newline' button text to create a new table
713 # row. The texts of the buttons are generated by get_navigation_text and
714 # will contain the name of the next/previous section/chapter.
715 sub lilypond_print_navigation
718 my $vertical = shift;
720 my $result = "<table class=\"nav_table\">\n";
722 $result .= "<tr>" unless $vertical;
724 foreach my $button (@$buttons)
726 $result .= qq{<tr valign="top" align="left">\n} if $vertical;
727 # Allow (left|right|center)-aligned-cell and newline as buttons!
728 if ( $button =~ /^(.*)-aligned-cell-(.*)$/ )
730 $result .= qq{</td>} unless $beginofline;
731 $result .= qq{<td valign="middle" align="$1" colspan="$2">};
734 elsif ( $button eq 'newline' )
736 $result .= qq{</td>} unless $beginofline;
737 $result .= qq{</tr>};
742 elsif (ref($button) eq 'CODE')
744 $result .= &$button($vertical);
746 elsif (ref($button) eq 'SCALAR')
748 $result .= "$$button" if defined($$button);
750 elsif (ref($button) eq 'ARRAY')
752 my $text = $button->[1];
753 my $button_href = $button->[0];
754 # verify that $button_href is simple text and text is a reference
755 if (defined($button_href) and !ref($button_href)
756 and defined($text) and (ref($text) eq 'SCALAR') and defined($$text))
758 if ($Texi2HTML::HREF{$button_href})
760 my $anchor_attributes = '';
761 if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button_href})) and ($BUTTONS_ACCESSKEY{$button_href} ne ''))
763 $anchor_attributes = "accesskey=\"$BUTTONS_ACCESSKEY{$button_href}\"";
765 if ($USE_REL_REV and (defined($BUTTONS_REL{$button_href})) and ($BUTTONS_REL{$button_href} ne ''))
767 $anchor_attributes .= " rel=\"$BUTTONS_REL{$button_href}\"";
771 $Texi2HTML::HREF{$button_href},
772 get_navigation_text($$text),
778 $result .= get_navigation_text($$text);
782 elsif ($button eq ' ')
783 { # handle space button
785 ($ICONS && $ACTIVE_ICONS{' '}) ?
786 &$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{' '}) :
787 $NAVIGATION_TEXT{' '};
790 elsif ($Texi2HTML::HREF{$button})
792 my $btitle = $BUTTONS_GOTO{$button} ?
793 'title="' . $BUTTONS_GOTO{$button} . '"' : '';
794 if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button})) and ($BUTTONS_ACCESSKEY{$button} ne ''))
796 $btitle .= " accesskey=\"$BUTTONS_ACCESSKEY{$button}\"";
798 if ($USE_REL_REV and (defined($BUTTONS_REL{$button})) and ($BUTTONS_REL{$button} ne ''))
800 $btitle .= " rel=\"$BUTTONS_REL{$button}\"";
802 if ($ICONS && $ACTIVE_ICONS{$button})
806 $Texi2HTML::HREF{$button},
807 &$button_icon_img($BUTTONS_NAME{$button},
808 $ACTIVE_ICONS{$button},
809 $Texi2HTML::SIMPLE_TEXT{$button}),
818 $Texi2HTML::HREF{$button},
819 get_navigation_text($button),
826 { # button is passive
828 $ICONS && $PASSIVE_ICONS{$button} ?
829 &$button_icon_img($BUTTONS_NAME{$button},
830 $PASSIVE_ICONS{$button},
831 $Texi2HTML::SIMPLE_TEXT{$button}) :
833 "[" . get_navigation_text($button) . "]";
835 $result .= "</td>\n" if $vertical;
836 $result .= "</tr>\n" if $vertical;
838 $result .= "</td>" unless $beginofline;
839 $result .= "</tr>" unless $vertical;
840 $result .= "</table>\n";
845 @Texi2HTML::Config::SECTION_BUTTONS =
846 ('left-aligned-cell-1', 'FastBack',
847 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
848 'right-aligned-cell-1', 'FastForward',
850 'left-aligned-cell-2', 'Back',
851 'center-aligned-cell-1', 'Up',
852 'right-aligned-cell-2', 'Forward'
855 # buttons for misc stuff
856 @Texi2HTML::Config::MISC_BUTTONS = ('center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About');
858 # buttons for chapter file footers
859 # (and headers but only if SECTION_NAVIGATION is false)
860 @Texi2HTML::Config::CHAPTER_BUTTONS =
861 ('left-aligned-cell-1', 'FastBack',
862 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
863 'right-aligned-cell-1', 'FastForward',
866 # buttons for section file footers
867 @Texi2HTML::Config::SECTION_FOOTER_BUTTONS =
868 ('left-aligned-cell-1', 'FastBack',
869 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
870 'right-aligned-cell-1', 'FastForward',
872 'left-aligned-cell-2', 'Back',
873 'center-aligned-cell-1', 'Up',
874 'right-aligned-cell-2', 'Forward'
877 @Texi2HTML::Config::NODE_FOOTER_BUTTONS =
878 ('left-aligned-cell-1', 'FastBack',
879 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
880 'right-aligned-cell-1', 'FastForward',
882 'left-aligned-cell-2', 'Back',
883 'center-aligned-cell-1', 'Up',
884 'right-aligned-cell-2', 'Forward'
891 #############################################################################
892 ### FOOTNOTE FORMATTING
893 #############################################################################
895 # Format footnotes in a nicer way: Instead of printing the number in a separate
896 # (nr) heading line, use the standard way of prepending <sup>nr</sup> immediately
897 # before the fn text.
900 # The following code is copied from texi2html's examples/makeinfo.init and
901 # should be updated when texi2html makes some changes there!
903 my $makekinfo_like_footnote_absolute_number = 0;
905 sub makeinfo_like_foot_line_and_ref($$$$$$$$)
907 my $foot_num = shift;
908 my $relative_num = shift;
911 my $from_file = shift;
912 my $footnote_file = shift;
916 $makekinfo_like_footnote_absolute_number++;
918 # this is a bit obscure, this allows to add an anchor only if formatted
919 # as part of the document.
920 $docid = '' if ($state->{'outside_document'} or $state->{'multiple_pass'});
922 if ($from_file eq $footnote_file)
924 $from_file = $footnote_file = '';
927 my $foot_anchor = "<sup>" . &$anchor($docid, "$footnote_file#$footid", $relative_num) . "</sup>";
928 $foot_anchor = &$anchor($docid, "$footnote_file#$footid", "($relative_num)") if ($state->{'preformatted'});
930 # unshift @$lines, "<li>";
931 # push @$lines, "</li>\n";
932 return ($lines, $foot_anchor);
935 sub makeinfo_like_foot_lines($)
938 unshift @$lines, "<hr>\n<h4>$Texi2HTML::I18n::WORDS->{'Footnotes_Title'}</h4>\n";
940 # push @$lines, "</ol>";
944 my %makekinfo_like_paragraph_in_footnote_nr;
946 sub makeinfo_like_paragraph ($$$$$$$$$$$$$)
951 my $paragraph_command = shift;
952 my $paragraph_command_formatted = shift;
953 my $paragraph_number = shift;
956 my $enumerate_style = shift;
958 my $command_stack_at_end = shift;
959 my $command_stack_at_begin = shift;
961 #print STDERR "format: $format\n" if (defined($format));
962 #print STDERR "paragraph @$command_stack_at_end; @$command_stack_at_begin\n";
963 $paragraph_command_formatted = '' if (!defined($paragraph_command_formatted) or
964 exists($special_list_commands{$format}->{$paragraph_command}));
965 return '' if ($text =~ /^\s*$/);
966 foreach my $style(t2h_collect_styles($command_stack_at_begin))
968 $text = t2h_begin_style($style, $text);
970 foreach my $style(t2h_collect_styles($command_stack_at_end))
972 $text = t2h_end_style($style, $text);
974 if (defined($paragraph_number) and defined($$paragraph_number))
976 $$paragraph_number++;
977 return $text if (($format eq 'itemize' or $format eq 'enumerate') and
978 ($$paragraph_number == 1));
983 $open .= " align=\"$paragraph_style{$align}\"";
985 my $footnote_text = '';
986 if (defined($command_stack_at_begin->[0]) and $command_stack_at_begin->[0] eq 'footnote')
988 my $state = $Texi2HTML::THISDOC{'state'};
989 $makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number}++;
990 if ($makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number} <= 1)
992 $open.=' class="footnote"';
993 my $document_file = $state->{'footnote_document_file'};
994 if ($document_file eq $state->{'footnote_footnote_file'})
998 my $docid = $state->{'footnote_place_id'};
999 my $doc_state = $state->{'footnote_document_state'};
1000 $docid = '' if ($doc_state->{'outside_document'} or $doc_state->{'multiple_pass'});
1001 my $foot_label = &$anchor($state->{'footnote_footnote_id'},
1002 $document_file . "#$state->{'footnote_place_id'}",
1003 "$state->{'footnote_number_in_page'}");
1004 $footnote_text = "<small>[${foot_label}]</small> ";
1007 return $open.'>'.$footnote_text.$text.'</p>';
1011 #############################################################################
1013 #############################################################################
1015 # For split pages, use index.html as start page!
1016 if ($Texi2HTML::Config::SPLIT eq 'section') {
1017 $Texi2HTML::Config::TOP_FILE = 'index.html';