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