]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/lilypond-texi2html.init
Imported Upstream version 2.12.3
[lilypond.git] / Documentation / lilypond-texi2html.init
1 #!/usr/bin/env perl
2 # -*- coding: utf-8; -*-
3
4 ### texi2html customization script for Lilypond
5 ### Author: Reinhold Kainhofer <reinhold@kainhofer.com>, 2008.
6 ###         Some code parts copied from texi2html and adapted. These functions
7 ###         were written mainly by Patrice Dumas
8 ### License: GPLv2+
9 ###
10 ###
11 ### Features implemented here:
12 ### -) For split manuals, the main page is index.html.
13 ### -) All @unnumbered* sections are placed into the same file
14 ###    (implemented by split_at_numbered_sections)
15 ### -) Use our custom CSS file, with IE-specific fixes in another CSS file,
16 ###    impelmented by lilypond_css_lines
17 ### -) TOC (folded, with the current page highlighted) in an overflown <div>
18 ###    is added to every page; implemented by:
19 ###           lilypond_print_element_header -- building of the TOC
20 ###           lilypond_toc_body -- generation of customized TOC output
21 ###           lilypond_print_page_head -- start <div id="main">
22 ###           print_lilypond_page_foot -- closing id=main, output of footer & TOC
23 ### -) External refs are formatted only as "Text of the node" (not as >>see
24 ###    "NODE" section "SECTION" in "BOOK"<< like with default texi2html). Also,
25 ###    the leading "(book-name)" is removed.
26 ###    Implemented by overriding lilypond_external_ref
27 ### -) Navigation bars on top/bottom of the page and between sections are not
28 ###    left-aligned, but use a combination of left/center/right aligned table
29 ###    cells; For this, I heavily extend the texi2html code to allow for
30 ###    differently aligned cells and for multi-line tables);
31 ###    Implemented in lilypond_print_navigation
32 ### -) Different formatting than the default: example uses the same formatting
33 ###    as quote.
34 ### -) Allow translated section titles: All section titles can be translated,
35 ###    the original (English) title is associated with @translationof. This is
36 ###    needed, because the file name / anchor is generated from the original
37 ###    English title, since otherwise language-autoselection would break with
38 ###    posted links.
39 ###    Since it is then no longer possible to obtain the file name from the
40 ###    section title, I keep a sectionname<=>filename/anchor around. This way,
41 ###    xrefs from other manuals can simply load that map and retrieve the
42 ###    correct file name for the link. Implemented in:
43 ###           lilypond_unknown (handling of @translationof, in case
44 ###                             extract_texi_filenames.py messes up...)
45 ###           lilypond_element_file_name (correct file name: use the map)
46 ###           lilypond_element_target_name (correct anchor: use the map)
47 ###           lilypond_init_map (read in the externally created map from disk)
48 ###           lilypond_external_href (load the map for xrefs, use the correct
49 ###                                   link target)
50 ### -) The HTML anchors for all sections are derived from the node name /
51 ###    section title (pre-generated in the .xref-map file). Implemented by:
52 ###           lilypond_element_target_name (adjust section anchors)
53 ### -) Use the standard footnote format "<sup>nr</sup> text" instead of the
54 ###    ugly format of texi2html (<h3>(nr)</h3><p>text</p>). Implemented in
55 ###           makeinfo_like_foot_line_and_ref
56 ###           makeinfo_like_foot_lines
57 ###           makeinfo_like_paragraph
58 ###
59 ###
60 ### Useful helper functions:
61 ### -) texinfo_file_name($node_name): returns a texinfo-compatible file name
62 ###    for the given string $node_name (whitespace trimmed/replaced by -,
63 ###    non-standard chars replaced by _xxxx (ascii char code) and forced to
64 ###    start with a letter by prepending t_g if necessary)
65
66
67 package Texi2HTML::Config;
68
69 #############################################################################
70 ### TRANSLATIONS
71 #############################################################################
72
73 use utf8;
74 my $LY_LANGUAGES = {};
75 $LY_LANGUAGES->{'fr'} = {
76     'Back to Documentation Index' => 'Retour à l\'accueil de la documentation',
77 };
78 $LY_LANGUAGES->{'es'} = {
79     'Back to Documentation Index' => 'Volver al índice de la documentación',
80 };
81 $LY_LANGUAGES->{'de'} = {
82     'Back to Documentation Index' => 'Zur Dokumentationsübersicht',
83 };
84
85 # FIXME: request the translations below then send them to texi2html/texinfo devs
86 $LANGUAGES->{'ja'} = {
87                        '  The buttons in the navigation panels have the following meaning:' => '  ナビゲーション パネルの中にあるボタンには以下のような意味があります:',
88                        '  where the @strong{ Example } assumes that the current position is at @strong{ Subsubsection One-Two-Three } of a document of the following structure:' => '  この表で、@strong{ 行き先 } は、現在の位置が以下のような構造を持つドキュメントの @strong{ サブサブセクション 1-2-3 } であると仮定しています:',
89                        ' Up ' => ' 上へ ',
90                        '(outside of any element)' => '(outside of any element)',
91                        '(outside of any node)' => '(outside of any node)',
92                        '@b{{quotation_arg}:} ' => '@b{{quotation_arg}:} ',
93                        '@cite{{book}}' => '@cite{{book}}',
94                        '@{No value for `{value}\'@}' => '@{No value for `{value}\'@}',
95                        'About' => '情報',
96                        'About (help)' => '情報 (ヘルプ)',
97                        'About This Document' => 'このドキュメントについて',
98                        'April' => '4 月',
99                        'August' => '8 月',
100                        'Back' => 'Back',
101                        'Back section in previous file' => '',
102                        'Beginning of this chapter or previous chapter' => 'この章あるいは前の章の先頭',
103                        'Button' => 'ボタン',
104                        'Contents' => '目次',
105                        'Cover (top) of document' => 'ドキュメントの表紙 (先頭)',
106                        'Current' => '',
107                        'Current Position' => '現在の位置',
108                        'Current section' => '',
109                        'December' => '12 月',
110                        'FastBack' => '',
111                        'FastForward' => '',
112                        'February' => '2 月',
113                        'First' => '',
114                        'First section in reading order' => '',
115                        'Following' => '',
116                        'Following node' => '',
117                        'Footnotes' => '脚注',
118                        'Forward' => '',
119                        'Forward section in next file' => '',
120                        'From 1.2.3 go to' => '1.2.3 からの行き先',
121                        'Go to' => '行き先',
122                        'Index' => 'インデックス',
123                        'Index Entry' => 'インデックス エントリ',
124                        'January' => '1 月',
125                        'July' => '7 月',
126                        'Jump to' => '',
127                        'June' => '6月',
128                        'Last' => '',
129                        'Last section in reading order' => '',
130                        'March' => '3 月',
131                        'May' => '5 月',
132                        'Menu:' => 'メニュー',
133                        'Name' => '',
134                        'Next' => '',
135                        'Next chapter' => '次の章',
136                        'Next file' => '',
137                        'Next node' => '',
138                        'Next section in reading order' => '次のセクション',
139                        'Next section on same level' => '',
140                        'NextFile' => '',
141                        'Node following in node reading order' => '',
142                        'Node up' => '',
143                        'NodeNext' => '',
144                        'NodePrev' => '',
145                        'NodeUp' => '',
146                        'November' => '11 月',
147                        'October' => '10 月',
148                        'Overview' => '概要',
149                        'Prev' => '',
150                        'PrevFile' => '',
151                        'Previous' => '',
152                        'Previous file' => '',
153                        'Previous node' => '',
154                        'Previous section in reading order' => '前のセクション',
155                        'Previous section on same level' => '',
156                        'Section' => 'セクション',
157                        'Section One' => 'セクション 1',
158                        'See ' => '',
159                        'See @cite{{book}}' => '',
160                        'See section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '',
161                        'See section `{section}\' in @cite{{book}}' => '',
162                        'See section {reference_name}' => '',
163                        'See {node_file_href}' => '',
164                        'See {node_file_href} @cite{{book}}' => '',
165                        'See {node_file_href} section `{section}\' in @cite{{book}}' => '',
166                        'See {reference_name}' => '',
167                        'See {ref}' => '',
168                        'See {title_ref}' => '',
169                        'September' => '9 月',
170                        'Short Table of Contents' => '',
171                        'Short table of contents' => '',
172                        'Subsection One-Four' => 'サブセクション 1-4',
173                        'Subsection One-One' => 'サブセクション 1-1',
174                        'Subsection One-Three' => 'サブセクション 1-3',
175                        'Subsection One-Two' => 'サブセクション 1-2',
176                        'Subsubsection One-Two-Four' => 'サブサブセクション 1-2-4',
177                        'Subsubsection One-Two-One' => 'サブサブセクション 1-2-1',
178                        'Subsubsection One-Two-Three' => 'サブサブセクション 1-2-3',
179                        'Subsubsection One-Two-Two' => 'サブサブセクション 1-2-2',
180                        'T2H_today' => '%s, %d %d',
181                        'Table of Contents' => '目次',
182                        'Table of contents' => '目次',
183                        'The node you are looking for is at {href}.' => '',
184                        'This' => '',
185                        'This document was generated on @i{{date}} using @uref{{program_homepage}, @i{{program}}}.' => 'このドキュメントは @i{{date}} に、@uref{{program_homepage}, @i{{program}}} を用いて生成されました。',
186                        'This document was generated using @uref{{program_homepage}, @emph{{program}}}.' => 'このドキュメントは @uref{{program_homepage}, @emph{{program}}} を用いて生成されました。',
187                        'Top' => 'トップ',
188                        'Untitled Document' => '',
189                        'Up' => '上',
190                        'Up node' => '',
191                        'Up section' => '上のセクション',
192                        'current' => '',
193                        'on @emph{{date}}' => '@emph{{date}} に',
194                        'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '',
195                        'section `{section}\' in @cite{{book}}' => '',
196                        'see ' => '',
197                        'see @cite{{book}}' => '',
198                        'see section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '',
199                        'see section `{section}\' in @cite{{book}}' => '',
200                        'see section {reference_name}' => '',
201                        'see {node_file_href}' => '',
202                        'see {node_file_href} @cite{{book}}' => '',
203                        'see {node_file_href} section `{section}\' in @cite{{book}}' => '',
204                        'see {reference_name}' => '',
205                        'see {ref}' => '',
206                        'see {title_ref}' => '',
207                        '{acronym_like} ({explanation})' => '{acronym_like} ({explanation})',
208                        '{name} of {class}' => '',
209                        '{name} on {class}' => '',
210                        '{node_file_href}' => '',
211                        '{node_file_href} @cite{{book}}' => '',
212                        '{node_file_href} section `{section}\' in @cite{{book}}' => '',
213                        '{reference_name}' => '',
214                        '{ref}' => '{ref}',
215                        '{style} {number}' => '{style} {number}',
216                        '{style}: {caption_first_line}' => '{style}: {caption_first_line}',
217                        '{style}: {shortcaption_first_line}' => '{style}: {shortcaption_first_line}',
218                        '{title_ref}' => '{title_ref}'
219                      };
220
221 sub ly_get_string () {
222     my $lang = $Texi2HTML::THISDOC{current_lang};
223     my $string = shift;
224     if ($lang and $lang ne "en" and $LY_LANGUAGES->{$lang}->{$string}) {
225         return $LY_LANGUAGES->{$lang}->{$string};
226     } else {
227         return $string;
228     }
229 }
230
231
232 #############################################################################
233 ###  SETTINGS FOR TEXI2HTML
234 #############################################################################
235
236 @Texi2HTML::Config::CSS_REFS      = (
237     {FILENAME => "lilypond-mccarty.css", TITLE => "Patrick McCarty's design"}
238 );
239 @Texi2HTML::Config::ALT_CSS_REFS      = (
240     {FILENAME => "lilypond.css", TITLE => "Andrew Hawryluk's design" },
241     {FILENAME => "lilypond-blue.css", TITLE => "Kurt Kroon's blue design" },
242 );
243 $Texi2HTML::Config::USE_ACCESSKEY = 1;
244 $Texi2HTML::Config::USE_LINKS     = 1;
245 $Texi2HTML::Config::USE_REL_REV   = 1;
246 $Texi2HTML::Config::SPLIT_INDEX   = 0;
247 $Texi2HTML::Config::SEPARATED_FOOTNOTES = 0; # Print footnotes on same page, not separated
248 if ($Texi2HTML::Config::SPLIT eq 'section') {
249   $Texi2HTML::Config::element_file_name    = \&lilypond_element_file_name;
250 }
251 $Texi2HTML::Config::element_target_name  = \&lilypond_element_target_name;
252 $default_print_element_header = $Texi2HTML::Config::print_element_header;
253 $Texi2HTML::Config::print_element_header = \&lilypond_print_element_header;
254 $Texi2HTML::Config::print_page_foot      = \&print_lilypond_page_foot;
255 $Texi2HTML::Config::print_navigation     = \&lilypond_print_navigation;
256 $Texi2HTML::Config::external_ref         = \&lilypond_external_ref;
257 $default_external_href = $Texi2HTML::Config::external_href;
258 $Texi2HTML::Config::external_href        = \&lilypond_external_href;
259 $default_toc_body = $Texi2HTML::Config::toc_body;
260 $Texi2HTML::Config::toc_body             = \&lilypond_toc_body;
261 $Texi2HTML::Config::css_lines            = \&lilypond_css_lines;
262 $default_unknown = $Texi2HTML::Config::unknown;
263 $Texi2HTML::Config::unknown              = \&lilypond_unknown;
264 $default_print_page_head = $Texi2HTML::Config::print_page_head;
265 $Texi2HTML::Config::print_page_head      = \&lilypond_print_page_head;
266 # $Texi2HTML::Config::foot_line_and_ref    = \&lilypond_foot_line_and_ref;
267 $Texi2HTML::Config::foot_line_and_ref  = \&makeinfo_like_foot_line_and_ref;
268 $Texi2HTML::Config::foot_lines         = \&makeinfo_like_foot_lines;
269 $Texi2HTML::Config::paragraph          = \&makeinfo_like_paragraph;
270
271
272
273 # Examples should be formatted similar to quotes:
274 $Texi2HTML::Config::complex_format_map->{'example'} = {
275   'begin' => q{"<blockquote>"},
276   'end' => q{"</blockquote>\n"},
277   'style' => 'code',
278  };
279
280 %Texi2HTML::config::misc_pages_targets = (
281    'Overview' => 'Overview',
282    'Contents' => 'Contents',
283    'About' => 'About'
284 );
285
286
287 my @section_to_filename;
288
289
290
291
292 #############################################################################
293 ###  DEBUGGING
294 #############################################################################
295
296 use Data::Dumper;
297 $Data::Dumper::Maxdepth = 2;
298
299 sub print_element_info($)
300 {
301   my $element = shift;
302   print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
303   print "Element: $element\n";
304   print Dumper($element);
305 }
306
307
308
309
310
311 #############################################################################
312 ###  HELPER FUNCTIONS
313 #############################################################################
314
315 # Convert a given node name to its proper file name (normalization as explained
316 # in the texinfo manual:
317 # http://www.gnu.org/software/texinfo/manual/texinfo/html_node/HTML-Xref-Node-Name-Expansion.html
318 sub texinfo_file_name($)
319 {
320   my $text = shift;
321   my $result = '';
322   # File name normalization by texinfo:
323   # 1/2: letters and numbers are left unchanged
324   # 3/4: multiple, leading and trailing whitespace is removed
325   $text = main::normalise_space($text);
326   # 5/6: all remaining spaces are converted to '-', all other 7- or 8-bit
327   #      chars are replaced by _xxxx (xxxx=ascii character code)
328   while ($text ne '') {
329     if ($text =~ s/^([A-Za-z0-9]+)//o) { # number or letter stay unchanged
330       $result .= $1;
331     } elsif ($text =~ s/^ //o) { # space -> '-'
332       $result .= '-';
333     } elsif ($text =~ s/^(.)//o) { # Otherwise use _xxxx (ascii char code)
334       my $ccode = ord($1);
335       if ( $ccode <= 0xFFFF ) {
336         $result .= sprintf("_%04x", $ccode);
337       } else {
338         $result .= sprintf("__%06x", $ccode);
339       }
340     }
341   }
342   # 7: if name does not begin with a letter, prepend 't_g' (so it starts with a letter)
343   if ($result !~ /^[a-zA-Z]/) {
344     $result = 't_g' . $result;
345   }
346   # DONE
347   return $result
348 }
349
350
351 # Load a file containing a nodename<=>filename map (tab-sepatared, i.e.
352 # NODENAME\tFILENAME\tANCHOR
353 # Returns a ref to a hash "Node title" => ["FilenameWithoutExt", "Anchor"]
354 sub load_map_file ($)
355 {
356     my $mapfile = shift;
357     my $node_map = ();
358
359     if (open(XREFFILE,'<:encoding(utf8)', $mapfile)) {
360         my $line;
361         while ( $line = <XREFFILE> ) {
362             # parse the tab-separated entries and insert them into the map:
363             chomp($line);
364             my @entries = split(/\t/, $line);
365             if (scalar (@entries) == 3) {
366               $node_map->{$entries[0]} = [$entries[1], $entries[2]];
367             } else {
368               print STDERR "Invalid entry in the node file $mapfile: $line\n";
369             }
370         }
371         close (XREFFILE);
372     } else {
373         print STDERR "WARNING: Unable to load the map file $mapfile\n";
374     }
375     return $node_map;
376 }
377
378
379 # Split the given path into dir and basename (with .texi removed). Used mainly
380 # to get the path/basename of the original texi input file
381 sub split_texi_filename ($)
382 {
383   my $docu = shift;
384   my ($docu_dir, $docu_name);
385   if ($docu =~ /(.*\/)/) {
386     chop($docu_dir = $1);
387     $docu_name = $docu;
388     $docu_name =~ s/.*\///;
389   } else {
390      $docu_dir = '.';
391      $docu_name = $docu;
392   }
393   $docu_name =~ s/\.te?x(i|info)?$//;
394   return ($docu_dir, $docu_name);
395 }
396
397
398
399
400
401 #############################################################################
402 ###  CSS HANDLING
403 #############################################################################
404
405 # Include our standard CSS file, not hard-coded CSS code directly in the HTML!
406 # For IE, conditionally include the lilypond-ie-fixes.css style sheet
407 sub lilypond_css_lines ($$)
408 {
409     my $import_lines = shift;
410     my $rule_lines = shift;
411     return if (defined($Texi2HTML::THISDOC{'CSS_LINES'}));
412     if (@$rule_lines or @$import_lines)
413     {
414         $Texi2HTML::THISDOC{'CSS_LINES'} = "<style type=\"text/css\">\n<!--\n";
415         $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$import_lines) . "\n" if (@$import_lines);
416         $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$rule_lines) . "\n" if (@$rule_lines);
417         $Texi2HTML::THISDOC{'CSS_LINES'} .= "-->\n</style>\n";
418     }
419     foreach my $ref (@CSS_REFS)
420     {
421         $Texi2HTML::THISDOC{'CSS_LINES'} .= "<link rel=\"stylesheet\" type=\"text/css\" title=\"$ref->{TITLE}\" href=\"$ref->{FILENAME}\">\n";
422     }
423     foreach my $ref (@Texi2HTML::Config::ALT_CSS_REFS)
424     {
425         $Texi2HTML::THISDOC{'CSS_LINES'} .= "<link rel=\"alternate stylesheet\" type=\"text/css\" href=\"$ref->{FILENAME}\" title=\"$ref->{TITLE}\">\n";
426     }
427     $Texi2HTML::THISDOC{'CSS_LINES'} .= "<!--[if lte IE 7]>\n<link href=\"lilypond-ie-fixes.css\" rel=\"stylesheet\" type=\"text/css\">\n<![endif]-->\n";
428 }
429
430
431
432
433
434 #############################################################################
435 ###  SPLITTING BASED ON NUMBERED SECTIONS
436 #############################################################################
437
438 my $lastfilename;
439 my $docnr = 0;
440 my $node_to_filename_map = ();
441
442
443 # This function makes sure that files are only generated for numbered sections,
444 # but not for unnumbered ones. It is called after texi2html has done its own
445 # splitting and simply returns the filename for the node given as first argument
446 # Nodes with the same filename will be printed out to the same filename, so
447 # this really all we need. Also, make sure that the file names for sections
448 # are derived from the section title. We also might want to name the anchors
449 # according to node titles, which works by simply overriding the id element of
450 # the $element hash.
451 # If an external nodename<=>filename/anchor map file is found (loaded in
452 # the command handler, use the externally created values, otherwise use the
453 # same logic here.
454 sub lilypond_element_file_name($$$)
455 {
456   my $element = shift;
457   my $type = shift;
458   my $docu_name = shift;
459   my $docu_ext = $Texi2HTML::Config::EXTENSION;
460
461   my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
462   # the snippets page does not use nodes for the snippets, so in this case
463   # we'll have to use the section name!
464   if ($node_name eq '') {
465     $node_name = main::remove_texi($element->{'texi'});
466   }
467
468   # If we have an entry in the section<=>filename map, use that one, otherwise
469   # generate the filename/anchor here. In the latter case, external manuals
470   # will not be able to retrieve the file name for xrefs!!! Still, I already
471   # had that code, so I'll leave it in in case something goes wrong with the
472   # extract_texi_filenames.py script in the lilypond build process!
473   if (exists ($node_to_filename_map->{$node_name})) {
474     (my $filename, my $anchor) = @{$node_to_filename_map->{$node_name}};
475     $filename .= ".$docu_ext" if (defined($docu_ext));
476
477     # unnumbered sections (except those at top-level!) always go to the same
478     # file as the previous numbered section
479     if (not ($element->{number}) and not ($lastfilename eq '') and ($element->{level} > 1)) {
480       $filename = $lastfilename;
481     }
482     if (($filename eq $lastfilename)) {
483       $$element{doc_nr} = $docnr;
484     } else {
485       $docnr += 1;
486       $$element{doc_nr} = $docnr;
487       $lastfilename = $filename;
488     }
489     return $filename;
490
491   } elsif ($type eq "top" or $type eq "toc" or $type eq "doc" or $type eq "stoc" or $type eq "foot" or $type eq "about") {
492     return;
493   } else {
494     print STDERR "WARNING: Node '$node_name' was NOT found in the map\n"
495         unless ($node_name eq '') or ($element->{'tag'} eq 'unnumberedsec')
496                or ($node_name =~ /NOT REALLY USED/);
497
498     # Numbered sections will get a filename Node_title, unnumbered sections will use
499     # the file name of the previous numbered section:
500     if (($element->{number}) or ($lastfilename eq '') or ($element->{level} == 1)) {
501       # normalize to the same file name as texinfo
502       if ($element->{translationof}) {
503         $node_name = main::remove_texi($element->{translationof});
504       }
505       my $filename = texinfo_file_name($node_name);
506       $filename .= ".$docu_ext" if (defined($docu_ext));
507       $docnr += 1;
508       $$element{doc_nr} = $docnr;
509       $lastfilename = $filename;
510       return $filename;
511     } else {
512       $$element{doc_nr} = $docnr;
513       return $lastfilename;
514     }
515   }
516
517   return;
518 }
519
520 sub lilypond_element_target_name($$$)
521 {
522   my $element = shift;
523   my $target = shift;
524   my $id = shift;
525   # Target is based on node name (or sec name for secs without node attached)
526   my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
527   if ($node_name eq '') {
528     $node_name = main::remove_texi($element->{'texi'});
529   }
530
531   # If we have an entry in the section<=>filename map, use that one, otherwise
532   # generate the anchor here.
533   if (exists ($node_to_filename_map->{$node_name})) {
534     (my $filename, $target) = @{$node_to_filename_map->{$node_name}};
535   } else {
536     my $anchor = $node_name;
537     if ($element->{translationof}) {
538       $anchor = main::remove_texi($element->{translationof});
539     }
540     # normalize to the same file name as texinfo
541     $target = texinfo_file_name($anchor);
542   }
543   # TODO: Once texi2html correctly prints out the target and not the id for
544   #       the sections, change this back to ($id, $target)
545   return ($target, $target);
546 }
547
548
549 ## Load the map file for the corrently processed texi file. We do this
550 #  using a command init handler, since texi2html does not have any
551 #  other hooks that are called after THISDOC is filled but before phase 2
552 #  of the texi2html conversion.
553 sub lilypond_init_map ()
554 {
555     my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
556     my $map_filename = main::locate_include_file ("${docu_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
557         || main::locate_include_file ("${docu_name}.xref-map");
558     $node_to_filename_map = load_map_file ($map_filename);
559 }
560 push @Texi2HTML::Config::command_handler_init, \&lilypond_init_map;
561
562
563
564 #############################################################################
565 ###  CLEANER LINK TITLE FOR EXTERNAL REFS
566 #############################################################################
567
568 # The default formatting of external refs returns e.g.
569 # "(lilypond-internals)Timing_translator", so we remove all (...) from the
570 # file_and_node argument. Also, we want only a very simple format, so we don't
571 # even call the default handler!
572 sub lilypond_external_ref($$$$$$)
573 {
574   my $type = shift;
575   my $section = shift;
576   my $book = shift;
577   my $file_node = shift;
578   my $href = shift;
579   my $cross_ref = shift;
580
581   my $displaytext = '';
582
583   # 1) if we have a cross ref name, that's the text to be displayed:
584   # 2) For the top node, use the (printable) name of the manual, unless we
585   #    have an explicit cross ref name
586   # 3) In all other cases use the section name
587   if ($cross_ref ne '') {
588     $displaytext = $cross_ref;
589   } elsif (($section eq '') or ($section eq 'Top')) {
590     $displaytext = $book;
591   } else {
592     $displaytext = $section;
593   }
594
595   $displaytext = &$anchor('', $href, $displaytext) if ($displaytext ne '');
596   return &$I('%{node_file_href}', { 'node_file_href' => $displaytext });
597 }
598
599
600
601
602
603 #############################################################################
604 ###  HANDLING TRANSLATED SECTIONS: handle @translationof, secname<->filename
605 ###                  map stored on disk, xrefs in other manuals load that map
606 #############################################################################
607
608
609 # Try to make use of @translationof to generate files according to the original
610 # English section title...
611 sub lilypond_unknown($$$$$)
612 {
613     my $macro = shift;
614     my $line = shift;
615     my $pass = shift;
616     my $stack = shift;
617     my $state = shift;
618
619     # the @translationof macro provides the original English section title,
620     # which should be used for file/anchor naming, while the title will be
621     # translated to each language
622     # It is already used by extract_texi_filenames.py, so this should not be
623     # necessary here at all. Still, I'll leave the code in just in case the
624     # python script messed up ;-)
625     if ($pass == 1 and $macro eq "translationof") {
626       if (ref($state->{'element'}) eq 'HASH') {
627         $state->{'element'}->{'translationof'} = main::normalise_space($line);
628       }
629       return ('', 1, undef, undef);
630     } else {
631       return &$default_unknown($macro, $line, $pass, $stack, $state);
632     }
633 }
634
635
636
637
638 my %translated_books = ();
639 # Construct a href to an external source of information.
640 # node is the node with texinfo @-commands
641 # node_id is the node transliterated and transformed as explained in the
642 #         texinfo manual
643 # node_xhtml_id is the node transformed such that it is unique and can
644 #     be used to make an html cross ref as explained in the texinfo manual
645 # file is the file in '(file)node'
646 sub lilypond_external_href($$$)
647 {
648   my $node = shift;
649   my $node_id = shift;
650   my $node_hxmlt_id = shift;
651   my $file = shift;
652
653   # 1) Keep a hash of book->section_map
654   # 2) if not file in keys hash => try to load the map (assign empty map if
655   #    non-existent => will load only once!)
656   # 3) if node in the section=>(file, anchor) map, replace node_id and
657   #    node_xhtml_id by the map's values
658   # 4) call the default_external_href with these values (or the old ones if not found)
659
660   if (($node_id ne '') and defined($file) and ($node_id ne 'Top')) {
661     my $map_name = $file;
662     $map_name =~ s/-big-page//;
663
664     # Load the map if we haven't done so already
665     if (!exists($translated_books{$map_name})) {
666       my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
667       my $map_filename = main::locate_include_file ("${map_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
668           || main::locate_include_file ("${map_name}.xref-map");
669       $translated_books{$map_name} = load_map_file ($map_filename);
670     }
671
672     # look up translation. use these values instead of the old filename/anchor
673     my $section_name_map = $translated_books{$map_name};
674     my $node_text = main::remove_texi($node);
675     if (defined($section_name_map->{$node_text})) {
676       ($node_id, $node_hxmlt_id) = @{$section_name_map->{$node_text}};
677     } else {
678       print STDERR "WARNING: Unable to find node '$node_text' in book $map_name.\n";
679     }
680   }
681
682   if (defined $file) {
683     return &$default_external_href($node, $node_id, $node_hxmlt_id, $file);
684   } else {
685     return &$default_external_href($node, $node_id, $node_hxmlt_id);
686   }
687 }
688
689
690
691
692
693 #############################################################################
694 ###  CUSTOM TOC FOR EACH PAGE (in a frame on the left)
695 #############################################################################
696
697 my $page_toc_depth = 2;
698 my @default_toc = [];
699
700
701 # Initialize the toc_depth to 1 if the command-line option -D=short_toc is given
702 sub lilypond_init_toc_depth ()
703 {
704   if (exists($main::value{'short_toc'}) and not exists($main::value{'bigpage'})) {
705     $page_toc_depth = 1;
706   }
707 }
708 # Set the TOC-depth (depending on a texinfo variable short_toc) in a 
709 # command-handler, so we have them available when creating the pages
710 push @Texi2HTML::Config::command_handler_process, \&lilypond_init_toc_depth;
711
712
713 # recursively generate the TOC entries for the element and its children (which
714 # are only shown up to maxlevel. All ancestors of the current element are also
715 # shown with their immediate children, irrespective of their level.
716 # Unnumbered entries are only printed out if they are at top-level or 2nd level 
717 # or their parent element is an ancestor of the currently viewed node.
718 # The conditions to call this method to print the entry for a child node is:
719 # -) the parent is an ancestor of the current page node
720 # -) the parent is a numbered element at top-level toplevel (i.e. show numbered 
721 #    and unnumbered 2nd-level children of numbered nodes)
722 # -) the child element is a numbered node below level maxlevel
723 sub generate_ly_toc_entries($$$)
724 {
725   my $element = shift;
726   my $element_path = shift;
727   my $maxlevel = shift;
728   # Skip undefined sections, plus all sections generated by index splitting
729   return() if (not defined($element) or exists($element->{'index_page'}));
730   my @result = ();
731   my $level = $element->{'toc_level'};
732   my $is_parent_of_current = $element->{'id'} && $element_path->{$element->{'id'}};
733   my $ind = '  ' x $level;
734   my $this_css_class = $is_parent_of_current ? " class=\"toc_current\"" : "";
735
736   my $entry = "$ind<li$this_css_class>" . &$anchor ($element->{'tocid'}, "$element->{'file'}#$element->{'target'}",$element->{'text'});
737
738   push (@result, $entry);
739   my $children = $element->{'section_childs'};
740   if (defined($children) and (ref($children) eq "ARRAY")) {
741     my $force_children = $is_parent_of_current or ($level == 1 and $element->{'number'});
742     my @child_result = ();
743     foreach my $c (@$children) {
744       my $is_numbered_child = defined ($c->{'number'});
745       my $below_maxlevel = $c->{'toc_level'} le $maxlevel;
746       if ($force_children or ($is_numbered_child and $below_maxlevel)) {
747         my @child_res = generate_ly_toc_entries($c, $element_path, $maxlevel);
748         push (@child_result, @child_res);
749       }
750     }
751     # if no child nodes were generated, e.g. for the index, where expanded pages
752     # are ignored, don't generate a list at all...
753     if (@child_result) {
754       push (@result, "\n$ind<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
755       push (@result, @child_result);
756       push (@result, "$ind</ul>\n");
757     }
758   }
759   push (@result, "$ind</li>\n");
760   return @result;
761 }
762
763
764 # Print a customized TOC, containing only the first two levels plus the whole
765 # path to the current page
766 sub lilypond_generate_page_toc_body($)
767 {
768     my $element = shift;
769     my $current_element = $element;
770     my %parentelements;
771     $parentelements{$element->{'id'}} = 1;
772     # Find the path to the current element
773     while ( defined($current_element->{'sectionup'}) and
774            ($current_element->{'sectionup'} ne $current_element) )
775     {
776       $parentelements{$current_element->{'sectionup'}->{'id'}} = 1
777               if ($current_element->{'sectionup'}->{'id'} ne '');
778       $current_element = $current_element->{'sectionup'};
779     }
780     return () if not defined($current_element);
781     # Create the toc entries recursively
782     my @toc_entries = ("<div class=\"contents\">\n", "<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
783     my $children = $current_element->{'section_childs'};
784     foreach ( @$children ) {
785       push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth));
786     }
787     push (@toc_entries, "</ul>\n");
788     push (@toc_entries, "</div>\n");
789     return @toc_entries;
790 }
791
792 sub lilypond_print_toc_div ($$)
793 {
794   my $fh = shift;
795   my $tocref = shift;
796   my @lines = @$tocref;
797   # use default TOC if no custom lines have been generated
798   @lines = @default_toc if (not @lines);
799   if (@lines) {
800   
801     print $fh "\n\n<div id=\"tocframe\">\n";
802     
803     # Remove the leading "GNU LilyPond --- " from the manual title
804     my $topname = $Texi2HTML::NAME{'Top'};
805     $topname =~ s/^GNU LilyPond(:| &[mn]dash;) //;
806     
807     # construct the top-level Docs index (relative path and including language!)
808     my $lang = $Texi2HTML::THISDOC{current_lang};
809     if ($lang and $lang ne "en") {
810       $lang .= ".";
811     } else {
812       $lang = "";
813     }
814     my $reldir = "";
815     $reldir = "../" if ($Texi2HTML::Config::SPLIT eq 'section');
816     my $uplink = $reldir."index.${lang}html";
817
818     print $fh "<p class=\"toc_uplink\"><a href=\"$uplink\" 
819          title=\"Documentation Index\">&lt;&lt; " .
820          &ly_get_string ('Back to Documentation Index') .
821          "</a></p>\n";
822
823     print $fh '<h4 class="toc_header"> ' . &$anchor('',
824                                     $Texi2HTML::HREF{'Top'},
825                                     $topname,
826                                     'title="Start of the manual"'
827                                    ) . "</h4>\n";
828     foreach my $line (@lines) {
829       print $fh $line;
830     }
831     print $fh "</div>\n\n";
832   }
833 }
834
835 # Create the custom TOC for this page (partially folded, current page is
836 # highlighted) and store it in a global variable. The TOC is written out after
837 # the html contents (but positioned correctly using CSS), so that browsers with
838 # css turned off still show the contents first.
839 our @this_page_toc = ();
840 sub lilypond_print_element_header
841 {
842   my $first_in_page = shift;
843   my $previous_is_top = shift;
844   if ($first_in_page and not @this_page_toc) {
845     if (defined($Texi2HTML::THIS_ELEMENT)) {
846       # Create the TOC for this page
847       @this_page_toc = lilypond_generate_page_toc_body($Texi2HTML::THIS_ELEMENT);
848     }
849   }
850   return &$default_print_element_header( $first_in_page, $previous_is_top);
851 }
852
853 # Generate the HTML output for the TOC
854 sub lilypond_toc_body($)
855 {
856     my $elements_list = shift;
857     # Generate a default TOC for pages without THIS_ELEMENT
858     @default_toc = lilypond_generate_page_toc_body(@$elements_list[0]);
859     return &$default_toc_body($elements_list);
860 }
861
862 # Print out the TOC in a <div> at the beginning of the page
863 sub lilypond_print_page_head($)
864 {
865     my $fh = shift;
866     &$default_print_page_head($fh);
867     print $fh "<div id=\"main\">\n";
868 }
869
870 # Print out the TOC in a <div> at the end of th page, which will be formatted as a
871 # sidebar mimicking a TOC frame
872 sub print_lilypond_page_foot($)
873 {
874   my $fh = shift;
875   my $program_string = &$program_string();
876 #   print $fh "<p><font size='-1'>$program_string</font><br>$PRE_BODY_CLOSE</p>\n";
877   print $fh "<!-- FOOTER -->\n\n";
878   print $fh "<!-- end div#main here -->\n</div>\n\n";
879
880   # Print the TOC frame and reset the TOC:
881   lilypond_print_toc_div ($fh, \@this_page_toc);
882   @this_page_toc = ();
883
884   # Close the page:
885   print $fh "</body>\n</html>\n";
886 }
887
888
889
890
891
892 #############################################################################
893 ###  NICER / MORE FLEXIBLE NAVIGATION PANELS
894 #############################################################################
895
896 sub get_navigation_text
897 {
898   my $button = shift;
899   my $text = $NAVIGATION_TEXT{$button};
900   if ( ($button eq 'Back') or ($button eq 'FastBack') ) {
901     $text = $text . $Texi2HTML::NODE{$button} . "&nbsp;";
902   } elsif ( ($button eq 'Forward') or ($button eq 'FastForward') ) {
903     $text = "&nbsp;" . $Texi2HTML::NODE{$button} . $text;
904   } elsif ( $button eq 'Up' ) {
905     $text = "&nbsp;".$text.":&nbsp;" . $Texi2HTML::NODE{$button} . "&nbsp;";
906   }
907   return $text;
908 }
909
910
911 # Don't automatically create left-aligned table cells for every link, but
912 # instead create a <td> only on an appropriate '(left|right|center)-aligned-cell-n'
913 # button text. It's alignment as well as the colspan will be taken from the
914 # name of the button. Also, add 'newline' button text to create a new table
915 # row. The texts of the buttons are generated by get_navigation_text and
916 # will contain the name of the next/previous section/chapter.
917 sub lilypond_print_navigation
918 {
919     my $buttons = shift;
920     my $vertical = shift;
921     my $spacing = 1;
922     my $result = "<table class=\"nav_table\">\n";
923
924     $result .= "<tr>" unless $vertical;
925     my $beginofline = 1;
926     foreach my $button (@$buttons)
927     {
928         $result .= qq{<tr valign="top" align="left">\n} if $vertical;
929         # Allow (left|right|center)-aligned-cell and newline as buttons!
930         if ( $button =~ /^(.*)-aligned-cell-(.*)$/ )
931         {
932           $result .= qq{</td>} unless $beginofline;
933           $result .= qq{<td valign="middle" align="$1" colspan="$2">};
934           $beginofline = 0;
935         }
936         elsif ( $button eq 'newline' )
937         {
938           $result .= qq{</td>} unless $beginofline;
939           $result .= qq{</tr>};
940           $result .= qq{<tr>};
941           $beginofline = 1;
942
943         }
944         elsif (ref($button) eq 'CODE')
945         {
946             $result .= &$button($vertical);
947         }
948         elsif (ref($button) eq 'SCALAR')
949         {
950             $result .= "$$button" if defined($$button);
951         }
952         elsif (ref($button) eq 'ARRAY')
953         {
954             my $text = $button->[1];
955             my $button_href = $button->[0];
956             # verify that $button_href is simple text and text is a reference
957             if (defined($button_href) and !ref($button_href) 
958                and defined($text) and (ref($text) eq 'SCALAR') and defined($$text))
959             {             # use given text
960                 if ($Texi2HTML::HREF{$button_href})
961                 {
962                   my $anchor_attributes = '';
963                   if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button_href})) and ($BUTTONS_ACCESSKEY{$button_href} ne ''))
964                   {
965                       $anchor_attributes = "accesskey=\"$BUTTONS_ACCESSKEY{$button_href}\"";
966                   }
967                   if ($USE_REL_REV and (defined($BUTTONS_REL{$button_href})) and ($BUTTONS_REL{$button_href} ne ''))
968                   {
969                       $anchor_attributes .= " rel=\"$BUTTONS_REL{$button_href}\"";
970                   }
971                   $result .=  "" .
972                         &$anchor('',
973                                     $Texi2HTML::HREF{$button_href},
974                                     get_navigation_text($$text),
975                                     $anchor_attributes
976                                    );
977                 }
978                 else
979                 {
980                   $result .=  get_navigation_text($$text);
981                 }
982             }
983         }
984         elsif ($button eq ' ')
985         {                       # handle space button
986             $result .= 
987                 ($ICONS && $ACTIVE_ICONS{' '}) ?
988                     &$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{' '}) :
989                         $NAVIGATION_TEXT{' '};
990             #next;
991         }
992         elsif ($Texi2HTML::HREF{$button})
993         {                       # button is active
994             my $btitle = $BUTTONS_GOTO{$button} ?
995                 'title="' . $BUTTONS_GOTO{$button} . '"' : '';
996             if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button})) and ($BUTTONS_ACCESSKEY{$button} ne ''))
997             {
998                 $btitle .= " accesskey=\"$BUTTONS_ACCESSKEY{$button}\"";
999             }
1000             if ($USE_REL_REV and (defined($BUTTONS_REL{$button})) and ($BUTTONS_REL{$button} ne ''))
1001             {
1002                 $btitle .= " rel=\"$BUTTONS_REL{$button}\"";
1003             }
1004             if ($ICONS && $ACTIVE_ICONS{$button})
1005             {                   # use icon
1006                 $result .= '' .
1007                     &$anchor('',
1008                         $Texi2HTML::HREF{$button},
1009                         &$button_icon_img($BUTTONS_NAME{$button},
1010                                    $ACTIVE_ICONS{$button},
1011                                    $Texi2HTML::SIMPLE_TEXT{$button}),
1012                         $btitle
1013                       );
1014             }
1015             else
1016             {                   # use text
1017                 $result .= 
1018                     '[' .
1019                         &$anchor('',
1020                                     $Texi2HTML::HREF{$button},
1021                                     get_navigation_text($button),
1022                                     $btitle
1023                                    ) .
1024                                        ']';
1025             }
1026         }
1027         else
1028         {                       # button is passive
1029             $result .= 
1030                 $ICONS && $PASSIVE_ICONS{$button} ?
1031                     &$button_icon_img($BUTTONS_NAME{$button},
1032                                           $PASSIVE_ICONS{$button},
1033                                           $Texi2HTML::SIMPLE_TEXT{$button}) :
1034
1035                                               "[" . get_navigation_text($button) . "]";
1036         }
1037         $result .= "</td>\n" if $vertical;
1038         $result .= "</tr>\n" if $vertical;
1039     }
1040     $result .= "</td>" unless $beginofline;
1041     $result .= "</tr>" unless $vertical;
1042     $result .= "</table>\n";
1043     return $result;
1044 }
1045
1046
1047 @Texi2HTML::Config::SECTION_BUTTONS =
1048     ('left-aligned-cell-1', 'FastBack',
1049      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1050      'right-aligned-cell-1', 'FastForward',
1051      'newline',
1052      'left-aligned-cell-2', 'Back',
1053      'center-aligned-cell-1', 'Up',
1054      'right-aligned-cell-2', 'Forward'
1055     );
1056
1057 # buttons for misc stuff
1058 @Texi2HTML::Config::MISC_BUTTONS = ('center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About');
1059
1060 # buttons for chapter file footers
1061 # (and headers but only if SECTION_NAVIGATION is false)
1062 @Texi2HTML::Config::CHAPTER_BUTTONS =
1063     ('left-aligned-cell-1', 'FastBack',
1064      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1065      'right-aligned-cell-1', 'FastForward',
1066     );
1067
1068 # buttons for section file footers
1069 @Texi2HTML::Config::SECTION_FOOTER_BUTTONS =
1070     ('left-aligned-cell-1', 'FastBack',
1071      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1072      'right-aligned-cell-1', 'FastForward',
1073      'newline',
1074      'left-aligned-cell-2', 'Back',
1075      'center-aligned-cell-1', 'Up',
1076      'right-aligned-cell-2', 'Forward'
1077     );
1078
1079 @Texi2HTML::Config::NODE_FOOTER_BUTTONS =
1080     ('left-aligned-cell-1', 'FastBack',
1081      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1082      'right-aligned-cell-1', 'FastForward',
1083      'newline',
1084      'left-aligned-cell-2', 'Back',
1085      'center-aligned-cell-1', 'Up',
1086      'right-aligned-cell-2', 'Forward'
1087     );
1088
1089
1090
1091
1092
1093 #############################################################################
1094 ###  FOOTNOTE FORMATTING
1095 #############################################################################
1096
1097 # Format footnotes in a nicer way: Instead of printing the number in a separate
1098 # (nr) heading line, use the standard way of prepending <sup>nr</sup> immediately
1099 # before the fn text.
1100
1101
1102 # The following code is copied from texi2html's examples/makeinfo.init and
1103 # should be updated when texi2html makes some changes there!
1104
1105 my $makekinfo_like_footnote_absolute_number = 0;
1106
1107 sub makeinfo_like_foot_line_and_ref($$$$$$$$)
1108 {
1109     my $foot_num = shift;
1110     my $relative_num = shift;
1111     my $footid = shift;
1112     my $docid = shift;
1113     my $from_file = shift;
1114     my $footnote_file = shift;
1115     my $lines = shift;
1116     my $state = shift;
1117
1118     $makekinfo_like_footnote_absolute_number++;
1119
1120     # this is a bit obscure, this allows to add an anchor only if formatted
1121     # as part of the document.
1122     $docid = '' if ($state->{'outside_document'} or $state->{'multiple_pass'});
1123
1124     if ($from_file eq $footnote_file)
1125     {
1126         $from_file = $footnote_file = '';
1127     }
1128
1129     my $foot_anchor = "<sup>" . &$anchor($docid, "$footnote_file#$footid", $relative_num) . "</sup>";
1130     $foot_anchor = &$anchor($docid, "$footnote_file#$footid", "($relative_num)") if ($state->{'preformatted'});
1131
1132 #    unshift @$lines, "<li>";
1133 #    push @$lines, "</li>\n";
1134     return ($lines, $foot_anchor);
1135 }
1136
1137 sub makeinfo_like_foot_lines($)
1138 {
1139     my $lines = shift;
1140     unshift @$lines, "<hr>\n<h4>$Texi2HTML::I18n::WORDS->{'Footnotes_Title'}</h4>\n";
1141 #<ol type=\"1\">\n";
1142 #    push @$lines, "</ol>";
1143     return $lines;
1144 }
1145
1146 my %makekinfo_like_paragraph_in_footnote_nr;
1147
1148 sub makeinfo_like_paragraph ($$$$$$$$$$$$$)
1149 {
1150     my $text = shift;
1151     my $align = shift;
1152     my $indent = shift;
1153     my $paragraph_command = shift;
1154     my $paragraph_command_formatted = shift;
1155     my $paragraph_number = shift;
1156     my $format = shift;
1157     my $item_nr = shift;
1158     my $enumerate_style = shift;
1159     my $number = shift;
1160     my $command_stack_at_end = shift;
1161     my $command_stack_at_begin = shift;
1162     my $state = shift;
1163 #print STDERR "format: $format\n" if (defined($format));
1164 #print STDERR "paragraph @$command_stack_at_end; @$command_stack_at_begin\n";
1165     $paragraph_command_formatted = '' if (!defined($paragraph_command_formatted) or
1166           exists($special_list_commands{$format}->{$paragraph_command}));
1167     return '' if ($text =~ /^\s*$/);
1168     foreach my $style(t2h_collect_styles($command_stack_at_begin))
1169     {
1170        $text = t2h_begin_style($style, $text);
1171     }
1172     foreach my $style(t2h_collect_styles($command_stack_at_end))
1173     {
1174        $text = t2h_end_style($style, $text);
1175     }
1176     if (defined($paragraph_number) and defined($$paragraph_number))
1177     {
1178          $$paragraph_number++;
1179          return $text  if (($format eq 'itemize' or $format eq 'enumerate') and
1180             ($$paragraph_number == 1));
1181     }
1182     my $open = '<p';
1183     if ($align)
1184     {
1185         $open .= " align=\"$paragraph_style{$align}\"";
1186     }
1187     my $footnote_text = '';
1188     if (defined($command_stack_at_begin->[0]) and $command_stack_at_begin->[0] eq 'footnote')
1189     {
1190         my $state = $Texi2HTML::THISDOC{'state'};
1191         $makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number}++;
1192         if ($makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number} <= 1)
1193         {
1194            $open.=' class="footnote"';
1195            my $document_file = $state->{'footnote_document_file'};
1196            if ($document_file eq $state->{'footnote_footnote_file'})
1197            {
1198                $document_file = '';
1199            }
1200            my $docid = $state->{'footnote_place_id'};
1201            my $doc_state = $state->{'footnote_document_state'};
1202            $docid = '' if ($doc_state->{'outside_document'} or $doc_state->{'multiple_pass'});
1203            my $foot_label = &$anchor($state->{'footnote_footnote_id'},
1204                  $document_file . "#$state->{'footnote_place_id'}",
1205                  "$state->{'footnote_number_in_page'}");
1206            $footnote_text = "<small>[${foot_label}]</small> ";
1207         }
1208     }
1209     return $open.'>'.$footnote_text.$text.'</p>';
1210 }
1211
1212
1213 #############################################################################
1214 ###  OTHER SETTINGS
1215 #############################################################################
1216
1217 # For split pages, use index.html as start page!
1218 if ($Texi2HTML::Config::SPLIT eq 'section') {
1219   $Texi2HTML::Config::TOP_FILE = 'index.html';
1220 }
1221
1222
1223 return 1;