]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/lilypond-texi2html.init
Merge remote branch 'origin' into release/unstable
[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: GPLv3+
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 ###    implemented 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 ### -) In tables, don't wrap <p> around the contents. Implemented in
59 ###           makeinfo_like_paragraph
60 ###
61 ###
62 ### Useful helper functions:
63 ### -) texinfo_file_name($node_name): returns a texinfo-compatible file name
64 ###    for the given string $node_name (whitespace trimmed/replaced by -,
65 ###    non-standard chars replaced by _xxxx (ascii char code) and forced to
66 ###    start with a letter by prepending t_g if necessary)
67
68 package main;
69 $original_normalise_node = \&normalise_node;
70
71 sub t2h_default_normalise_node($)
72 {
73     my $text = shift;
74     $original_normalise_node->($text);
75 }
76
77 *normalise_node = sub($)
78 {
79     my $text = shift;
80     return &$Texi2HTML::Config::normalise_node($text);
81 };
82
83 package Texi2HTML::Config;
84 ##$normalise_node = \&t2h_default_normalise_node;
85 $normalise_node = \&lilypond_normalise_node;
86
87
88 use utf8;
89 use Encode qw(decode);
90
91 #############################################################################
92 ### TRANSLATIONS
93 #############################################################################
94
95 my $LY_LANGUAGES = {};
96 $LY_LANGUAGES->{'cs'} = {
97     'Back to Documentation Index' => '',
98     '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '',
99 };
100
101 $LY_LANGUAGES->{'de'} = {
102     'Back to Documentation Index' => 'Zur Dokumentationsübersicht',
103     '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '',
104 };
105
106 $LY_LANGUAGES->{'es'} = {
107     'Back to Documentation Index' => 'Volver al índice de la documentación',
108     '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '<p>Agradecemos a ${webdev_link} el alojamiento de ${lily_site}.',
109 };
110
111 $LY_LANGUAGES->{'fr'} = {
112     'Back to Documentation Index' => 'Retour à l\'accueil de la documentation',
113     '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '<p>Remerciements à ${webdev_link} pour l\'hébergement de ${lily_site}.',
114 };
115
116
117 $LY_LANGUAGES->{'hu'} = {
118     'Back to Documentation Index' => 'Vissza a dokumentációk jegyzékéhez',
119     '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => 'Köszönet a ${webdev_link} részére a ${lily_site} tárhelyért.',
120 };
121
122 $LY_LANGUAGES->{'it'} = {
123     'Back to Documentation Index' => 'Torna all\'indice della documentazione',
124     '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '',
125 };
126
127 $LY_LANGUAGES->{'ja'} = {
128     'Back to Documentation Index' => 'ドキュメント インデックスに戻る',
129     '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '${lily_site} をホスティングしてくれている ${webdev_link} に感謝します。',
130 };
131
132
133 $LY_LANGUAGES->{'nl'} = {
134     'Back to Documentation Index' => 'Terug naar de Documentatieindex',
135     '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '<p>Met dank aan ${webdev_link} voor het hosten van ${lily_site}.',
136 };
137
138 $LY_LANGUAGES->{'zh'} = {
139     'Back to Documentation Index' => '回到文档索引',
140     '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '非常感谢 ${webdev_link} 提供 ${lily_site} 的主机空间。',
141 };
142
143 # FIXME: request the translations below then send them to texi2html/texinfo devs
144
145 $LANGUAGES->{'it'} = {
146                        '  The buttons in the navigation panels have the following meaning:' => '  I bottoni nei pannelli di navigazione hanno il seguente significato:',
147                        '  where the @strong{ Example } assumes that the current position is at @strong{ Subsubsection One-Two-Three } of a document of the following structure:' => '  dove @strong{ Esempio } assume che l\'attuale posizione è alla @strong{ Sottosottosezione Uno-Due-Tre } di un documento che ha la seguente struttura:',
148                        ' Up ' => ' Su ',
149                        '(outside of any element)' => '(fuori da qualsiasi elemento)',
150                        '(outside of any node)' => '(fuori da qualsiasi nodo)',
151                        '@b{{quotation_arg}:} ' => '@b{{quotation_arg}:} ',
152                        '@cite{{book}}' => '@cite{{book}}',
153                        '@{No value for `{value}\'@}' => '@{Nessun valore per `{value}\'@}',
154                        'About' => 'Informazioni',
155                        'About (help)' => 'Informazioni (aiuto)',
156                        'About This Document' => 'Informazioni su questo documento',
157                        'April' => 'Aprile',
158                        'August' => 'Agosto',
159                        'Back' => 'Indietro',
160                        'Back section in previous file' => '',
161                        'Beginning of this chapter or previous chapter' => 'Inizio di questo capitolo o capitolo precedente',
162                        'Button' => 'Bottone',
163                        'Contents' => 'Contenuti',
164                        'Cover (top) of document' => 'Copertina (inizio) del documento',
165                        'Current' => 'Attuale',
166                        'Current Position' => 'Posizione Attuale',
167                        'Current section' => 'Sezione attuale',
168                        'December' => 'Dicembre',
169                        'FastBack' => 'Indietro veloce',
170                        'FastForward' => 'Avanti veloce',
171                        'February' => 'Febbraio',
172                        'First' => 'Primo',
173                        'First section in reading order' => 'Prima sezione in ordine di lettura',
174                        'Following' => 'Seguente',
175                        'Following node' => 'Nodo seguente',
176                        'Footnotes' => 'Note a piè di pagina',
177                        'Forward' => 'Avanti',
178                        'Forward section in next file' => 'Sezione successiva nel prossimo file',
179                        'From 1.2.3 go to' => 'Da 1.2.3 vai a',
180                        'Go to' => 'Vai a',
181                        'Index' => 'Indice',
182                        'Index Entry' => 'Voce dell\'indice',
183                        'January' => 'Gennaio',
184                        'July' => 'Luglio',
185                        'Jump to' => 'Salta a',
186                        'June' => 'Giugno',
187                        'Last' => 'Ultimo',
188                        'Last section in reading order' => 'Ultima sezione in ordine di lettura',
189                        'March' => 'Marzo',
190                        'May' => 'Maggio',
191                        'Menu:' => 'Menu',
192                        'Name' => 'Nome',
193                        'Next' => 'Successivo',
194                        'Next chapter' => 'Capitolo successivo',
195                        'Next file' => 'File successivo',
196                        'Next node' => 'Nodo successivo',
197                        'Next section in reading order' => 'Sezione successiva in ordine di lettura',
198                        'Next section on same level' => 'Sezione successiva sullo stesso livello',
199                        'NextFile' => 'File successivo',
200                        'Node following in node reading order' => 'Nodo seguente in ordine di lettura',
201                        'Node up' => 'Nodo superiore',
202                        'NodeNext' => 'Nodo successivo',
203                        'NodePrev' => 'Nodo precedente',
204                        'NodeUp' => 'Nodo superiore',
205                        'November' => 'Novembre',
206                        'October' => 'Ottobre',
207                        'Overview' => 'Panoramica',
208                        'Prev' => 'Prec.',
209                        'PrevFile' => 'File precedente',
210                        'Previous' => 'Precedente',
211                        'Previous file' => 'File precedente',
212                        'Previous node' => 'Nodo precedente',
213                        'Previous section in reading order' => 'Sezione precedente in ordine di lettura',
214                        'Previous section on same level' => 'Sezione precedente sullo stesso livello',
215                        'Section' => 'Sezione',
216                        'Section One' => 'Sezione uno',
217                        'See ' => 'Vedi',
218                        'See @cite{{book}}' => 'Vedi @cite{{book}}',
219                        'See section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'Vedi la sezione `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}',
220                        'See section `{section}\' in @cite{{book}}' => 'Vedi la sezione `{section}\' in @cite{{book}}',
221                        'See section {reference_name}' => 'Vedi la sezione {reference_name}',
222                        'See {node_file_href}' => 'Vedi {node_file_href}',
223                        'See {node_file_href} @cite{{book}}' => 'Vedi {node_file_href} @cite{{book}}',
224                        'See {node_file_href} section `{section}\' in @cite{{book}}' => 'Vedi {node_file_href} nella sezione `{section}\' in @cite{{book}}',
225                        'See {reference_name}' => 'Vedi {reference_name}',
226                        'See {ref}' => 'Vedi {ref}',
227                        'See {title_ref}' => 'Vedi {title_ref}',
228                        'September' => 'Settembre',
229                        'Short Table of Contents' => 'Indice breve',
230                        'Short table of contents' => 'Indice breve',
231                        'Subsection One-Four' => 'Sottosezione Uno-Quattro',
232                        'Subsection One-One' => 'Sottosezione Uno-Uno',
233                        'Subsection One-Three' => 'Sottosezione Uno-Tre',
234                        'Subsection One-Two' => 'Sottosezione Uno-Due',
235                        'Subsubsection One-Two-Four' => 'Sottosottosezione Uno-Due-Quattro',
236                        'Subsubsection One-Two-One' => 'Sottosottosezione Uno-Due-Uno',
237                        'Subsubsection One-Two-Three' => 'Sottosottosezione Uno-Due-Tre',
238                        'Subsubsection One-Two-Two' => 'Sottosottosezione Uno-Due-Due',
239                        'T2H_today' => '%s, %d %d',
240                        'Table of Contents' => 'Indice',
241                        'Table of contents' => 'Indice',
242                        'The node you are looking for is at {href}.' => 'Il nodo che stai cercando è {href}',
243                        'This' => 'Questo',
244                        'This document was generated on @i{{date}} using @uref{{program_homepage}, @i{{program}}}.' => 'Questo documento è stato generato il @i{{date}} con @uref{{program_homepage}, @i{{program}}}.',
245                        'This document was generated using @uref{{program_homepage}, @emph{{program}}}.' => 'Questo documento è stato generato con @uref{{program_homepage}, @emph{{program}}}.',
246                        'Top' => 'Inizio',
247                        'Untitled Document' => 'Documento senza titolo',
248                        'Up' => 'Su',
249                        'Up node' => 'Nodo superiore',
250                        'Up section' => 'Sezione superiore',
251                        'current' => 'attuale',
252                        'on @emph{{date}}' => 'il @emph{{date}}',
253                        'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'sezione `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}',
254                        'section `{section}\' in @cite{{book}}' => 'sezione `{section}\' in @cite{{book}}',
255                        'see ' => 'vedi ',
256                        'see @cite{{book}}' => 'vedi @cite{{book}}',
257                        'see section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'vedi la sezione `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}',
258                        'see section `{section}\' in @cite{{book}}' => 'vedi la sezione `{section}\' in @cite{{book}}',
259                        'see section {reference_name}' => 'vedi la sezione {reference_name}',
260                        'see {node_file_href}' => 'vedi {node_file_href}',
261                        'see {node_file_href} @cite{{book}}' => 'vedi {node_file_href} @cite{{book}}',
262                        'see {node_file_href} section `{section}\' in @cite{{book}}' => 'vedi {node_file_href} nella sezione `{section}\' in @cite{{book}}',
263                        'see {reference_name}' => 'vedi {reference_name}',
264                        'see {ref}' => 'vedi {ref}',
265                        'see {title_ref}' => 'vedi {title_ref}',
266                        '{acronym_like} ({explanation})' => '{acronym_like} ({explanation})',
267                        '{name} of {class}' => '{name} di {class}',
268                        '{name} on {class}' => '{name} in {class}',
269                        '{node_file_href}' => '{node_file_href}',
270                        '{node_file_href} @cite{{book}}' => '{node_file_href} @cite{{book}}',
271                        '{node_file_href} section `{section}\' in @cite{{book}}' => '{node_file_href} nella sezione `{section}\' in @cite{{book}}',
272                        '{reference_name}' => '{reference_name}',
273                        '{ref}' => '{ref}',
274                        '{style} {number}' => '{style} {number}',
275                        '{style}: {caption_first_line}' => '{style}: {caption_first_line}',
276                        '{style}: {shortcaption_first_line}' => '{style}: {shortcaption_first_line}',
277                        '{title_ref}' => '{title_ref}'
278                      };
279
280 $LANGUAGES->{'hu'} = {
281                        '  The buttons in the navigation panels have the following meaning:' => '  A navigációs panelen levő gombok jelentése a következő:',
282                        '  where the @strong{ Example } assumes that the current position is at @strong{ Subsubsection One-Two-Three } of a document of the following structure:' => '  @strong{ Példánkban } az aktuális pozíció az @strong{ 1.2.3 alalszakasz } egy olyan dokumentumban, melynek szerkezete a következő:',
283                        ' Up ' => 'Fel',
284                        '(outside of any element)' => '(bármelyik elemen kívül)',
285                        '(outside of any node)' => '(bármelyik csomóponton kívül)',
286                        '@b{{quotation_arg}:} ' => '@b{{quotation_arg}:} ',
287                        '@cite{{book}}' => '@cite{{book}}',
288                        '@{No value for `{value}\'@}' => '@{Nincs értéke ennek: `{value}\'@}',
289                        'About' => 'Súgó',
290                        'About (help)' => 'Segítség a navigációhoz',
291                        'About This Document' => 'A navigációs panel használata',
292                        'April' => 'április',
293                        'August' => 'augusztus',
294                        'Back' => 'Vissza',
295                        'Back section in previous file' => 'Előző fájl hátsó szakasza',
296                        'Beginning of this chapter or previous chapter' => 'Fejezet eleje vagy előző fejezet',
297                        'Button' => 'Gomb',
298                        'Contents' => 'Tartalom',
299                        'Cover (top) of document' => 'Dokumentum címoldala',
300                        'Current' => 'Aktuális',
301                        'Current Position' => 'Aktuális pozíció',
302                        'Current section' => 'Aktuális szakasz',
303                        'December' => 'december',
304                        'FastBack' => 'Visszaugrás',
305                        'FastForward' => 'Előreugrás',
306                        'February' => 'február',
307                        'First' => 'Első',
308                        'First section in reading order' => 'Első szakasz az olvasási sorrendben',
309                        'Following' => 'Következő',
310                        'Following node' => 'Következő csomópont',
311                        'Footnotes' => 'Lábjegyzet',
312                        'Forward' => 'Előre',
313                        'Forward section in next file' => 'Következő fájl elülső szakasza',
314                        'From 1.2.3 go to' => '1.2.3-ból ide jutunk',
315                        'Go to' => 'Cél',
316                        'Index' => 'Tárgymutató',
317                        'Index Entry' => 'Tárgymutató-bejegyzés',
318                        'January' => 'január',
319                        'July' => 'július',
320                        'Jump to' => 'Ugorj ide',
321                        'June' => 'június',
322                        'Last' => 'Utolsó',
323                        'Last section in reading order' => 'Utolsó szakasz az olvasási sorrendben',
324                        'March' => 'március',
325                        'May' => 'május',
326                        'Menu:' => 'Menü:',
327                        'Name' => 'Név',
328                        'Next' => 'Következő',
329                        'Next chapter' => 'Következő fejezet',
330                        'Next file' => 'Következő fájl',
331                        'Next node' => 'Következő csomópont',
332                        'Next section in reading order' => 'Következő szakasz az olvasási sorrendben',
333                        'Next section on same level' => 'Következő szakasz ugyanazon a szinten',
334                        'NextFile' => 'KövetkezőFájl',
335                        'Node following in node reading order' => 'Következő csomópont az olvasási sorrendben',
336                        'Node up' => 'Szülő csomópont',
337                        'NodeNext' => 'KövetkezőCsomópont',
338                        'NodePrev' => 'ElőzőCsomópont',
339                        'NodeUp' => 'SzülőCsomópont',
340                        'November' => 'november',
341                        'October' => 'október',
342                        'Overview' => 'Áttekintés',
343                        'Prev' => 'Előző',
344                        'PrevFile' => 'ElőzőFájl',
345                        'Previous' => 'Előző',
346                        'Previous file' => 'Előző fájl',
347                        'Previous node' => 'Előző csomópont',
348                        'Previous section in reading order' => 'Előző szakasz az olvasási sorrendben',
349                        'Previous section on same level' => 'Előző szakasz ugyanazon a szinten',
350                        'Section' => 'Szakasz',
351                        'Section One' => 'szakasz',
352                        'See ' => 'Ld. ',
353                        'See @cite{{book}}' => 'Ld. @cite{{book}}',
354                        'See section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'Ld. ezt a szakaszt: `@asis{}`{section_name}\'@asis{}\' itt: @cite{{book}}',
355                        'See section `{section}\' in @cite{{book}}' => 'Ld. ezt a szakaszt: `{section}\' itt: @cite{{book}}',
356                        'See section {reference_name}' => 'Ld. ezt a szakaszt: {reference_name}',
357                        'See {node_file_href}' => 'Ld. {node_file_href}',
358                        'See {node_file_href} @cite{{book}}' => 'See {node_file_href} @cite{{book}}',
359                        'See {node_file_href} section `{section}\' in @cite{{book}}' => 'Ld. {node_file_href} ezt a szakaszt: `{section}\' itt: @cite{{book}}',
360                        'See {reference_name}' => 'Ld. {reference_name}',
361                        'See {ref}' => 'Ld. {ref}',
362                        'See {title_ref}' => 'Ld. {title_ref}',
363                        'September' => 'szeptember',
364                        'Short Table of Contents' => 'Rövid tartalomjegyzék',
365                        'Short table of contents' => 'Rövid tartalomjegyzék',
366                        'Subsection One-Four' => 'alszakasz',
367                        'Subsection One-One' => 'alszakasz',
368                        'Subsection One-Three' => 'alszakasz',
369                        'Subsection One-Two' => 'alszakasz',
370                        'Subsubsection One-Two-Four' => 'alalszakasz',
371                        'Subsubsection One-Two-One' => 'alalszakasz',
372                        'Subsubsection One-Two-Three' => 'alalszakasz',
373                        'Subsubsection One-Two-Two' => 'alalszakasz',
374                        'T2H_today' => '%s, %d %d',
375                        'Table of Contents' => 'Tartalomjegyzék',
376                        'Table of contents' => 'Tartalomjegyzék',
377                        'The node you are looking for is at {href}.' => 'A keresett csomópont itt található: {href}.',
378                        'This' => 'Ez a(z)',
379                        'This document was generated on @i{{date}} using @uref{{program_homepage}, @i{{program}}}.' => 'Ezt a dokumentumot @i{{date}} napon generálta a(z) @uref{{program_homepage}, @i{{program}}}.',
380                        'This document was generated using @uref{{program_homepage}, @emph{{program}}}.' => 'Ezt a dokumentumot a(z) @uref{{program_homepage}, @emph{{program}}} generálta.',
381                        'Top' => 'Címoldal',
382                        'Untitled Document' => 'Névtelen dokumentum',
383                        'Up' => 'Fel',
384                        'Up node' => 'Szülő csomópont',
385                        'Up section' => 'Szülő szakasz',
386                        'current' => 'aktuális',
387                        'on @emph{{date}}' => 'ekkor: @emph{{date}}',
388                        'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'szakasz: `@asis{}`{section_name}\'@asis{}\' itt: @cite{{book}}',
389                        'section `{section}\' in @cite{{book}}' => 'szakasz: `{section}\' itt: @cite{{book}}',
390                        'see ' => 'ld. ',
391                        'see @cite{{book}}' => 'ld. @cite{{book}}',
392                        'see section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'ld. ezt a szakaszt: `@asis{}`{section_name}\'@asis{}\' itt: @cite{{book}}',
393                        'see section `{section}\' in @cite{{book}}' => 'ld. ezt a szakaszt: `{section}\' itt: @cite{{book}}',
394                        'see section {reference_name}' => 'ld. ezt a szakaszt: {reference_name}',
395                        'see {node_file_href}' => 'ld. {node_file_href}',
396                        'see {node_file_href} @cite{{book}}' => 'ld. {node_file_href} @cite{{book}}',
397                        'see {node_file_href} section `{section}\' in @cite{{book}}' => 'ld. {node_file_href} ezt a szakaszt: `{section}\' itt: @cite{{book}}',
398                        'see {reference_name}' => 'ld. {reference_name}',
399                        'see {ref}' => 'ld. {ref}',
400                        'see {title_ref}' => 'ld. {title_ref}',
401                        '{acronym_like} ({explanation})' => '{acronym_like} ({explanation})',
402                        '{name} of {class}' => '{name} típusa: {class}',
403                        '{name} on {class}' => '{name} ezen: {class}',
404                        '{node_file_href}' => '{node_file_href}',
405                        '{node_file_href} @cite{{book}}' => '{node_file_href} @cite{{book}}',
406                        '{node_file_href} section `{section}\' in @cite{{book}}' => '{node_file_href} szakasz: `{section}\' itt: @cite{{book}}',
407                        '{reference_name}' => '{reference_name}',
408                        '{ref}' => '{ref}',
409                        '{style} {number}' => '{style} {number}',
410                        '{style}: {caption_first_line}' => '{style}: {caption_first_line}',
411                        '{style}: {shortcaption_first_line}' => '{style}: {shortcaption_first_line}',
412                        '{title_ref}' => '{title_ref}'
413                      };
414
415 $LANGUAGES->{'ja'} = {
416                        '  The buttons in the navigation panels have the following meaning:' => '  ナビゲーション パネルの中にあるボタンには以下のような意味があります:',
417                        '  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 } であると仮定しています:',
418                        ' Up ' => ' 上へ ',
419                        '(outside of any element)' => '(outside of any element)',
420                        '(outside of any node)' => '(outside of any node)',
421                        '@b{{quotation_arg}:} ' => '@b{{quotation_arg}:} ',
422                        '@cite{{book}}' => '@cite{{book}}',
423                        '@{No value for `{value}\'@}' => '@{No value for `{value}\'@}',
424                        'About' => '情報',
425                        'About (help)' => '情報 (ヘルプ)',
426                        'About This Document' => 'このドキュメントについて',
427                        'April' => '4 月',
428                        'August' => '8 月',
429                        'Back' => '戻る',
430                        'Back section in previous file' => '前のファイルのセクションに戻る',
431                        'Beginning of this chapter or previous chapter' => 'この章あるいは前の章の先頭',
432                        'Button' => 'ボタン',
433                        'Contents' => '目次',
434                        'Cover (top) of document' => 'ドキュメントの表紙 (先頭)',
435                        'Current' => '現在の',
436                        'Current Position' => '現在の位置',
437                        'Current section' => '現在のセクション',
438                        'December' => '12 月',
439                        'FastBack' => '大きく戻る',
440                        'FastForward' => '大きく進む',
441                        'February' => '2 月',
442                        'First' => '最初',
443                        'First section in reading order' => '最初のセクション',
444                        'Following' => '次',
445                        'Following node' => '次のノード',
446                        'Footnotes' => '脚注',
447                        'Forward' => '進む',
448                        'Forward section in next file' => '次のファイルのセクションに進む',
449                        'From 1.2.3 go to' => '1.2.3 からの行き先',
450                        'Go to' => '行き先',
451                        'Index' => 'インデックス',
452                        'Index Entry' => 'インデックス エントリ',
453                        'January' => '1 月',
454                        'July' => '7 月',
455                        'Jump to' => '行き先',
456                        'June' => '6月',
457                        'Last' => '最後',
458                        'Last section in reading order' => '最後のセクション',
459                        'March' => '3 月',
460                        'May' => '5 月',
461                        'Menu:' => 'メニュー',
462                        'Name' => '名前',
463                        'Next' => '次',
464                        'Next chapter' => '次の章',
465                        'Next file' => '次のファイル',
466                        'Next node' => '次のノード',
467                        'Next section in reading order' => '次のセクション',
468                        'Next section on same level' => '次のセクション',
469                        'NextFile' => '次のファイル',
470                        'Node following in node reading order' => '次のノード',
471                        'Node up' => '上のノード',
472                        'NodeNext' => '次のノード',
473                        'NodePrev' => '前のノード',
474                        'NodeUp' => '上のノード',
475                        'November' => '11 月',
476                        'October' => '10 月',
477                        'Overview' => '概要',
478                        'Prev' => '前',
479                        'PrevFile' => '前のファイル',
480                        'Previous' => '前の',
481                        'Previous file' => '前のファイル',
482                        'Previous node' => '前のノード',
483                        'Previous section in reading order' => '前のセクション',
484                        'Previous section on same level' => '前のセクション',
485                        'Section' => 'セクション',
486                        'Section One' => 'セクション 1',
487                        'See ' => '参照',
488                        'See @cite{{book}}' => '@cite{{book}} を参照してください',
489                        'See section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '@cite{{book}} のセクション `@asis{}`{section_name}\'@asis{}\' を参照してください',
490                        'See section `{section}\' in @cite{{book}}' => '@cite{{book}} のセクション `{section}\' を参照してください',
491                        'See section {reference_name}' => 'セクション {reference_name} を参照してください',
492                        'See {node_file_href}' => '{node_file_href} を参照してください',
493                        'See {node_file_href} @cite{{book}}' => '@cite{{book}} の {node_file_href} を参照してください',
494                        'See {node_file_href} section `{section}\' in @cite{{book}}' => '@cite{{book}} の {node_file_href} セクション `{section}\' を参照してください',
495                        'See {reference_name}' => '{reference_name} を参照してください',
496                        'See {ref}' => '{ref} を参照してください',
497                        'See {title_ref}' => '{title_ref} を参照してください',
498                        'September' => '9 月',
499                        'Short Table of Contents' => '簡単な目次',
500                        'Short table of contents' => '簡単な目次',
501                        'Subsection One-Four' => 'サブセクション 1-4',
502                        'Subsection One-One' => 'サブセクション 1-1',
503                        'Subsection One-Three' => 'サブセクション 1-3',
504                        'Subsection One-Two' => 'サブセクション 1-2',
505                        'Subsubsection One-Two-Four' => 'サブサブセクション 1-2-4',
506                        'Subsubsection One-Two-One' => 'サブサブセクション 1-2-1',
507                        'Subsubsection One-Two-Three' => 'サブサブセクション 1-2-3',
508                        'Subsubsection One-Two-Two' => 'サブサブセクション 1-2-2',
509                        'T2H_today' => '%s, %d %d',
510                        'Table of Contents' => '目次',
511                        'Table of contents' => '目次',
512                        'The node you are looking for is at {href}.' => 'あなたが探しているノードは {href} にあります。',
513                        'This' => 'この',
514                        'This document was generated on @i{{date}} using @uref{{program_homepage}, @i{{program}}}.' => 'このドキュメントは @i{{date}} に、@uref{{program_homepage}, @i{{program}}} を用いて生成されました。',
515                        'This document was generated using @uref{{program_homepage}, @emph{{program}}}.' => 'このドキュメントは @uref{{program_homepage}, @emph{{program}}} を用いて生成されました。',
516                        'Top' => 'トップ',
517                        'Untitled Document' => '無題のドキュメント',
518                        'Up' => '上',
519                        'Up node' => '上のノード',
520                        'Up section' => '上のセクション',
521                        'current' => '現在の',
522                        'on @emph{{date}}' => '@emph{{date}} に',
523                        'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '@cite{{book}} のセクション `@asis{}`{section_name}\'@asis{}\'',
524                        'section `{section}\' in @cite{{book}}' => '@cite{{book}} のセクション `{section}\'',
525                        'see ' => '参照',
526                        'see @cite{{book}}' => '@cite{{book}} を参照してください',
527                        'see section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '@cite{{book}} のセクション `@asis{}`{section_name}\'@asis{}\' を参照してください',
528                        'see section `{section}\' in @cite{{book}}' => '@cite{{book}} のセクション `{section}\' を参照してください',
529                        'see section {reference_name}' => 'セクション {reference_name} を参照してください',
530                        'see {node_file_href}' => '{node_file_href} を参照してください',
531                        'see {node_file_href} @cite{{book}}' => '{node_file_href} @cite{{book}} を参照してください',
532                        'see {node_file_href} section `{section}\' in @cite{{book}}' => '@cite{{book}} の {node_file_href} section `{section}\' を参照してください',
533                        'see {reference_name}' => '{reference_name} を参照してください',
534                        'see {ref}' => '{ref} を参照してくださ',
535                        'see {title_ref}' => '{title_ref} を参照してくださ',
536                        '{acronym_like} ({explanation})' => '{acronym_like} ({explanation})',
537                        '{name} of {class}' => '{class} の {name}',
538                        '{name} on {class}' => '{class} の {name}',
539                        '{node_file_href}' => '{node_file_href}',
540                        '{node_file_href} @cite{{book}}' => '{node_file_href} @cite{{book}}',
541                        '{node_file_href} section `{section}\' in @cite{{book}}' => '@cite{{book}} の {node_file_href} セクション `{section}\'',
542                        '{reference_name}' => '{reference_name}',
543                        '{ref}' => '{ref}',
544                        '{style} {number}' => '{style} {number}',
545                        '{style}: {caption_first_line}' => '{style}: {caption_first_line}',
546                        '{style}: {shortcaption_first_line}' => '{style}: {shortcaption_first_line}',
547                        '{title_ref}' => '{title_ref}'
548                      };
549
550 $LANGUAGES->{'cs'} = {
551                        '  The buttons in the navigation panels have the following meaning:' => '',
552                        '  where the @strong{ Example } assumes that the current position is at @strong{ Subsubsection One-Two-Three } of a document of the following structure:' => '',
553                        ' Up ' => '',
554                        '(outside of any element)' => '',
555                        '(outside of any node)' => '',
556                        '@b{{quotation_arg}:} ' => '',
557                        '@cite{{book}}' => '',
558                        '@{No value for `{value}\'@}' => '',
559                        'About' => '',
560                        'About (help)' => '',
561                        'About This Document' => '',
562                        'April' => '',
563                        'August' => '',
564                        'Back' => '',
565                        'Back section in previous file' => '',
566                        'Beginning of this chapter or previous chapter' => '',
567                        'Button' => '',
568                        'Contents' => '',
569                        'Cover (top) of document' => '',
570                        'Current' => '',
571                        'Current Position' => '',
572                        'Current section' => '',
573                        'December' => '',
574                        'FastBack' => '',
575                        'FastForward' => '',
576                        'February' => '',
577                        'First' => '',
578                        'First section in reading order' => '',
579                        'Following' => '',
580                        'Following node' => '',
581                        'Footnotes' => '',
582                        'Forward' => '',
583                        'Forward section in next file' => '',
584                        'From 1.2.3 go to' => '',
585                        'Go to' => '',
586                        'Index' => '',
587                        'Index Entry' => '',
588                        'January' => '',
589                        'July' => '',
590                        'Jump to' => '',
591                        'June' => '',
592                        'Last' => '',
593                        'Last section in reading order' => '',
594                        'March' => '',
595                        'May' => '',
596                        'Menu:' => '',
597                        'Name' => '',
598                        'Next' => '',
599                        'Next chapter' => '',
600                        'Next file' => '',
601                        'Next node' => '',
602                        'Next section in reading order' => '',
603                        'Next section on same level' => '',
604                        'NextFile' => '',
605                        'Node following in node reading order' => '',
606                        'Node up' => '',
607                        'NodeNext' => '',
608                        'NodePrev' => '',
609                        'NodeUp' => '',
610                        'November' => '',
611                        'October' => '',
612                        'Overview' => '',
613                        'Prev' => '',
614                        'PrevFile' => '',
615                        'Previous' => '',
616                        'Previous file' => '',
617                        'Previous node' => '',
618                        'Previous section in reading order' => '',
619                        'Previous section on same level' => '',
620                        'Section' => '',
621                        'Section One' => '',
622                        'See ' => '',
623                        'See @cite{{book}}' => '',
624                        'See section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '',
625                        'See section `{section}\' in @cite{{book}}' => '',
626                        'See section {reference_name}' => '',
627                        'See {node_file_href}' => '',
628                        'See {node_file_href} @cite{{book}}' => '',
629                        'See {node_file_href} section `{section}\' in @cite{{book}}' => '',
630                        'See {reference_name}' => '',
631                        'See {ref}' => '',
632                        'See {title_ref}' => '',
633                        'September' => '',
634                        'Short Table of Contents' => '',
635                        'Short table of contents' => '',
636                        'Subsection One-Four' => '',
637                        'Subsection One-One' => '',
638                        'Subsection One-Three' => '',
639                        'Subsection One-Two' => '',
640                        'Subsubsection One-Two-Four' => '',
641                        'Subsubsection One-Two-One' => '',
642                        'Subsubsection One-Two-Three' => '',
643                        'Subsubsection One-Two-Two' => '',
644                        'T2H_today' => '',
645                        'Table of Contents' => '',
646                        'Table of contents' => '',
647                        'The node you are looking for is at {href}.' => '',
648                        'This' => '',
649                        'This document was generated on @i{{date}} using @uref{{program_homepage}, @i{{program}}}.' => '',
650                        'This document was generated using @uref{{program_homepage}, @emph{{program}}}.' => '',
651                        'Top' => '',
652                        'Untitled Document' => '',
653                        'Up' => '',
654                        'Up node' => '',
655                        'Up section' => '',
656                        'current' => '',
657                        'on @emph{{date}}' => '',
658                        'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '',
659                        'section `{section}\' in @cite{{book}}' => '',
660                        'see ' => '',
661                        'see @cite{{book}}' => '',
662                        'see section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '',
663                        'see section `{section}\' in @cite{{book}}' => '',
664                        'see section {reference_name}' => '',
665                        'see {node_file_href}' => '',
666                        'see {node_file_href} @cite{{book}}' => '',
667                        'see {node_file_href} section `{section}\' in @cite{{book}}' => '',
668                        'see {reference_name}' => '',
669                        'see {ref}' => '',
670                        'see {title_ref}' => '',
671                        '{acronym_like} ({explanation})' => '',
672                        '{name} of {class}' => '',
673                        '{name} on {class}' => '',
674                        '{node_file_href}' => '',
675                        '{node_file_href} @cite{{book}}' => '',
676                        '{node_file_href} section `{section}\' in @cite{{book}}' => '',
677                        '{reference_name}' => '',
678                        '{ref}' => '',
679                        '{style} {number}' => '',
680                        '{style}: {caption_first_line}' => '',
681                        '{style}: {shortcaption_first_line}' => '',
682                        '{title_ref}' => '{title_ref}'
683                      };
684
685 $LANGUAGES->{'zh'} = {
686                        '  The buttons in the navigation panels have the following meaning:' => '  在导航面板上按钮有以下含意:',
687                        '  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 }:',
688                        ' Up ' => ' 上 ',
689                        '(outside of any element)' => '(任何元素外面)',
690                        '(outside of any node)' => '(任何节点外面)',
691                        '@b{{quotation_arg}:} ' => '@b{{quotation_arg}:} ',
692                        '@cite{{book}}' => '@cite{{book}}',
693                        '@{No value for `{value}\'@}' => '@{没有值 `{value}\'@}',
694                        'About' => '关于',
695                        'About (help)' => '关于 (帮助)',
696                        'About This Document' => '关于本文档',
697                        'April' => '4 月',
698                        'August' => '8 月',
699                        'Back' => '返回',
700                        'Back section in previous file' => '返回到前一个文件',
701                        'Beginning of this chapter or previous chapter' => '本章开头或前一章',
702                        'Button' => '按钮',
703                        'Contents' => '目录',
704                        'Cover (top) of document' => '文档的封面(首页)',
705                        'Current' => '当前',
706                        'Current Position' => '当前的位置',
707                        'Current section' => '当前的段',
708                        'December' => '12 月',
709                        'FastBack' => '快速返回',
710                        'FastForward' => '快速向前',
711                        'February' => '2 月',
712                        'First' => '第一个',
713                        'First section in reading order' => '看的第一段',
714                        'Following' => '紧接着的',
715                        'Following node' => '紧接着的节点',
716                        'Footnotes' => '脚注',
717                        'Forward' => '向前',
718                        'Forward section in next file' => '向前到下一个文件的段',
719                        'From 1.2.3 go to' => '从1.2.3 到',
720                        'Go to' => '到',
721                        'Index' => '索引',
722                        'Index Entry' => '索引条目',
723                        'January' => '1 月',
724                        'July' => '7 月',
725                        'Jump to' => '跳转到',
726                        'June' => '6 月',
727                        'Last' => '最后',
728                        'Last section in reading order' => '看的最后一段',
729                        'March' => '3 月',
730                        'May' => '5 月',
731                        'Menu:' => '菜单',
732                        'Name' => '名字',
733                        'Next' => '下一个',
734                        'Next chapter' => '下一章',
735                        'Next file' => '下一个文件',
736                        'Next node' => '下一个节点',
737                        'Next section in reading order' => '看的下一段',
738                        'Next section on same level' => '同级的下一段',
739                        'NextFile' => '下一个文件',
740                        'Node following in node reading order' => '看的下一个节点',
741                        'Node up' => '向上一个节点',
742                        'NodeNext' => '下一个节点',
743                        'NodePrev' => '前一个节点',
744                        'NodeUp' => '向上一个节点',
745                        'November' => '11 月',
746                        'October' => '10 月',
747                        'Overview' => '综述',
748                        'Prev' => '前一个',
749                        'PrevFile' => '前一个文件',
750                        'Previous' => '前一个',
751                        'Previous file' => '前一个文件',
752                        'Previous node' => '前一个节点',
753                        'Previous section in reading order' => '看的前一段',
754                        'Previous section on same level' => '同级的前一段',
755                        'Section' => '段',
756                        'Section One' => '段 1',
757                        'See ' => '见',
758                        'See @cite{{book}}' => '见 @cite{{book}}',
759                        'See section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '',
760                        'See section `{section}\' in @cite{{book}}' => '',
761                        'See section {reference_name}' => '见段 {reference_name}',
762                        'See {node_file_href}' => '见 {node_file_href}',
763                        'See {node_file_href} @cite{{book}}' => '见 {node_file_href} @cite{{book}}',
764                        'See {node_file_href} section `{section}\' in @cite{{book}}' => '见在@cite{{book}} 中的 {node_file_href} 段 `{section}\' ',
765                        'See {reference_name}' => '见 {reference_name}',
766                        'See {ref}' => '见 {ref}',
767                        'See {title_ref}' => '见 {title_ref}',
768                        'September' => '9 月',
769                        'Short Table of Contents' => '短目录',
770                        'Short table of contents' => '短目录',
771                        'Subsection One-Four' => '分段 1-4',
772                        'Subsection One-One' => '分段 1-1',
773                        'Subsection One-Three' => '分段 1-3',
774                        'Subsection One-Two' => '分段 1-2',
775                        'Subsubsection One-Two-Four' => '小分段 1-2-4',
776                        'Subsubsection One-Two-One' => '小分段 1-2-1',
777                        'Subsubsection One-Two-Three' => '小分段 1-2-3',
778                        'Subsubsection One-Two-Two' => '小分段 1-2-2',
779                        'T2H_today' => '',
780                        'Table of Contents' => '目录',
781                        'Table of contents' => '目录',
782                        'The node you are looking for is at {href}.' => '你查找的节点在{href}。',
783                        'This' => '这个',
784                        'This document was generated on @i{{date}} using @uref{{program_homepage}, @i{{program}}}.' => '本文档在 @i{{date}} 上用 @uref{{program_homepage}, @i{{program}}} 生成的。',
785                        'This document was generated using @uref{{program_homepage}, @emph{{program}}}.' => '本文档用 @uref{{program_homepage}, @emph{{program}}} 生成的。',
786                        'Top' => '首页',
787                        'Untitled Document' => '没有标题的文档',
788                        'Up' => '上',
789                        'Up node' => '上一节点',
790                        'Up section' => '上一段',
791                        'current' => '目前',
792                        'on @emph{{date}}' => '@emph{{date}} 上',
793                        'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '',
794                        'section `{section}\' in @cite{{book}}' => '',
795                        'see ' => '见',
796                        'see @cite{{book}}' => '见 @cite{{book}}',
797                        'see section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '见在@cite{{book}}里的段`@asis{}`{section_name}\'@asis{}\'',
798                        'see section `{section}\' in @cite{{book}}' => '见在@cite{{book}}里的段`{section}\'',
799                        'see section {reference_name}' => '见段 {reference_name}',
800                        'see {node_file_href}' => '见 {node_file_href}',
801                        'see {node_file_href} @cite{{book}}' => '见 {node_file_href} @cite{{book}}',
802                        'see {node_file_href} section `{section}\' in @cite{{book}}' => '见在@cite{{book}}里的{node_file_href} 段`{section}\'',
803                        'see {reference_name}' => '见 {reference_name}',
804                        'see {ref}' => '见 {ref}',
805                        'see {title_ref}' => '见 {title_ref}',
806                        '{acronym_like} ({explanation})' => '{acronym_like} ({explanation})',
807                        '{name} of {class}' => '{class} 的 {name}',
808                        '{name} on {class}' => '在{class} 上的 {name}',
809                        '{node_file_href}' => '',
810                        '{node_file_href} @cite{{book}}' => '',
811                        '{node_file_href} section `{section}\' in @cite{{book}}' => '{node_file_href} 段 `{section}\' 在 @cite{{book}}里',
812                        '{reference_name}' => '',
813                        '{ref}' => '{ref}',
814                        '{style} {number}' => '{style} {number}',
815                        '{style}: {caption_first_line}' => '{style}: {caption_first_line}',
816                        '{style}: {shortcaption_first_line}' => '{style}: {shortcaption_first_line}',
817                        '{title_ref}' => '{title_ref}'
818                      };
819
820
821 sub ly_get_string () {
822     my $lang = $Texi2HTML::THISDOC{current_lang};
823     my $string = shift;
824     if ($lang and $lang ne "en" and $LY_LANGUAGES->{$lang}->{$string}) {
825         return $LY_LANGUAGES->{$lang}->{$string};
826     } else {
827         return $string;
828     }
829 }
830
831
832 #############################################################################
833 ### FUNCTIONALITY FOR MAIN WEB PAGES
834 #############################################################################
835
836 our $web_manual;
837
838 #############################################################################
839 ###  SETTINGS FOR TEXI2HTML
840 #############################################################################
841
842 # Validation fix for texi2html<=1.82
843 $Texi2HTML::Config::DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
844
845 @Texi2HTML::Config::CSS_REFS = (
846     {FILENAME => "lilypond-manuals.css", TITLE => "Default style"}
847     );
848 @Texi2HTML::Config::ALT_CSS_REFS      = (
849     );
850
851 sub web_settings() {
852   print STDERR "Processing web site: [$Texi2HTML::THISDOC{current_lang}]\n";
853   $Texi2HTML::Config::BODYTEXT = "";
854   @Texi2HTML::Config::CSS_REFS      = (
855       {FILENAME => "lilypond-website.css", TITLE => "Default style"}
856       );
857   @Texi2HTML::Config::ALT_CSS_REFS      = (
858       );
859 }
860
861 $Texi2HTML::Config::USE_ACCESSKEY = 1;
862 $Texi2HTML::Config::USE_LINKS     = 1;
863 $Texi2HTML::Config::USE_REL_REV   = 1;
864 $Texi2HTML::Config::SPLIT_INDEX   = 0;
865 $Texi2HTML::Config::SEPARATED_FOOTNOTES = 0; # Print footnotes on same page, not separated
866
867 my $bigpage = 0;
868 my $have_index_entries = 0;
869 if ($Texi2HTML::Config::SPLIT eq 'section' or
870     $Texi2HTML::Config::SPLIT eq 'node') {
871   $Texi2HTML::Config::element_file_name    = \&lilypond_element_file_name;
872   $bigpage = 0;
873 } else {
874   $bigpage = 1;
875 }
876
877 $Texi2HTML::Config::anchor  = \&lilypond_anchor;
878 $Texi2HTML::Config::element_target_name  = \&lilypond_element_target_name;
879 $default_print_element_header = $Texi2HTML::Config::print_element_header;
880 $Texi2HTML::Config::print_element_header = \&lilypond_print_element_header;
881 $Texi2HTML::Config::print_page_foot      = \&print_lilypond_page_foot;
882 $Texi2HTML::Config::print_navigation     = \&lilypond_print_navigation;
883 $Texi2HTML::Config::external_ref         = \&lilypond_external_ref;
884 $default_external_href = $Texi2HTML::Config::external_href;
885 $Texi2HTML::Config::external_href        = \&lilypond_external_href;
886 $default_toc_body = $Texi2HTML::Config::toc_body;
887 $Texi2HTML::Config::toc_body             = \&lilypond_toc_body;
888 $Texi2HTML::Config::css_lines            = \&lilypond_css_lines;
889 $default_unknown = $Texi2HTML::Config::unknown;
890 $Texi2HTML::Config::unknown              = \&lilypond_unknown;
891 $default_print_page_head = $Texi2HTML::Config::print_page_head;
892 $Texi2HTML::Config::print_page_head      = \&lilypond_print_page_head;
893 # $Texi2HTML::Config::foot_line_and_ref    = \&lilypond_foot_line_and_ref;
894 $Texi2HTML::Config::foot_line_and_ref  = \&makeinfo_like_foot_line_and_ref;
895 $Texi2HTML::Config::foot_lines         = \&makeinfo_like_foot_lines;
896 $Texi2HTML::Config::paragraph          = \&makeinfo_like_paragraph;
897
898
899
900 # Examples should be formatted similar to quotes:
901 $Texi2HTML::Config::complex_format_map->{'example'} = {
902   'begin' => q{"<blockquote>"},
903   'end' => q{"</blockquote>\n"},
904   'style' => 'code',
905  };
906
907 %Texi2HTML::config::misc_pages_targets = (
908    'Overview' => 'Overview',
909    'Contents' => 'Contents',
910    'About' => 'About'
911 );
912
913
914 my @section_to_filename;
915
916
917
918
919 #############################################################################
920 ###  DEBUGGING
921 #############################################################################
922
923 use Data::Dumper;
924 $Data::Dumper::Maxdepth = 2;
925
926 sub print_element_info($)
927 {
928   my $element = shift;
929   print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
930   print "Element: $element\n";
931   print Dumper($element);
932 }
933
934
935
936
937
938 #############################################################################
939 ###  HELPER FUNCTIONS
940 #############################################################################
941
942 # only lc() the last portion of an href
943 sub lc_last($)
944 {
945   my $href = shift;
946   my @hrefsplit = split('/', $href);
947   # change the last portion (the filename), if it exists;
948   # if it is a plain filename with no path, change the string as a whole
949   if ($#hrefsplit > 0) {
950     @hrefsplit[$#hrefsplit] = lc( @hrefsplit[$#hrefsplit] );
951     $href = join("/", @hrefsplit);
952   } else {
953     $href = lc($href);
954   }
955   return $href;
956 }
957
958 # Convert a given node name to its proper file name (normalization as explained
959 # in the texinfo manual:
960 # http://www.gnu.org/software/texinfo/manual/texinfo/html_node/HTML-Xref-Node-Name-Expansion.html
961 sub texinfo_file_name($)
962 {
963   my $text = shift;
964   my $result = '';
965   # File name normalization by texinfo:
966   # 1/2: letters and numbers are left unchanged
967   # 3/4: multiple, leading and trailing whitespace is removed
968   $text = main::normalise_space($text);
969   # 5/6: all remaining spaces are converted to '-', all other 7- or 8-bit
970   #      chars are replaced by _xxxx (xxxx=ascii character code)
971   while ($text ne '') {
972     if ($text =~ s/^([A-Za-z0-9]+)//o) { # number or letter stay unchanged
973       $result .= $1;
974     } elsif ($text =~ s/^ //o) { # space -> '-'
975       $result .= '-';
976     } elsif ($text =~ s/^(.)//o) { # Otherwise use _xxxx (ascii char code)
977       my $ccode = ord($1);
978       if ( $ccode <= 0xFFFF ) {
979         $result .= sprintf("_%04x", $ccode);
980       } else {
981         $result .= sprintf("__%06x", $ccode);
982       }
983     }
984   }
985   # 7: if name does not begin with a letter, prepend 't_g' (so it starts with a letter)
986   if ($result !~ /^[a-zA-Z]/) {
987     $result = 't_g' . $result;
988   }
989   # DONE
990   return lc_last($result)
991 }
992
993 # Load a file containing a nodename<=>filename map (tab-sepatared, i.e.
994 # NODENAME\tFILENAME\tANCHOR
995 # Returns a ref to a hash "Node title" => ["FilenameWithoutExt", "Anchor"]
996 sub load_map_file ($)
997 {
998   my $mapfile = shift;
999   my $node_map = ();
1000
1001   # For some unknown reason, Perl on my system (5.10.0 on Fedora 12)
1002   # refuses to open map files of translated documents with
1003   # '<:encoding(utf8)', but decoding from UTF-8 line by line works. -jm
1004   if (open(XREFFILE,'<', $mapfile)) {
1005     my $line;
1006     # print STDERR "*** PRINTING MAP FILE LINES ***\n";
1007     while ( $line = decode ('UTF-8', <XREFFILE>) ) {
1008       # parse the tab-separated entries and insert them into the map:
1009       chomp($line);
1010       my @entries = split(/\t/, $line);
1011       if (scalar (@entries) == 3) {
1012         $node_map->{$entries[0]} = [$entries[1], $entries[2]];
1013         $, = " ";
1014         # print STDERR @entries;
1015         # print STDERR "\n";
1016       } else {
1017         print STDERR "Invalid entry in the node file $mapfile: $line\n";
1018       }
1019     }
1020     close (XREFFILE);
1021   } else {
1022     print STDERR "WARNING: Unable to load the map file $mapfile\n";
1023   }
1024   return $node_map;
1025 }
1026
1027
1028 # Split the given path into dir and basename (with .texi removed). Used mainly
1029 # to get the path/basename of the original texi input file
1030 sub split_texi_filename ($)
1031 {
1032   my $docu = shift;
1033   my ($docu_dir, $docu_name);
1034   if ($docu =~ /(.*\/)/) {
1035     chop($docu_dir = $1);
1036     $docu_name = $docu;
1037     $docu_name =~ s/.*\///;
1038   } else {
1039      $docu_dir = '.';
1040      $docu_name = $docu;
1041   }
1042   $docu_name =~ s/\.te?x(i|info)?$//;
1043   return ($docu_dir, $docu_name);
1044 }
1045
1046
1047
1048
1049
1050 #############################################################################
1051 ###  CSS HANDLING
1052 #############################################################################
1053
1054 # Include our standard CSS file, not hard-coded CSS code directly in the HTML!
1055 # For IE, conditionally include the lilypond-ie-fixes.css style sheet
1056 sub lilypond_css_lines ($$)
1057 {
1058   my $import_lines = shift;
1059   my $rule_lines = shift;
1060   return if (defined($Texi2HTML::THISDOC{'CSS_LINES'}));
1061   if (@$rule_lines or @$import_lines)
1062   {
1063     $Texi2HTML::THISDOC{'CSS_LINES'} = "<style type=\"text/css\">\n<!--\n";
1064     $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$import_lines) . "\n" if (@$import_lines);
1065     $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$rule_lines) . "\n" if (@$rule_lines);
1066     $Texi2HTML::THISDOC{'CSS_LINES'} .= "-->\n</style>\n";
1067   }
1068   foreach my $ref (@CSS_REFS)
1069   {
1070     $Texi2HTML::THISDOC{'CSS_LINES'} .=
1071         "<link rel=\"stylesheet\" type=\"text/css\" title=\"$ref->{TITLE}\" href=\"$ref->{FILENAME}\">\n";
1072   }
1073   foreach my $ref (@Texi2HTML::Config::ALT_CSS_REFS)
1074   {
1075     $Texi2HTML::THISDOC{'CSS_LINES'} .=
1076         "<link rel=\"alternate stylesheet\" type=\"text/css\" href=\"$ref->{FILENAME}\" title=\"$ref->{TITLE}\">\n";
1077   }
1078
1079   # The ie-fixes stylesheet is needed for the docs, but not the website.
1080   if (not ($web_manual)) {
1081     $Texi2HTML::THISDOC{'CSS_LINES'} .=
1082         "<!--[if lte IE 7]>\n<link href=\"lilypond-ie-fixes.css\" rel=\"stylesheet\" type=\"text/css\">\n<![endif]-->\n";
1083   }
1084
1085   if ($ENV{'AJAX_SEARCH'} == 1) {
1086     # Add the JavaScript file only if we have an index.
1087     # Unfortunately, init_out is called after css_lines, so as a workaround
1088     # here we have to check again for the existence of an index...
1089     my $ix = main::get_index ("cp");
1090     $have_index_entries = (scalar $ix > 0);
1091     my $reldir = "";
1092     $reldir = "../" unless $bigpage;
1093     if ($have_index_entries) {
1094       $Texi2HTML::THISDOC{'CSS_LINES'} .= "<script language=\"JavaScript\" src=\"${reldir}lily_search.js\"></script>\n";
1095     }
1096   }
1097 }
1098
1099
1100
1101
1102
1103 #############################################################################
1104 ###  SPLITTING BASED ON NUMBERED SECTIONS
1105 #############################################################################
1106
1107 my $lastfilename;
1108 my $docnr = 0;
1109 my $node_to_filename_map = ();
1110 $source_to_translationof_map = ();
1111
1112
1113 # This function makes sure that files are only generated for numbered sections,
1114 # but not for unnumbered ones. It is called after texi2html has done its own
1115 # splitting and simply returns the filename for the node given as first argument
1116 # Nodes with the same filename will be printed out to the same filename, so
1117 # this really all we need. Also, make sure that the file names for sections
1118 # are derived from the section title. We also might want to name the anchors
1119 # according to node titles, which works by simply overriding the id element of
1120 # the $element hash.
1121 # If an external nodename<=>filename/anchor map file is found (loaded in
1122 # the command handler, use the externally created values, otherwise use the
1123 # same logic here.
1124 sub lilypond_element_file_name($$$)
1125 {
1126   my $element = shift;
1127   my $type = shift;
1128   my $docu_name = shift;
1129   my $docu_ext = $Texi2HTML::Config::EXTENSION;
1130
1131   my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
1132   # the snippets page does not use nodes for the snippets, so in this case
1133   # we'll have to use the section name!
1134   if ($node_name eq '') {
1135     $node_name = main::remove_texi($element->{'texi'});
1136   }
1137
1138   # If we have an entry in the section<=>filename map, use that one, otherwise
1139   # generate the filename/anchor here. In the latter case, external manuals
1140   # will not be able to retrieve the file name for xrefs!!! Still, I already
1141   # had that code, so I'll leave it in in case something goes wrong with the
1142   # extract_texi_filenames.py script in the lilypond build process!
1143   if (exists ($node_to_filename_map->{$node_name})) {
1144     (my $filename, my $anchor) = @{$node_to_filename_map->{$node_name}};
1145     $filename .= ".$docu_ext" if (defined($docu_ext));
1146     # don't do lc_last here, otherwise the colors are messed up!
1147     $filename = lc($filename);
1148
1149     # unnumbered sections (except those at top-level!) always go to the same
1150     # file as the previous numbered section
1151     if (not ($web_manual) and not ($element->{number})
1152         and not ($lastfilename eq '') and ($element->{level} > 1)) {
1153       $filename = $lastfilename;
1154     }
1155     if (($filename eq $lastfilename)) {
1156       $$element{doc_nr} = $docnr;
1157     } else {
1158       $docnr += 1;
1159       $$element{doc_nr} = $docnr;
1160       $lastfilename = $filename;
1161     }
1162     #print STDERR "Output file name: $filename\n";
1163     $filename = lc_last($filename);
1164     return $filename;
1165
1166   } elsif ($type eq "top" or $type eq "toc" or $type eq "doc" or
1167            $type eq "stoc" or $type eq "foot" or $type eq "about") {
1168     return;
1169   } else {
1170     print STDERR "WARNING: Node '$node_name' was NOT found in the map\n"
1171         unless ($node_name eq '') or ($element->{'tag'} eq 'unnumberedsec')
1172                or ($node_name =~ /NOT REALLY USED/);
1173
1174     # Numbered sections will get a filename Node_title, unnumbered sections will use
1175     # the file name of the previous numbered section:
1176     if (($element->{number}) or ($lastfilename eq '') or ($element->{level} == 1)) {
1177       # normalize to the same file name as texinfo
1178       if ($element->{translationof}) {
1179         $node_name = main::remove_texi($element->{translationof});
1180       }
1181       my $filename = texinfo_file_name($node_name);
1182       $filename .= ".$docu_ext" if (defined($docu_ext));
1183       $filename = lc_last($filename);
1184       $docnr += 1;
1185       $$element{doc_nr} = $docnr;
1186       $lastfilename = $filename;
1187       print STDERR "File name: $filename\n";
1188       return $filename;
1189     } else {
1190       $$element{doc_nr} = $docnr;
1191       $filename = lc_last($filename);
1192       print STDERR "File name: $filename\n";
1193       return $filename;
1194     }
1195   }
1196
1197   return;
1198 }
1199
1200 sub lilypond_normalise_node($)
1201 {
1202     my $text = shift;
1203     my $norm = main::t2h_default_normalise_node($text);
1204     if (exists ($source_to_translationof_map->{$text})) {
1205         my $original = $source_to_translationof_map->{$text};
1206         $norm = main::t2h_default_normalise_node($original);
1207     }
1208
1209     return $norm;
1210 }
1211
1212 # This function produces an anchor.
1213 #
1214 # arguments:
1215 # $name           :   anchor name
1216 # $href           :   anchor href
1217 # text            :   text displayed
1218 # extra_attribs   :   added to anchor attributes list
1219 sub lilypond_anchor($;$$$)
1220 {
1221     my $name = shift;
1222     my $href = shift;
1223     my $text = shift;
1224     my $attributes = shift;
1225     $href = remove_unneeded_anchor($href);
1226     if (!defined($attributes) or ($attributes !~ /\S/))
1227     {
1228         $attributes = '';
1229     }
1230     else
1231     {
1232         $attributes = ' ' . $attributes;
1233     }
1234     $name = '' if (!defined($name) or ($name !~ /\S/));
1235     $href = '' if (!defined($href) or ($href !~ /\S/));
1236     $text = '' if (!defined($text));
1237     return $text if (($name eq '') and ($href eq ''));
1238     $name = "name=\"$name\"" if ($name ne '');
1239     $href = "href=\"$href\"" if ($href ne '');
1240     $href = ' ' . $href if (($name ne '') and ($href ne ''));
1241     return "<a ${name}${href}${attributes}>$text</a>";
1242 }
1243
1244
1245 sub lilypond_element_target_name($$$)
1246 {
1247   my $element = shift;
1248   my $target = shift;
1249   my $id = shift;
1250   # Target is based on node name (or sec name for secs without node attached)
1251   my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
1252   if ($node_name eq '') {
1253     $node_name = main::remove_texi($element->{'texi'});
1254   }
1255
1256   # If we have an entry in the section<=>filename map, use that one, otherwise
1257   # generate the anchor here.
1258   if (exists ($node_to_filename_map->{$node_name})) {
1259     (my $filename, $target) = @{$node_to_filename_map->{$node_name}};
1260   } else {
1261     my $anchor = $node_name;
1262     if ($element->{translationof}) {
1263       $anchor = main::remove_texi($element->{translationof});
1264     }
1265     # normalize to the same file name as texinfo
1266     $target = texinfo_file_name($anchor);
1267   }
1268   # TODO: Once texi2html correctly prints out the target and not the id for
1269   #       the sections, change this back to ($id, $target)
1270   # I don't understand this comment, so I'm reluctant to delete it -gp
1271   $target = lc_last($target);
1272   $id = lc($target);
1273 # $id =~ s/-1$//i; # remove any trailing "-1"
1274   return ($target, $id);
1275 }
1276
1277
1278 ## Load the map file for the corrently processed texi file. We do this
1279 #  using a command init handler, since texi2html does not have any
1280 #  other hooks that are called after THISDOC is filled but before phase 2
1281 #  of the texi2html conversion.
1282 sub lilypond_init_map ()
1283 {
1284     my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1285     my $map_filename = main::locate_include_file ("${docu_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
1286         || main::locate_include_file ("${docu_name}.xref-map");
1287     #print STDERR "Map filename is: $map_filename\nDocu name is $docu_name\n";
1288     if ($docu_name eq 'web') {
1289         $web_manual = 1;
1290         web_settings();
1291     }
1292     $node_to_filename_map = load_map_file ($map_filename);
1293 }
1294 push @Texi2HTML::Config::command_handler_init, \&lilypond_init_map;
1295
1296
1297
1298 #############################################################################
1299 ###  CLEANER LINK TITLE FOR EXTERNAL REFS
1300 #############################################################################
1301
1302 # The default formatting of external refs returns e.g.
1303 # "(lilypond-internals)Timing_translator", so we remove all (...) from the
1304 # file_and_node argument. Also, we want only a very simple format, so we don't
1305 # even call the default handler!
1306 sub lilypond_external_ref($$$$$$)
1307 {
1308   my $type = shift;
1309   my $section = shift;
1310   my $book = shift;
1311   my $file_node = shift;
1312   my $href = shift;
1313
1314   $href = lc_last($href);
1315
1316   my $cross_ref = shift;
1317
1318   my $displaytext = '';
1319
1320   # 1) if we have a cross ref name, that's the text to be displayed:
1321   # 2) For the top node, use the (printable) name of the manual, unless we
1322   #    have an explicit cross ref name
1323   # 3) In all other cases use the section name
1324   if ($cross_ref ne '') {
1325     $displaytext = $cross_ref;
1326   } elsif (($section eq '') or ($section eq 'Top')) {
1327     $displaytext = $book;
1328   } else {
1329     $displaytext = $section;
1330   }
1331
1332   $displaytext = &$anchor('', $href, $displaytext) if ($displaytext ne '');
1333   return &$I('%{node_file_href}', { 'node_file_href' => $displaytext });
1334 }
1335
1336
1337
1338
1339
1340 #############################################################################
1341 ###  HANDLING TRANSLATED SECTIONS: handle @translationof, secname<->filename
1342 ###                  map stored on disk, xrefs in other manuals load that map
1343 #############################################################################
1344
1345
1346 # Try to make use of @translationof to generate files according to the original
1347 # English section title...
1348 sub lilypond_unknown($$$$$)
1349 {
1350     my $macro = shift;
1351     my $line = shift;
1352     my $pass = shift;
1353     my $stack = shift;
1354     my $state = shift;
1355
1356     # the @translationof macro provides the original English section title,
1357     # which should be used for file/anchor naming, while the title will be
1358     # translated to each language
1359     # It is already used by extract_texi_filenames.py, so this should not be
1360     # necessary here at all. Still, I'll leave the code in just in case the
1361     # python script messed up ;-)
1362     if ($pass == 1 and $macro eq "translationof") {
1363       if (ref($state->{'element'}) eq 'HASH') {
1364           $state->{'element'}->{'translationof'} = main::normalise_space($line);
1365           my $source = main::normalise_space ($line);
1366           if (ref($state->{'node_ref'}) eq 'HASH') {
1367               my $translationof = $state->{'node_ref'}->{'texi'};
1368               our %source_to_translationof_map;
1369               $source_to_translationof_map->{$source} = $translationof;
1370           }
1371       }
1372       return ('', 1, undef, undef);
1373     } else {
1374       return &$default_unknown($macro, $line, $pass, $stack, $state);
1375     }
1376 }
1377
1378
1379 my %translated_books = ();
1380 # Construct a href to an external source of information.
1381 # node is the node with texinfo @-commands
1382 # node_id is the node transliterated and transformed as explained in the
1383 #         texinfo manual
1384 # node_xhtml_id is the node transformed such that it is unique and can
1385 #     be used to make an html cross ref as explained in the texinfo manual
1386 # file is the file in '(file)node'
1387 sub lilypond_external_href($$$)
1388 {
1389   my $node = shift;
1390   my $node_id = shift;
1391   my $node_xhtml_id = shift;
1392   my $file = shift;
1393
1394   # 1) Keep a hash of book->section_map
1395   # 2) if not file in keys hash => try to load the map (assign empty map if
1396   #    non-existent => will load only once!)
1397   # 3) if node in the section=>(file, anchor) map, replace node_id and
1398   #    node_xhtml_id by the map's values
1399   # 4) call the default_external_href with these values (or the old ones if not found)
1400
1401   if (($node_id ne '') and defined($file) and ($node_id ne 'Top')) {
1402     my $map_name = $file;
1403     $map_name =~ s/-big-page//;
1404
1405     # Load the map if we haven't done so already
1406     if (!exists($translated_books{$map_name})) {
1407       my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1408       my $map_filename = main::locate_include_file ("${map_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
1409           || main::locate_include_file ("${map_name}.xref-map");
1410       $translated_books{$map_name} = load_map_file ($map_filename);
1411     }
1412
1413     # look up translation. use these values instead of the old filename/anchor
1414     my $section_name_map = $translated_books{$map_name};
1415     my $node_text = main::remove_texi($node);
1416     if (defined($section_name_map->{$node_text})) {
1417       ($node_id, $node_xhtml_id) = @{$section_name_map->{$node_text}};
1418     } else {
1419       print STDERR "WARNING: Unable to find node '$node_text' in book $map_name.\n";
1420     }
1421   }
1422
1423   if (defined $file) {
1424     $href = &$default_external_href($node, $node_id, $node_xhtml_id, lc_last($file));
1425     $href = remove_unneeded_anchor($href);
1426
1427     # TODO: very yucky, but will be fixed in issue 1004
1428     if ($web_manual) {
1429       my $only_web = $ENV{ONLY_WEB};
1430       if ($only_web) {
1431         $href = "../../doc/v2.13/Documentation/web/".$href;
1432       }
1433     }
1434
1435     return $href;
1436   } else {
1437     $href = &$default_external_href($node, $node_id, $node_xhtml_id);
1438     $href = remove_unneeded_anchor($href);
1439     return $href;
1440   }
1441 }
1442
1443 sub remove_unneeded_anchor($)
1444 {
1445   my $href = shift;
1446   my @hrefsplit = split("/", $href);
1447   for ($i = 0; $i < @hrefsplit; $i++) {
1448     $item = @hrefsplit[$i];
1449     if ($item =~ /#/) {
1450       @split = split(".html#", $item);
1451       if (@split[0] eq @split[1]) {
1452         @hrefsplit[$i] = @split[0] . ".html";
1453       }
1454     }
1455   }
1456   $href = join("/", @hrefsplit);
1457   return $href
1458 }
1459
1460
1461
1462 #############################################################################
1463 ###  CUSTOM TOC FOR EACH PAGE (in a frame on the left)
1464 #############################################################################
1465
1466 my $page_toc_depth = 2;
1467 my @default_toc = [];
1468
1469 # Initialize the toc_depth to 1 if the command-line option -D=short_toc is given
1470 sub lilypond_init_toc_depth ()
1471 {
1472   if (exists($main::value{'short_toc'}) and not exists($main::value{'bigpage'})
1473       and not $web_manual) {
1474     $page_toc_depth = 1;
1475   }
1476 }
1477 # Set the TOC-depth (depending on a texinfo variable short_toc) in a
1478 # command-handler, so we have them available when creating the pages
1479 push @Texi2HTML::Config::command_handler_process, \&lilypond_init_toc_depth;
1480
1481
1482
1483 # recursively generate the TOC entries for the element and its children (which
1484 # are only shown up to maxlevel. All ancestors of the current element are also
1485 # shown with their immediate children, irrespective of their level.
1486 # Unnumbered entries are only printed out if they are at top-level or 2nd level
1487 # or their parent element is an ancestor of the currently viewed node.
1488 # The conditions to call this method to print the entry for a child node is:
1489 # -) the parent is an ancestor of the current page node
1490 # -) the parent is a numbered element at top-level toplevel (i.e. show numbered
1491 #    and unnumbered 2nd-level children of numbered nodes)
1492 # -) the child element is a numbered node below level maxlevel
1493 sub generate_ly_toc_entries($$$$$)
1494 {
1495   my $element = shift;
1496   my $element_path = shift;
1497   my $maxlevel = shift;
1498   if ($web_manual) {
1499     $maxlevel = 1;
1500   }
1501   my $child_count = shift;
1502   my $current_element = shift;
1503   # Skip undefined sections, plus all sections generated by index splitting
1504   return() if (not defined($element) or exists($element->{'index_page'}));
1505   my @result = ();
1506   my $level = $element->{'toc_level'};
1507   my $is_parent_of_current = $element->{'id'} && $element_path->{$element->{'id'}};
1508   my $ind = '  ' x $level;
1509   my $this_css_class = " class=\"";
1510   # color indices for the second navigation bar on the website
1511   if ($web_manual) {
1512       my %color_maps = (
1513           'introduction' => [2, 2, 2, 2, 3, 3, 4, 4],
1514           'download' => [2, 2, 2, 3, 3, 4],
1515           'manuals' => [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4],
1516           'community' => [1, 1, 1, 2, 2, 2, 3, 3],
1517           );
1518       my $addColor = "colorDefault";
1519       while (($top_section, $color_indices) = each %color_maps) {
1520           if (index ($element->{'sectionup'}->{'file'}, $top_section) >= 0) {
1521               $addColor = "color" . $color_indices->[$child_count];
1522           }
1523       }
1524       $this_css_class .= $addColor;
1525   }
1526   $this_css_class .= $is_parent_of_current ? ' toc_current"' : '"';
1527   my $entry = "$ind<li$this_css_class>" .
1528       &$anchor ($element->{'tocid'},
1529                 "$element->{'file'}#$element->{'target'}",
1530                 $element->{'text'});
1531
1532   push (@result, $entry);
1533   my $children = $element->{'section_childs'};
1534   if (defined($children) and (ref($children) eq "ARRAY")) {
1535     my $force_children = $is_parent_of_current or ($level == 1 and $element->{'number'});
1536     my @child_result = ();
1537     my $sub_child_count = 0;
1538     foreach my $c (@$children) {
1539       my $is_numbered_child = defined ($c->{'number'});
1540       my $below_maxlevel = $c->{'toc_level'} le $maxlevel;
1541       if ($force_children or ($is_numbered_child and $below_maxlevel)) {
1542         my @child_res =
1543             generate_ly_toc_entries($c, $element_path, $maxlevel, $sub_child_count, $current_element);
1544         push (@child_result, @child_res);
1545         $sub_child_count += 1;
1546       }
1547     }
1548     # if no child nodes were generated, e.g. for the index, where expanded pages
1549     # are ignored, don't generate a list at all...
1550     if (@child_result) {
1551       push (@result, "\n$ind<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
1552       if ($web_manual) {
1553         push (@result, "$ind<li class=\"colorDefault" .
1554               ($element->{'text'} eq $current_element->{'text'} ?
1555                ' toc_current">' : '">') .
1556               &$anchor ($element->{'tocid'},
1557                         "$element->{'file'}#$element->{'target'}",
1558                         $element->{'text'}) . "</li>\n");
1559       }
1560       push (@result, @child_result);
1561       push (@result, "$ind</ul>\n");
1562     }
1563   }
1564   push (@result, "$ind</li>\n");
1565   return @result;
1566 }
1567
1568
1569 # Print a customized TOC, containing only the first two levels plus the whole
1570 # path to the current page
1571 sub lilypond_generate_page_toc_body($)
1572 {
1573     my $element = shift;
1574     my $current_element = $element;
1575     my %parentelements;
1576     $parentelements{$element->{'id'}} = 1;
1577     # Find the path to the current element
1578     while ( defined($current_element->{'sectionup'}) and
1579            ($current_element->{'sectionup'} ne $current_element) )
1580     {
1581       $parentelements{$current_element->{'sectionup'}->{'id'}} = 1
1582               if ($current_element->{'sectionup'}->{'id'} ne '');
1583       $current_element = $current_element->{'sectionup'};
1584       if ($web_manual) {
1585         if (exists($main::value{'shallow_toc'})) {
1586           last;
1587         }
1588       }
1589     }
1590     return () if not defined($current_element);
1591     # Create the toc entries recursively
1592     my @toc_entries = "";
1593     if ($web_manual) {
1594         @toc_entries = "<ul$NO_BULLET_LIST_ATTRIBUTE>\n";
1595         # FIXME: add link to main page, really hackily.
1596         if ($element->{'sectionup'}) {
1597             # it's not the top element
1598             push (@toc_entries, "<li><a href=\"index.html\">Main</a></li>\n");
1599         } else {
1600             push (@toc_entries,
1601                   "<li class=\"toc_current\"><a href=\"index.html\">Main</a></li>\n");
1602         }
1603     } else {
1604         push (@toc_entries, "<div class=\"contents\">\n");
1605         push (@toc_entries, "<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
1606     }
1607     my $children = $current_element->{'section_childs'};
1608     foreach ( @$children ) {
1609       push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth, 0, $element));
1610     }
1611     # search box
1612     #  I'm assuming that we wouldn't keep the google search box? -gp
1613     if (!($ENV{AJAX_SEARCH} == 1)) {
1614       local $/=undef;
1615       my $name = "search-box";
1616       $lang = $Texi2HTML::THISDOC{current_lang};
1617       open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$lang/$name.ihtml" or
1618         open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$name.ihtml"  or
1619         die "no such file: $name.ihtml: $!";
1620       my $search_string = decode ('UTF-8', <FILE>);
1621       $search_string = "<li>\n" . $search_string . "</li>\n";
1622       push (@toc_entries, $search_string);
1623       close FILE;
1624     }
1625
1626     push (@toc_entries, "</ul>\n");
1627     if ($web_manual) {
1628         push (@toc_entries, "\n");
1629     } else {
1630         push (@toc_entries, "</div>\n");
1631     }
1632     return @toc_entries;
1633 }
1634
1635 sub lilypond_print_toc_div ($$)
1636 {
1637   my $fh = shift;
1638   my $tocref = shift;
1639   my @lines = @$tocref;
1640   # use default TOC if no custom lines have been generated
1641   @lines = @default_toc if (not @lines);
1642   if (@lines) {
1643
1644     print $fh "\n\n<div id=\"tocframe\">\n";
1645
1646     # Remove the leading "GNU LilyPond --- " from the manual title
1647     my $topname = $Texi2HTML::NAME{'Top'};
1648     $topname =~ s/^GNU LilyPond(:| &[mn]dash;) //;
1649
1650     # construct the top-level Docs index (relative path and including language!)
1651     my $lang = $Texi2HTML::THISDOC{current_lang};
1652     if ($lang and $lang ne "en") {
1653       $lang .= ".";
1654     } else {
1655       $lang = "";
1656     }
1657     my $reldir = $ENV{DEPTH};
1658     # strip one depth level for translations
1659     if ($lang and $lang ne "en" and substr ($reldir, 0, 3) eq '../') {
1660         $reldir = substr ($reldir, 3);
1661     }
1662     # add a / at the end if there isn't one.
1663     if (substr ($reldir, -1) ne '/') {
1664         $reldir .= '/';
1665     }
1666     my $uplink = $reldir."Documentation/web/manuals.${lang}html";
1667
1668     if (not $web_manual) {
1669       print $fh "<p class=\"toc_uplink\"><a href=\"$uplink\"
1670          title=\"Documentation Index\">&lt;&lt; " .
1671          &ly_get_string ('Back to Documentation Index') .
1672          "</a></p>\n";
1673
1674       # AJAX search box, written in JavaScript
1675       if ($ENV{'AJAX_SEARCH'} == 1) {
1676         if ($have_index_entries) {
1677           my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1678           print $fh '<script language="JavaScript">print_search_field ("' .
1679              $Texi2HTML::THISDOC{current_lang} . '", "' . 
1680              $docu_name . "\", " . $bigpage . ")</script>\n";
1681         }
1682       }
1683
1684       print $fh '<h4 class="toc_header"> ' . &$anchor('',
1685                                     $Texi2HTML::HREF{'Top'},
1686                                     $topname,
1687                                     'title="Start of the manual"'
1688                                    ) . "</h4>\n";
1689     }
1690
1691     foreach my $line (@lines) {
1692       print $fh $line;
1693     }
1694     print $fh "</div>\n\n";
1695   }
1696 }
1697
1698 # Create the custom TOC for this page (partially folded, current page is
1699 # highlighted) and store it in a global variable. The TOC is written out after
1700 # the html contents (but positioned correctly using CSS), so that browsers with
1701 # css turned off still show the contents first.
1702 our @this_page_toc = ();
1703 sub lilypond_print_element_header
1704 {
1705   my $first_in_page = shift;
1706   my $previous_is_top = shift;
1707   if ($first_in_page and not @this_page_toc) {
1708     if (defined($Texi2HTML::THIS_ELEMENT)) {
1709       # Create the TOC for this page
1710       @this_page_toc = lilypond_generate_page_toc_body($Texi2HTML::THIS_ELEMENT);
1711     }
1712   }
1713   return &$default_print_element_header( $first_in_page, $previous_is_top);
1714 }
1715
1716 # Generate the HTML output for the TOC
1717 sub lilypond_toc_body($)
1718 {
1719     my $elements_list = shift;
1720     # Generate a default TOC for pages without THIS_ELEMENT
1721     @default_toc = lilypond_generate_page_toc_body(@$elements_list[0]);
1722     return &$default_toc_body($elements_list);
1723 }
1724
1725 # Print out the TOC in a <div> at the beginning of the page
1726 sub lilypond_print_page_head($)
1727 {
1728     my $fh = shift;
1729     &$default_print_page_head($fh);
1730     print $fh "<div id=\"main\">\n";
1731 }
1732
1733 # Print out the TOC in a <div> at the end of th page, which will be formatted as a
1734 # sidebar mimicking a TOC frame
1735 sub print_lilypond_page_foot($)
1736 {
1737   my $fh = shift;
1738   my $program_string = &$program_string();
1739 #   print $fh "<p><font size='-1'>$program_string</font><br>$PRE_BODY_CLOSE</p>\n";
1740   print $fh "<!-- FOOTER -->\n\n";
1741   print $fh "<!-- end div#main here -->\n</div>\n\n";
1742   if ($web_manual) {
1743     # FIXME: This div and p#languages need to be in div#footer.
1744     #        Should we move this div to postprocess_html.py ?
1745     print $fh "<div id=\"verifier_texinfo\">\n";
1746     print $fh "<h3>Validation</h3>\n";
1747     # FIXME: inlined text substitution, move to ly_get_string as soon as another case is needed
1748     my $webdev_link = "<a href=\"http://www.webdev.nl/\">webdev.nl</a>";
1749     my $lily_site = "<code>lilypond.org</code>";
1750     my $hosting_thanks = &ly_get_string ('<p>Thanks to ${webdev_link} for hosting ${lily_site}.');
1751     # this does the variable substitution ("quoting" in Perlish) after the localization
1752     $hosting_thanks =~ s/(\$\{\w+\})/$1/eeg;
1753     print $fh $hosting_thanks . "\n";
1754     print $fh "<a href=\"http://validator.w3.org/check?uri=referer\">\n";
1755     print $fh "<img src=\"http://www.w3.org/Icons/valid-html401\"\n";
1756     print $fh "     alt=\"Valid HTML 4.01 Transitional\"\n";
1757     print $fh "     height=\"31\" width=\"88\"></a></p>\n";
1758     print $fh "</div>";
1759   }
1760
1761   # Print the TOC frame and reset the TOC:
1762   lilypond_print_toc_div ($fh, \@this_page_toc);
1763   @this_page_toc = ();
1764
1765   # Close the page:
1766   print $fh "</body>\n</html>\n";
1767 }
1768
1769
1770
1771
1772
1773 #############################################################################
1774 ###  NICER / MORE FLEXIBLE NAVIGATION PANELS
1775 #############################################################################
1776
1777 sub get_navigation_text
1778 {
1779   my $button = shift;
1780   my $text = $NAVIGATION_TEXT{$button};
1781   if ( ($button eq 'Back') or ($button eq 'FastBack') ) {
1782     $text = $text . $Texi2HTML::NODE{$button} . "&nbsp;";
1783   } elsif ( ($button eq 'Forward') or ($button eq 'FastForward') ) {
1784     $text = "&nbsp;" . $Texi2HTML::NODE{$button} . $text;
1785   } elsif ( $button eq 'Up' ) {
1786     $text = "&nbsp;".$text.":&nbsp;" . $Texi2HTML::NODE{$button} . "&nbsp;";
1787   }
1788   return $text;
1789 }
1790
1791
1792 # Don't automatically create left-aligned table cells for every link, but
1793 # instead create a <td> only on an appropriate '(left|right|center)-aligned-cell-n'
1794 # button text. It's alignment as well as the colspan will be taken from the
1795 # name of the button. Also, add 'newline' button text to create a new table
1796 # row. The texts of the buttons are generated by get_navigation_text and
1797 # will contain the name of the next/previous section/chapter.
1798 sub lilypond_print_navigation
1799 {
1800     my $buttons = shift;
1801     my $vertical = shift;
1802     my $spacing = 1;
1803     my $result = "<table class=\"nav_table\">\n";
1804
1805     $result .= "<tr>" unless $vertical;
1806     my $beginofline = 1;
1807     foreach my $button (@$buttons)
1808     {
1809         $result .= qq{<tr valign="top" align="left">\n} if $vertical;
1810         # Allow (left|right|center)-aligned-cell and newline as buttons!
1811         if ( $button =~ /^(.*)-aligned-cell-(.*)$/ )
1812         {
1813           $result .= qq{</td>} unless $beginofline;
1814           $result .= qq{<td valign="middle" align="$1" colspan="$2">};
1815           $beginofline = 0;
1816         }
1817         elsif ( $button eq 'newline' )
1818         {
1819           $result .= qq{</td>} unless $beginofline;
1820           $result .= qq{</tr>};
1821           $result .= qq{<tr>};
1822           $beginofline = 1;
1823
1824         }
1825         elsif (ref($button) eq 'CODE')
1826         {
1827             $result .= &$button($vertical);
1828         }
1829         elsif (ref($button) eq 'SCALAR')
1830         {
1831             $result .= "$$button" if defined($$button);
1832         }
1833         elsif (ref($button) eq 'ARRAY')
1834         {
1835             my $text = $button->[1];
1836             my $button_href = $button->[0];
1837             # verify that $button_href is simple text and text is a reference
1838             if (defined($button_href) and !ref($button_href)
1839                and defined($text) and (ref($text) eq 'SCALAR') and defined($$text))
1840             {             # use given text
1841                 if ($Texi2HTML::HREF{$button_href})
1842                 {
1843                   my $anchor_attributes = '';
1844                   if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button_href})) and
1845                       ($BUTTONS_ACCESSKEY{$button_href} ne ''))
1846                   {
1847                       $anchor_attributes = "accesskey=\"$BUTTONS_ACCESSKEY{$button_href}\"";
1848                   }
1849                   if ($USE_REL_REV and (defined($BUTTONS_REL{$button_href})) and
1850                       ($BUTTONS_REL{$button_href} ne ''))
1851                   {
1852                       $anchor_attributes .= " rel=\"$BUTTONS_REL{$button_href}\"";
1853                   }
1854                   $result .=  "" .
1855                         &$anchor('',
1856                                     $Texi2HTML::HREF{$button_href},
1857                                     get_navigation_text($$text),
1858                                     $anchor_attributes
1859                                    );
1860                 }
1861                 else
1862                 {
1863                   $result .=  get_navigation_text($$text);
1864                 }
1865             }
1866         }
1867         elsif ($button eq ' ')
1868         {                       # handle space button
1869             $result .=
1870                 ($ICONS && $ACTIVE_ICONS{' '}) ?
1871                     &$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{' '}) :
1872                         $NAVIGATION_TEXT{' '};
1873             #next;
1874         }
1875         elsif ($Texi2HTML::HREF{$button})
1876         {                       # button is active
1877             my $btitle = $BUTTONS_GOTO{$button} ?
1878                 'title="' . $BUTTONS_GOTO{$button} . '"' : '';
1879             if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button})) and
1880                 ($BUTTONS_ACCESSKEY{$button} ne ''))
1881             {
1882                 $btitle .= " accesskey=\"$BUTTONS_ACCESSKEY{$button}\"";
1883             }
1884             if ($USE_REL_REV and (defined($BUTTONS_REL{$button})) and
1885                 ($BUTTONS_REL{$button} ne ''))
1886             {
1887                 $btitle .= " rel=\"$BUTTONS_REL{$button}\"";
1888             }
1889             if ($ICONS && $ACTIVE_ICONS{$button})
1890             {                   # use icon
1891                 $result .= '' .
1892                     &$anchor('',
1893                         $Texi2HTML::HREF{$button},
1894                         &$button_icon_img($BUTTONS_NAME{$button},
1895                                    $ACTIVE_ICONS{$button},
1896                                    $Texi2HTML::SIMPLE_TEXT{$button}),
1897                         $btitle
1898                       );
1899             }
1900             else
1901             {                   # use text
1902                 $result .=
1903                     '[' .
1904                         &$anchor('',
1905                                     $Texi2HTML::HREF{$button},
1906                                     get_navigation_text($button),
1907                                     $btitle
1908                                    ) .
1909                                        ']';
1910             }
1911         }
1912         else
1913         {                       # button is passive
1914             $result .=
1915                 $ICONS && $PASSIVE_ICONS{$button} ?
1916                     &$button_icon_img($BUTTONS_NAME{$button},
1917                                           $PASSIVE_ICONS{$button},
1918                                           $Texi2HTML::SIMPLE_TEXT{$button}) :
1919
1920                                               "[" . get_navigation_text($button) . "]";
1921         }
1922         $result .= "</td>\n" if $vertical;
1923         $result .= "</tr>\n" if $vertical;
1924     }
1925     $result .= "</td>" unless $beginofline;
1926     $result .= "</tr>" unless $vertical;
1927     $result .= "</table>\n";
1928     if ($web_manual) {
1929       return "\n";
1930     } else {
1931       return $result;
1932     }
1933 }
1934
1935
1936 @Texi2HTML::Config::SECTION_BUTTONS =
1937     ('left-aligned-cell-1', 'FastBack',
1938      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1939      'right-aligned-cell-1', 'FastForward',
1940      'newline',
1941      'left-aligned-cell-2', 'Back',
1942      'center-aligned-cell-1', 'Up',
1943      'right-aligned-cell-2', 'Forward'
1944     );
1945
1946 # buttons for misc stuff
1947 @Texi2HTML::Config::MISC_BUTTONS = ('center-aligned-cell-3',
1948                                     'Top', 'Contents', 'Index', 'About');
1949
1950 # buttons for chapter file footers
1951 # (and headers but only if SECTION_NAVIGATION is false)
1952 @Texi2HTML::Config::CHAPTER_BUTTONS =
1953     ('left-aligned-cell-1', 'FastBack',
1954      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1955      'right-aligned-cell-1', 'FastForward',
1956     );
1957
1958 # buttons for section file footers
1959 @Texi2HTML::Config::SECTION_FOOTER_BUTTONS =
1960     ('left-aligned-cell-1', 'FastBack',
1961      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1962      'right-aligned-cell-1', 'FastForward',
1963      'newline',
1964      'left-aligned-cell-2', 'Back',
1965      'center-aligned-cell-1', 'Up',
1966      'right-aligned-cell-2', 'Forward'
1967     );
1968
1969 @Texi2HTML::Config::NODE_FOOTER_BUTTONS =
1970     ('left-aligned-cell-1', 'FastBack',
1971      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1972      'right-aligned-cell-1', 'FastForward',
1973      'newline',
1974      'left-aligned-cell-2', 'Back',
1975      'center-aligned-cell-1', 'Up',
1976      'right-aligned-cell-2', 'Forward'
1977     );
1978
1979
1980
1981
1982
1983 #############################################################################
1984 ###  FOOTNOTE FORMATTING
1985 #############################################################################
1986
1987 # Format footnotes in a nicer way: Instead of printing the number in a separate
1988 # (nr) heading line, use the standard way of prepending <sup>nr</sup> immediately
1989 # before the fn text.
1990
1991
1992 # The following code is copied from texi2html's examples/makeinfo.init and
1993 # should be updated when texi2html makes some changes there!
1994
1995 my $makekinfo_like_footnote_absolute_number = 0;
1996
1997 sub makeinfo_like_foot_line_and_ref($$$$$$$$)
1998 {
1999     my $foot_num = shift;
2000     my $relative_num = shift;
2001     my $footid = shift;
2002     my $docid = shift;
2003     my $from_file = shift;
2004     my $footnote_file = shift;
2005     my $lines = shift;
2006     my $state = shift;
2007
2008     $makekinfo_like_footnote_absolute_number++;
2009
2010     # this is a bit obscure, this allows to add an anchor only if formatted
2011     # as part of the document.
2012     $docid = '' if ($state->{'outside_document'} or $state->{'multiple_pass'});
2013
2014     if ($from_file eq $footnote_file)
2015     {
2016         $from_file = $footnote_file = '';
2017     }
2018
2019     my $foot_anchor = "<sup>" .
2020         &$anchor($docid, "$footnote_file#$footid", $relative_num) . "</sup>";
2021     $foot_anchor = &$anchor($docid,
2022                             "$footnote_file#$footid",
2023                             "($relative_num)") if ($state->{'preformatted'});
2024
2025 #    unshift @$lines, "<li>";
2026 #    push @$lines, "</li>\n";
2027     return ($lines, $foot_anchor);
2028 }
2029
2030 sub makeinfo_like_foot_lines($)
2031 {
2032     my $lines = shift;
2033     unshift @$lines, "<hr>\n<h4>$Texi2HTML::I18n::WORDS->{'Footnotes_Title'}</h4>\n";
2034 #<ol type=\"1\">\n";
2035 #    push @$lines, "</ol>";
2036     return $lines;
2037 }
2038
2039 my %makekinfo_like_paragraph_in_footnote_nr;
2040
2041 sub makeinfo_like_paragraph ($$$$$$$$$$$$$)
2042 {
2043     my $text = shift;
2044     my $align = shift;
2045     my $indent = shift;
2046     my $paragraph_command = shift;
2047     my $paragraph_command_formatted = shift;
2048     my $paragraph_number = shift;
2049     my $format = shift;
2050     my $item_nr = shift;
2051     my $enumerate_style = shift;
2052     my $number = shift;
2053     my $command_stack_at_end = shift;
2054     my $command_stack_at_begin = shift;
2055     my $state = shift;
2056 #print STDERR "format: $format\n" if (defined($format));
2057 #print STDERR "paragraph @$command_stack_at_end; @$command_stack_at_begin\n";
2058     $paragraph_command_formatted = '' if (!defined($paragraph_command_formatted) or
2059           exists($special_list_commands{$format}->{$paragraph_command}));
2060     return '' if ($text =~ /^\s*$/);
2061     foreach my $style(t2h_collect_styles($command_stack_at_begin))
2062     {
2063        $text = t2h_begin_style($style, $text);
2064     }
2065     foreach my $style(t2h_collect_styles($command_stack_at_end))
2066     {
2067        $text = t2h_end_style($style, $text);
2068     }
2069     if (defined($paragraph_number) and defined($$paragraph_number))
2070     {
2071          $$paragraph_number++;
2072          return $text  if (($format eq 'itemize' or $format eq 'enumerate') and
2073             ($$paragraph_number == 1));
2074     }
2075     # The cells of a table should not be wrapped in a <p> tag, so just return the text
2076     if (defined($command_stack_at_begin->[0]) and $command_stack_at_begin->[0] eq 'multitable')
2077     {
2078         return $text;
2079     }
2080
2081     # Adjust all footnotes so that they look like good old makeinfo
2082     my $open = '<p';
2083     if ($align)
2084     {
2085         $open .= " align=\"$paragraph_style{$align}\"";
2086     }
2087     my $footnote_text = '';
2088     if (defined($command_stack_at_begin->[0]) and $command_stack_at_begin->[0] eq 'footnote')
2089     {
2090         my $state = $Texi2HTML::THISDOC{'state'};
2091         $makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number}++;
2092         if ($makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number} <= 1)
2093         {
2094            $open.=' class="footnote"';
2095            my $document_file = $state->{'footnote_document_file'};
2096            if ($document_file eq $state->{'footnote_footnote_file'})
2097            {
2098                $document_file = '';
2099            }
2100            my $docid = $state->{'footnote_place_id'};
2101            my $doc_state = $state->{'footnote_document_state'};
2102            $docid = '' if ($doc_state->{'outside_document'} or $doc_state->{'multiple_pass'});
2103            my $foot_label = &$anchor($state->{'footnote_footnote_id'},
2104                  $document_file . "#$state->{'footnote_place_id'}",
2105                  "$state->{'footnote_number_in_page'}");
2106            $footnote_text = "<small>[${foot_label}]</small> ";
2107         }
2108     }
2109     return $open.'>'.$footnote_text.$text.'</p>';
2110 }
2111
2112
2113 #############################################################################
2114 ###  WRITING OUT THE INDEX FOR THE AJAX SEARCH FIELD
2115 #############################################################################
2116
2117 $Texi2HTML::Config::IDX_SUMMARY   = 1;
2118 $Texi2HTML::Config::init_out                  = \&lilypond_init_out;
2119 $Texi2HTML::Config::finish_out                = \&lilypond_finish_out;
2120 $Texi2HTML::Config::index_summary_file_entry  = \&lilypond_index_summary_file_entry;
2121
2122 my @index_entries;
2123
2124 sub lilypond_init_out ()
2125 {
2126   t2h_default_init_out ();
2127   # Check whether we have an index at all! If not -> don't print out a search box!
2128   my $ix = main::get_index ("cp");
2129   $have_index_entries = (scalar $ix > 0);
2130 }
2131
2132 sub lilypond_index_summary_file_entry ($$$$$$$$$)
2133 {
2134   my $index_name = shift;
2135   my $entry_text = shift;
2136   my $entry_reference = shift;
2137   my $formatted_entry = shift;
2138   my $texi_entry = shift;
2139   my $entry_element_reference = shift;
2140   my $entry_element_header = shift;
2141   my $is_printed = shift;
2142   my $manual_name = shift;
2143
2144   if ($ENV{'AJAX_SEARCH'}==1) {
2145     if ($index_name eq "cp")
2146     {
2147       # The entries in the index file have the form:
2148       # SearchText \t FormattedText \t EntryURL \t SectionText \t SectionURL
2149       push @index_entries, "$entry_text\t$formatted_entry\t$entry_reference\t$entry_element_header\t$entry_element_reference\n";
2150     }
2151   }
2152 }
2153
2154 sub lilypond_finish_out ()
2155 {
2156   if ($ENV{'AJAX_SEARCH'}==1) {
2157     if (((scalar @index_entries) > 0) and $have_index_entries) {
2158       my $lang = $Texi2HTML::THISDOC{current_lang};
2159       my $big = "";
2160       $big = "-big-page" if $bigpage;
2161       my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
2162       my $idx_file = "$docu_dir/$docu_name$big.$lang.idx";
2163       open IDXOUTFILE, ">:utf8", $idx_file;
2164       print IDXOUTFILE @index_entries;
2165       close IDXOUTFILE;
2166     }
2167   }
2168 }
2169
2170
2171
2172 #############################################################################
2173 ###  OTHER SETTINGS
2174 #############################################################################
2175
2176 # For split pages, use index.html as start page!
2177 if ($Texi2HTML::Config::SPLIT eq 'section' or
2178     $Texi2HTML::Config::SPLIT eq 'node') {
2179   $Texi2HTML::Config::TOP_FILE = 'index.html';
2180 }
2181
2182
2183 return 1;