]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/lilypond-texi2html.init
Merge branch 'master' into lilypond/translation
[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 ###    impelmented by lilypond_css_lines
17 ### -) TOC (folded, with the current page highlighted) in an overflown <div>
18 ###    is added to every page; implemented by:
19 ###           lilypond_print_element_header -- building of the TOC
20 ###           lilypond_toc_body -- generation of customized TOC output
21 ###           lilypond_print_page_head -- start <div id="main">
22 ###           print_lilypond_page_foot -- closing id=main, output of footer & TOC
23 ### -) External refs are formatted only as "Text of the node" (not as >>see
24 ###    "NODE" section "SECTION" in "BOOK"<< like with default texi2html). Also,
25 ###    the leading "(book-name)" is removed.
26 ###    Implemented by overriding lilypond_external_ref
27 ### -) Navigation bars on top/bottom of the page and between sections are not
28 ###    left-aligned, but use a combination of left/center/right aligned table
29 ###    cells; For this, I heavily extend the texi2html code to allow for
30 ###    differently aligned cells and for multi-line tables);
31 ###    Implemented in lilypond_print_navigation
32 ### -) Different formatting than the default: example uses the same formatting
33 ###    as quote.
34 ### -) Allow translated section titles: All section titles can be translated,
35 ###    the original (English) title is associated with @translationof. This is
36 ###    needed, because the file name / anchor is generated from the original
37 ###    English title, since otherwise language-autoselection would break with
38 ###    posted links.
39 ###    Since it is then no longer possible to obtain the file name from the
40 ###    section title, I keep a sectionname<=>filename/anchor around. This way,
41 ###    xrefs from other manuals can simply load that map and retrieve the
42 ###    correct file name for the link. Implemented in:
43 ###           lilypond_unknown (handling of @translationof, in case
44 ###                             extract_texi_filenames.py messes up...)
45 ###           lilypond_element_file_name (correct file name: use the map)
46 ###           lilypond_element_target_name (correct anchor: use the map)
47 ###           lilypond_init_map (read in the externally created map from disk)
48 ###           lilypond_external_href (load the map for xrefs, use the correct
49 ###                                   link target)
50 ### -) The HTML anchors for all sections are derived from the node name /
51 ###    section title (pre-generated in the .xref-map file). Implemented by:
52 ###           lilypond_element_target_name (adjust section anchors)
53 ### -) Use the standard footnote format "<sup>nr</sup> text" instead of the
54 ###    ugly format of texi2html (<h3>(nr)</h3><p>text</p>). Implemented in
55 ###           makeinfo_like_foot_line_and_ref
56 ###           makeinfo_like_foot_lines
57 ###           makeinfo_like_paragraph
58 ###
59 ###
60 ### Useful helper functions:
61 ### -) texinfo_file_name($node_name): returns a texinfo-compatible file name
62 ###    for the given string $node_name (whitespace trimmed/replaced by -,
63 ###    non-standard chars replaced by _xxxx (ascii char code) and forced to
64 ###    start with a letter by prepending t_g if necessary)
65
66 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-mccarty.css", TITLE => "Default style"}
845     );
846 @Texi2HTML::Config::ALT_CSS_REFS      = (
847     {FILENAME => "lilypond.css", TITLE => "Andrew Hawryluk's design" },
848     {FILENAME => "lilypond-blue.css", TITLE => "Kurt Kroon's blue design" },
849 );
850
851 sub web_settings() {
852   print STDERR "Initializing settings for web site: [$Texi2HTML::THISDOC{current_lang}]\n";
853   $Texi2HTML::Config::BODYTEXT = "";
854   @Texi2HTML::Config::CSS_REFS      = (
855       {FILENAME => "lilypond-web.css", TITLE => "Patrick McCarty's design"}
856       );
857   @Texi2HTML::Config::ALT_CSS_REFS      = (
858       {FILENAME => "lilypond-web-alt1.css", TITLE => "Alternate style 1"},
859       {FILENAME => "lilypond-web-alt2.css", TITLE => "Alternate style 2"},
860       );
861 }
862
863 $Texi2HTML::Config::USE_ACCESSKEY = 1;
864 $Texi2HTML::Config::USE_LINKS     = 1;
865 $Texi2HTML::Config::USE_REL_REV   = 1;
866 $Texi2HTML::Config::SPLIT_INDEX   = 0;
867 $Texi2HTML::Config::SEPARATED_FOOTNOTES = 0; # Print footnotes on same page, not separated
868
869 my $bigpage = 0;
870 my $have_index_entries = 0;
871 if ($Texi2HTML::Config::SPLIT eq 'section' or
872     $Texi2HTML::Config::SPLIT eq 'node') {
873   $Texi2HTML::Config::element_file_name    = \&lilypond_element_file_name;
874   $bigpage = 0;
875 } else {
876   $bigpage = 1;
877 }
878
879 $Texi2HTML::Config::anchor  = \&lilypond_anchor;
880 $Texi2HTML::Config::element_target_name  = \&lilypond_element_target_name;
881 $default_print_element_header = $Texi2HTML::Config::print_element_header;
882 $Texi2HTML::Config::print_element_header = \&lilypond_print_element_header;
883 $Texi2HTML::Config::print_page_foot      = \&print_lilypond_page_foot;
884 $Texi2HTML::Config::print_navigation     = \&lilypond_print_navigation;
885 $Texi2HTML::Config::external_ref         = \&lilypond_external_ref;
886 $default_external_href = $Texi2HTML::Config::external_href;
887 $Texi2HTML::Config::external_href        = \&lilypond_external_href;
888 $default_toc_body = $Texi2HTML::Config::toc_body;
889 $Texi2HTML::Config::toc_body             = \&lilypond_toc_body;
890 $Texi2HTML::Config::css_lines            = \&lilypond_css_lines;
891 $default_unknown = $Texi2HTML::Config::unknown;
892 $Texi2HTML::Config::unknown              = \&lilypond_unknown;
893 $default_print_page_head = $Texi2HTML::Config::print_page_head;
894 $Texi2HTML::Config::print_page_head      = \&lilypond_print_page_head;
895 # $Texi2HTML::Config::foot_line_and_ref    = \&lilypond_foot_line_and_ref;
896 $Texi2HTML::Config::foot_line_and_ref  = \&makeinfo_like_foot_line_and_ref;
897 $Texi2HTML::Config::foot_lines         = \&makeinfo_like_foot_lines;
898 $Texi2HTML::Config::paragraph          = \&makeinfo_like_paragraph;
899
900
901
902 # Examples should be formatted similar to quotes:
903 $Texi2HTML::Config::complex_format_map->{'example'} = {
904   'begin' => q{"<blockquote>"},
905   'end' => q{"</blockquote>\n"},
906   'style' => 'code',
907  };
908
909 %Texi2HTML::config::misc_pages_targets = (
910    'Overview' => 'Overview',
911    'Contents' => 'Contents',
912    'About' => 'About'
913 );
914
915
916 my @section_to_filename;
917
918
919
920
921 #############################################################################
922 ###  DEBUGGING
923 #############################################################################
924
925 use Data::Dumper;
926 $Data::Dumper::Maxdepth = 2;
927
928 sub print_element_info($)
929 {
930   my $element = shift;
931   print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
932   print "Element: $element\n";
933   print Dumper($element);
934 }
935
936
937
938
939
940 #############################################################################
941 ###  HELPER FUNCTIONS
942 #############################################################################
943
944 # only lc() the last portion of an href
945 sub lc_last($)
946 {
947   my $href = shift;
948   my @hrefsplit = split('/', $href);
949   # change the last portion (the filename), if it exists;
950   # if it is a plain filename with no path, change the string as a whole
951   if ($#hrefsplit > 0) {
952     @hrefsplit[$#hrefsplit] = lc( @hrefsplit[$#hrefsplit] );
953     $href = join("/", @hrefsplit);
954   } else {
955     $href = lc($href);
956   }
957   return $href;
958 }
959
960 # Convert a given node name to its proper file name (normalization as explained
961 # in the texinfo manual:
962 # http://www.gnu.org/software/texinfo/manual/texinfo/html_node/HTML-Xref-Node-Name-Expansion.html
963 sub texinfo_file_name($)
964 {
965   my $text = shift;
966   my $result = '';
967   # File name normalization by texinfo:
968   # 1/2: letters and numbers are left unchanged
969   # 3/4: multiple, leading and trailing whitespace is removed
970   $text = main::normalise_space($text);
971   # 5/6: all remaining spaces are converted to '-', all other 7- or 8-bit
972   #      chars are replaced by _xxxx (xxxx=ascii character code)
973   while ($text ne '') {
974     if ($text =~ s/^([A-Za-z0-9]+)//o) { # number or letter stay unchanged
975       $result .= $1;
976     } elsif ($text =~ s/^ //o) { # space -> '-'
977       $result .= '-';
978     } elsif ($text =~ s/^(.)//o) { # Otherwise use _xxxx (ascii char code)
979       my $ccode = ord($1);
980       if ( $ccode <= 0xFFFF ) {
981         $result .= sprintf("_%04x", $ccode);
982       } else {
983         $result .= sprintf("__%06x", $ccode);
984       }
985     }
986   }
987   # 7: if name does not begin with a letter, prepend 't_g' (so it starts with a letter)
988   if ($result !~ /^[a-zA-Z]/) {
989     $result = 't_g' . $result;
990   }
991   # DONE
992   return lc_last($result)
993 }
994
995 # Load a file containing a nodename<=>filename map (tab-sepatared, i.e.
996 # NODENAME\tFILENAME\tANCHOR
997 # Returns a ref to a hash "Node title" => ["FilenameWithoutExt", "Anchor"]
998 sub load_map_file ($)
999 {
1000   my $mapfile = shift;
1001   my $node_map = ();
1002
1003   # For some unknown reason, Perl on my system (5.10.0 on Fedora 12)
1004   # refuses to open map files of translated documents with
1005   # '<:encoding(utf8)', but decoding from UTF-8 line by line works. -jm
1006   if (open(XREFFILE,'<', $mapfile)) {
1007     my $line;
1008     # print STDERR "*** PRINTING MAP FILE LINES ***\n";
1009     while ( $line = decode ('UTF-8', <XREFFILE>) ) {
1010       # parse the tab-separated entries and insert them into the map:
1011       chomp($line);
1012       my @entries = split(/\t/, $line);
1013       if (scalar (@entries) == 3) {
1014         $node_map->{$entries[0]} = [$entries[1], $entries[2]];
1015         $, = " ";
1016         # print STDERR @entries;
1017         # print STDERR "\n";
1018       } else {
1019         print STDERR "Invalid entry in the node file $mapfile: $line\n";
1020       }
1021     }
1022     close (XREFFILE);
1023   } else {
1024     print STDERR "WARNING: Unable to load the map file $mapfile\n";
1025   }
1026   return $node_map;
1027 }
1028
1029
1030 # Split the given path into dir and basename (with .texi removed). Used mainly
1031 # to get the path/basename of the original texi input file
1032 sub split_texi_filename ($)
1033 {
1034   my $docu = shift;
1035   my ($docu_dir, $docu_name);
1036   if ($docu =~ /(.*\/)/) {
1037     chop($docu_dir = $1);
1038     $docu_name = $docu;
1039     $docu_name =~ s/.*\///;
1040   } else {
1041      $docu_dir = '.';
1042      $docu_name = $docu;
1043   }
1044   $docu_name =~ s/\.te?x(i|info)?$//;
1045   return ($docu_dir, $docu_name);
1046 }
1047
1048
1049
1050
1051
1052 #############################################################################
1053 ###  CSS HANDLING
1054 #############################################################################
1055
1056 # Include our standard CSS file, not hard-coded CSS code directly in the HTML!
1057 # For IE, conditionally include the lilypond-ie-fixes.css style sheet
1058 sub lilypond_css_lines ($$)
1059 {
1060   my $import_lines = shift;
1061   my $rule_lines = shift;
1062   return if (defined($Texi2HTML::THISDOC{'CSS_LINES'}));
1063   if (@$rule_lines or @$import_lines)
1064   {
1065     $Texi2HTML::THISDOC{'CSS_LINES'} = "<style type=\"text/css\">\n<!--\n";
1066     $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$import_lines) . "\n" if (@$import_lines);
1067     $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$rule_lines) . "\n" if (@$rule_lines);
1068     $Texi2HTML::THISDOC{'CSS_LINES'} .= "-->\n</style>\n";
1069   }
1070   foreach my $ref (@CSS_REFS)
1071   {
1072     $Texi2HTML::THISDOC{'CSS_LINES'} .=
1073         "<link rel=\"stylesheet\" type=\"text/css\" title=\"$ref->{TITLE}\" href=\"$ref->{FILENAME}\">\n";
1074   }
1075   foreach my $ref (@Texi2HTML::Config::ALT_CSS_REFS)
1076   {
1077     $Texi2HTML::THISDOC{'CSS_LINES'} .=
1078         "<link rel=\"alternate stylesheet\" type=\"text/css\" href=\"$ref->{FILENAME}\" title=\"$ref->{TITLE}\">\n";
1079   }
1080
1081   # The ie-fixes stylesheet is needed for the docs, but not the website.
1082   if (not ($web_manual)) {
1083     $Texi2HTML::THISDOC{'CSS_LINES'} .=
1084         "<!--[if lte IE 7]>\n<link href=\"lilypond-ie-fixes.css\" rel=\"stylesheet\" type=\"text/css\">\n<![endif]-->\n";
1085   }
1086
1087   if ($ENV{'AJAX_SEARCH'} == 1) {
1088     # Add the JavaScript file only if we have an index.
1089     # Unfortunately, init_out is called after css_lines, so as a workaround
1090     # here we have to check again for the existence of an index...
1091     my $ix = main::get_index ("cp");
1092     $have_index_entries = (scalar $ix > 0);
1093     my $reldir = "";
1094     $reldir = "../" unless $bigpage;
1095     if ($have_index_entries) {
1096       $Texi2HTML::THISDOC{'CSS_LINES'} .= "<script language=\"JavaScript\" src=\"${reldir}lily_search.js\"></script>\n";
1097     }
1098   }
1099 }
1100
1101
1102
1103
1104
1105 #############################################################################
1106 ###  SPLITTING BASED ON NUMBERED SECTIONS
1107 #############################################################################
1108
1109 my $lastfilename;
1110 my $docnr = 0;
1111 my $node_to_filename_map = ();
1112 $source_to_translationof_map = ();
1113
1114
1115 # This function makes sure that files are only generated for numbered sections,
1116 # but not for unnumbered ones. It is called after texi2html has done its own
1117 # splitting and simply returns the filename for the node given as first argument
1118 # Nodes with the same filename will be printed out to the same filename, so
1119 # this really all we need. Also, make sure that the file names for sections
1120 # are derived from the section title. We also might want to name the anchors
1121 # according to node titles, which works by simply overriding the id element of
1122 # the $element hash.
1123 # If an external nodename<=>filename/anchor map file is found (loaded in
1124 # the command handler, use the externally created values, otherwise use the
1125 # same logic here.
1126 sub lilypond_element_file_name($$$)
1127 {
1128   my $element = shift;
1129   my $type = shift;
1130   my $docu_name = shift;
1131   my $docu_ext = $Texi2HTML::Config::EXTENSION;
1132
1133   my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
1134   # the snippets page does not use nodes for the snippets, so in this case
1135   # we'll have to use the section name!
1136   if ($node_name eq '') {
1137     $node_name = main::remove_texi($element->{'texi'});
1138   }
1139
1140   # If we have an entry in the section<=>filename map, use that one, otherwise
1141   # generate the filename/anchor here. In the latter case, external manuals
1142   # will not be able to retrieve the file name for xrefs!!! Still, I already
1143   # had that code, so I'll leave it in in case something goes wrong with the
1144   # extract_texi_filenames.py script in the lilypond build process!
1145   if (exists ($node_to_filename_map->{$node_name})) {
1146     (my $filename, my $anchor) = @{$node_to_filename_map->{$node_name}};
1147     $filename .= ".$docu_ext" if (defined($docu_ext));
1148     # don't do lc_last here, otherwise the colors are messed up!
1149     $filename = lc($filename);
1150
1151     # unnumbered sections (except those at top-level!) always go to the same
1152     # file as the previous numbered section
1153     if (not ($web_manual) and not ($element->{number})
1154         and not ($lastfilename eq '') and ($element->{level} > 1)) {
1155       $filename = $lastfilename;
1156     }
1157     if (($filename eq $lastfilename)) {
1158       $$element{doc_nr} = $docnr;
1159     } else {
1160       $docnr += 1;
1161       $$element{doc_nr} = $docnr;
1162       $lastfilename = $filename;
1163     }
1164     #print STDERR "Output file name: $filename\n";
1165     $filename = lc_last($filename);
1166     return $filename;
1167
1168   } elsif ($type eq "top" or $type eq "toc" or $type eq "doc" or
1169            $type eq "stoc" or $type eq "foot" or $type eq "about") {
1170     return;
1171   } else {
1172     print STDERR "WARNING: Node '$node_name' was NOT found in the map\n"
1173         unless ($node_name eq '') or ($element->{'tag'} eq 'unnumberedsec')
1174                or ($node_name =~ /NOT REALLY USED/);
1175
1176     # Numbered sections will get a filename Node_title, unnumbered sections will use
1177     # the file name of the previous numbered section:
1178     if (($element->{number}) or ($lastfilename eq '') or ($element->{level} == 1)) {
1179       # normalize to the same file name as texinfo
1180       if ($element->{translationof}) {
1181         $node_name = main::remove_texi($element->{translationof});
1182       }
1183       my $filename = texinfo_file_name($node_name);
1184       $filename .= ".$docu_ext" if (defined($docu_ext));
1185       $filename = lc_last($filename);
1186       $docnr += 1;
1187       $$element{doc_nr} = $docnr;
1188       $lastfilename = $filename;
1189       print STDERR "File name: $filename\n";
1190       return $filename;
1191     } else {
1192       $$element{doc_nr} = $docnr;
1193       $filename = lc_last($filename);
1194       print STDERR "File name: $filename\n";
1195       return $filename;
1196     }
1197   }
1198
1199   return;
1200 }
1201
1202 sub lilypond_normalise_node($)
1203 {
1204     my $text = shift;
1205     my $norm = main::t2h_default_normalise_node($text);
1206     if (exists ($source_to_translationof_map->{$text})) {
1207         my $original = $source_to_translationof_map->{$text};
1208         $norm = main::t2h_default_normalise_node($original);
1209     }
1210
1211     return $norm;
1212 }
1213
1214 # This function produces an anchor.
1215 #
1216 # arguments:
1217 # $name           :   anchor name
1218 # $href           :   anchor href
1219 # text            :   text displayed
1220 # extra_attribs   :   added to anchor attributes list
1221 sub lilypond_anchor($;$$$)
1222 {
1223     my $name = shift;
1224     my $href = shift;
1225     my $text = shift;
1226     my $attributes = shift;
1227     $href = remove_unneeded_anchor($href);
1228     if (!defined($attributes) or ($attributes !~ /\S/))
1229     {
1230         $attributes = '';
1231     }
1232     else
1233     {
1234         $attributes = ' ' . $attributes;
1235     }
1236     $name = '' if (!defined($name) or ($name !~ /\S/));
1237     $href = '' if (!defined($href) or ($href !~ /\S/));
1238     $text = '' if (!defined($text));
1239     return $text if (($name eq '') and ($href eq ''));
1240     $name = "name=\"$name\"" if ($name ne '');
1241     $href = "href=\"$href\"" if ($href ne '');
1242     $href = ' ' . $href if (($name ne '') and ($href ne ''));
1243     return "<a ${name}${href}${attributes}>$text</a>";
1244 }
1245
1246
1247 sub lilypond_element_target_name($$$)
1248 {
1249   my $element = shift;
1250   my $target = shift;
1251   my $id = shift;
1252   # Target is based on node name (or sec name for secs without node attached)
1253   my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
1254   if ($node_name eq '') {
1255     $node_name = main::remove_texi($element->{'texi'});
1256   }
1257
1258   # If we have an entry in the section<=>filename map, use that one, otherwise
1259   # generate the anchor here.
1260   if (exists ($node_to_filename_map->{$node_name})) {
1261     (my $filename, $target) = @{$node_to_filename_map->{$node_name}};
1262   } else {
1263     my $anchor = $node_name;
1264     if ($element->{translationof}) {
1265       $anchor = main::remove_texi($element->{translationof});
1266     }
1267     # normalize to the same file name as texinfo
1268     $target = texinfo_file_name($anchor);
1269   }
1270   # TODO: Once texi2html correctly prints out the target and not the id for
1271   #       the sections, change this back to ($id, $target)
1272   # I don't understand this comment, so I'm reluctant to delete it -gp
1273   $target = lc_last($target);
1274   $id = lc($target);
1275 # $id =~ s/-1$//i; # remove any trailing "-1"
1276   return ($target, $id);
1277 }
1278
1279
1280 ## Load the map file for the corrently processed texi file. We do this
1281 #  using a command init handler, since texi2html does not have any
1282 #  other hooks that are called after THISDOC is filled but before phase 2
1283 #  of the texi2html conversion.
1284 sub lilypond_init_map ()
1285 {
1286     my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1287     my $map_filename = main::locate_include_file ("${docu_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
1288         || main::locate_include_file ("${docu_name}.xref-map");
1289     #print STDERR "Map filename is: $map_filename\nDocu name is $docu_name\n";
1290     if ($docu_name eq 'web') {
1291         $web_manual = 1;
1292         web_settings();
1293     }
1294     $node_to_filename_map = load_map_file ($map_filename);
1295 }
1296 push @Texi2HTML::Config::command_handler_init, \&lilypond_init_map;
1297
1298
1299
1300 #############################################################################
1301 ###  CLEANER LINK TITLE FOR EXTERNAL REFS
1302 #############################################################################
1303
1304 # The default formatting of external refs returns e.g.
1305 # "(lilypond-internals)Timing_translator", so we remove all (...) from the
1306 # file_and_node argument. Also, we want only a very simple format, so we don't
1307 # even call the default handler!
1308 sub lilypond_external_ref($$$$$$)
1309 {
1310   my $type = shift;
1311   my $section = shift;
1312   my $book = shift;
1313   my $file_node = shift;
1314   my $href = shift;
1315
1316   $href = lc_last($href);
1317
1318   my $cross_ref = shift;
1319
1320   my $displaytext = '';
1321
1322   # 1) if we have a cross ref name, that's the text to be displayed:
1323   # 2) For the top node, use the (printable) name of the manual, unless we
1324   #    have an explicit cross ref name
1325   # 3) In all other cases use the section name
1326   if ($cross_ref ne '') {
1327     $displaytext = $cross_ref;
1328   } elsif (($section eq '') or ($section eq 'Top')) {
1329     $displaytext = $book;
1330   } else {
1331     $displaytext = $section;
1332   }
1333
1334   $displaytext = &$anchor('', $href, $displaytext) if ($displaytext ne '');
1335   return &$I('%{node_file_href}', { 'node_file_href' => $displaytext });
1336 }
1337
1338
1339
1340
1341
1342 #############################################################################
1343 ###  HANDLING TRANSLATED SECTIONS: handle @translationof, secname<->filename
1344 ###                  map stored on disk, xrefs in other manuals load that map
1345 #############################################################################
1346
1347
1348 # Try to make use of @translationof to generate files according to the original
1349 # English section title...
1350 sub lilypond_unknown($$$$$)
1351 {
1352     my $macro = shift;
1353     my $line = shift;
1354     my $pass = shift;
1355     my $stack = shift;
1356     my $state = shift;
1357
1358     # the @translationof macro provides the original English section title,
1359     # which should be used for file/anchor naming, while the title will be
1360     # translated to each language
1361     # It is already used by extract_texi_filenames.py, so this should not be
1362     # necessary here at all. Still, I'll leave the code in just in case the
1363     # python script messed up ;-)
1364     if ($pass == 1 and $macro eq "translationof") {
1365       if (ref($state->{'element'}) eq 'HASH') {
1366           $state->{'element'}->{'translationof'} = main::normalise_space($line);
1367           my $source = main::normalise_space ($line);
1368           if (ref($state->{'node_ref'}) eq 'HASH') {
1369               my $translationof = $state->{'node_ref'}->{'texi'};
1370               our %source_to_translationof_map;
1371               $source_to_translationof_map->{$source} = $translationof;
1372           }
1373       }
1374       return ('', 1, undef, undef);
1375     } else {
1376       return &$default_unknown($macro, $line, $pass, $stack, $state);
1377     }
1378 }
1379
1380
1381 my %translated_books = ();
1382 # Construct a href to an external source of information.
1383 # node is the node with texinfo @-commands
1384 # node_id is the node transliterated and transformed as explained in the
1385 #         texinfo manual
1386 # node_xhtml_id is the node transformed such that it is unique and can
1387 #     be used to make an html cross ref as explained in the texinfo manual
1388 # file is the file in '(file)node'
1389 sub lilypond_external_href($$$)
1390 {
1391   my $node = shift;
1392   my $node_id = shift;
1393   my $node_xhtml_id = shift;
1394   my $file = shift;
1395
1396   # 1) Keep a hash of book->section_map
1397   # 2) if not file in keys hash => try to load the map (assign empty map if
1398   #    non-existent => will load only once!)
1399   # 3) if node in the section=>(file, anchor) map, replace node_id and
1400   #    node_xhtml_id by the map's values
1401   # 4) call the default_external_href with these values (or the old ones if not found)
1402
1403   if (($node_id ne '') and defined($file) and ($node_id ne 'Top')) {
1404     my $map_name = $file;
1405     $map_name =~ s/-big-page//;
1406
1407     # Load the map if we haven't done so already
1408     if (!exists($translated_books{$map_name})) {
1409       my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1410       my $map_filename = main::locate_include_file ("${map_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
1411           || main::locate_include_file ("${map_name}.xref-map");
1412       $translated_books{$map_name} = load_map_file ($map_filename);
1413     }
1414
1415     # look up translation. use these values instead of the old filename/anchor
1416     my $section_name_map = $translated_books{$map_name};
1417     my $node_text = main::remove_texi($node);
1418     if (defined($section_name_map->{$node_text})) {
1419       ($node_id, $node_xhtml_id) = @{$section_name_map->{$node_text}};
1420     } else {
1421       print STDERR "WARNING: Unable to find node '$node_text' in book $map_name.\n";
1422     }
1423   }
1424
1425   if (defined $file) {
1426     $href = &$default_external_href($node, $node_id, $node_xhtml_id, lc_last($file));
1427     $href = remove_unneeded_anchor($href);
1428
1429     # TODO: very yucky, but will be fixed in issue 1004
1430     if ($web_manual) {
1431       my $only_web = $ENV{ONLY_WEB};
1432       if ($only_web) {
1433         $href = "../../doc/v2.13/Documentation/web/".$href;
1434       }
1435     }
1436
1437     return $href;
1438   } else {
1439     $href = &$default_external_href($node, $node_id, $node_xhtml_id);
1440     $href = remove_unneeded_anchor($href);
1441     return $href;
1442   }
1443 }
1444
1445 sub remove_unneeded_anchor($)
1446 {
1447   my $href = shift;
1448   my @hrefsplit = split("/", $href);
1449   for ($i = 0; $i < @hrefsplit; $i++) {
1450     $item = @hrefsplit[$i];
1451     if ($item =~ /#/) {
1452       @splitted = split(".html#", $item);
1453       if (@splitted[0] eq @splitted[1]) {
1454         @hrefsplit[$i] = @splitted[0] . ".html";
1455       }
1456     }
1457   }
1458   $href = join("/", @hrefsplit);
1459   return $href
1460 }
1461
1462
1463
1464 #############################################################################
1465 ###  CUSTOM TOC FOR EACH PAGE (in a frame on the left)
1466 #############################################################################
1467
1468 my $page_toc_depth = 2;
1469 my @default_toc = [];
1470
1471 # Initialize the toc_depth to 1 if the command-line option -D=short_toc is given
1472 sub lilypond_init_toc_depth ()
1473 {
1474   if (exists($main::value{'short_toc'}) and not exists($main::value{'bigpage'})
1475       and not $web_manual) {
1476     $page_toc_depth = 1;
1477   }
1478 }
1479 # Set the TOC-depth (depending on a texinfo variable short_toc) in a
1480 # command-handler, so we have them available when creating the pages
1481 push @Texi2HTML::Config::command_handler_process, \&lilypond_init_toc_depth;
1482
1483
1484
1485 # recursively generate the TOC entries for the element and its children (which
1486 # are only shown up to maxlevel. All ancestors of the current element are also
1487 # shown with their immediate children, irrespective of their level.
1488 # Unnumbered entries are only printed out if they are at top-level or 2nd level
1489 # or their parent element is an ancestor of the currently viewed node.
1490 # The conditions to call this method to print the entry for a child node is:
1491 # -) the parent is an ancestor of the current page node
1492 # -) the parent is a numbered element at top-level toplevel (i.e. show numbered
1493 #    and unnumbered 2nd-level children of numbered nodes)
1494 # -) the child element is a numbered node below level maxlevel
1495 sub generate_ly_toc_entries($$$$$)
1496 {
1497   my $element = shift;
1498   my $element_path = shift;
1499   my $maxlevel = shift;
1500   if ($web_manual) {
1501     $maxlevel = 1;
1502   }
1503   my $child_count = shift;
1504   my $current_element = shift;
1505   # Skip undefined sections, plus all sections generated by index splitting
1506   return() if (not defined($element) or exists($element->{'index_page'}));
1507   my @result = ();
1508   my $level = $element->{'toc_level'};
1509   my $is_parent_of_current = $element->{'id'} && $element_path->{$element->{'id'}};
1510   my $ind = '  ' x $level;
1511   my $this_css_class = " class=\"";
1512   # color indices for the second navigation bar on the website
1513   if ($web_manual) {
1514       my %color_maps = (
1515           'introduction' => [2, 2, 2, 2, 3, 3, 4, 4],
1516           'download' => [2, 2, 2, 3, 3, 4],
1517           'manuals' => [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4],
1518           'community' => [1, 1, 1, 2, 2, 2, 3, 3],
1519           );
1520       my $addColor = "colorDefault";
1521       while (($top_section, $color_indices) = each %color_maps) {
1522           if (index ($element->{'sectionup'}->{'file'}, $top_section) >= 0) {
1523               $addColor = "color" . $color_indices->[$child_count];
1524           }
1525       }
1526       $this_css_class .= $addColor;
1527   }
1528   $this_css_class .= $is_parent_of_current ? ' toc_current"' : '"';
1529   my $entry = "$ind<li$this_css_class>" .
1530       &$anchor ($element->{'tocid'},
1531                 "$element->{'file'}#$element->{'target'}",
1532                 $element->{'text'});
1533
1534   push (@result, $entry);
1535   my $children = $element->{'section_childs'};
1536   if (defined($children) and (ref($children) eq "ARRAY")) {
1537     my $force_children = $is_parent_of_current or ($level == 1 and $element->{'number'});
1538     my @child_result = ();
1539     my $sub_child_count = 0;
1540     foreach my $c (@$children) {
1541       my $is_numbered_child = defined ($c->{'number'});
1542       my $below_maxlevel = $c->{'toc_level'} le $maxlevel;
1543       if ($force_children or ($is_numbered_child and $below_maxlevel)) {
1544         my @child_res =
1545             generate_ly_toc_entries($c, $element_path, $maxlevel, $sub_child_count, $current_element);
1546         push (@child_result, @child_res);
1547         $sub_child_count += 1;
1548       }
1549     }
1550     # if no child nodes were generated, e.g. for the index, where expanded pages
1551     # are ignored, don't generate a list at all...
1552     if (@child_result) {
1553       push (@result, "\n$ind<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
1554       if ($web_manual) {
1555         push (@result, "$ind<li class=\"colorDefault" .
1556               ($element->{'text'} eq $current_element->{'text'} ?
1557                ' toc_current">' : '">') .
1558               &$anchor ($element->{'tocid'},
1559                         "$element->{'file'}#$element->{'target'}",
1560                         $element->{'text'}) . "</li>\n");
1561       }
1562       push (@result, @child_result);
1563       push (@result, "$ind</ul>\n");
1564     }
1565   }
1566   push (@result, "$ind</li>\n");
1567   return @result;
1568 }
1569
1570
1571 # Print a customized TOC, containing only the first two levels plus the whole
1572 # path to the current page
1573 sub lilypond_generate_page_toc_body($)
1574 {
1575     my $element = shift;
1576     my $current_element = $element;
1577     my %parentelements;
1578     $parentelements{$element->{'id'}} = 1;
1579     # Find the path to the current element
1580     while ( defined($current_element->{'sectionup'}) and
1581            ($current_element->{'sectionup'} ne $current_element) )
1582     {
1583       $parentelements{$current_element->{'sectionup'}->{'id'}} = 1
1584               if ($current_element->{'sectionup'}->{'id'} ne '');
1585       $current_element = $current_element->{'sectionup'};
1586       if ($web_manual) {
1587         if (exists($main::value{'shallow_toc'})) {
1588           last;
1589         }
1590       }
1591     }
1592     return () if not defined($current_element);
1593     # Create the toc entries recursively
1594     my @toc_entries = "";
1595     if ($web_manual) {
1596         @toc_entries = "<ul$NO_BULLET_LIST_ATTRIBUTE>\n";
1597         # FIXME: add link to main page, really hackily.
1598         if ($element->{'sectionup'}) {
1599             # it's not the top element
1600             push (@toc_entries, "<li><a href=\"index.html\">Main</a></li>\n");
1601         } else {
1602             push (@toc_entries,
1603                   "<li class=\"toc_current\"><a href=\"index.html\">Main</a></li>\n");
1604         }
1605     } else {
1606         push (@toc_entries, "<div class=\"contents\">\n");
1607         push (@toc_entries, "<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
1608     }
1609     my $children = $current_element->{'section_childs'};
1610     foreach ( @$children ) {
1611       push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth, 0, $element));
1612     }
1613     # search box
1614     #  I'm assuming that we wouldn't keep the google search box? -gp
1615     if (!($ENV{AJAX_SEARCH} == 1)) {
1616       local $/=undef;
1617       my $name = "search-box";
1618       $lang = $Texi2HTML::THISDOC{current_lang};
1619       open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$lang/$name.ihtml" or
1620         open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$name.ihtml"  or
1621         die "no such file: $name.ihtml: $!";
1622       my $search_string = decode ('UTF-8', <FILE>);
1623       $search_string = "<li>\n" . $search_string . "</li>\n";
1624       push (@toc_entries, $search_string);
1625       close FILE;
1626     }
1627
1628     push (@toc_entries, "</ul>\n");
1629     if ($web_manual) {
1630         push (@toc_entries, "\n");
1631     } else {
1632         push (@toc_entries, "</div>\n");
1633     }
1634     return @toc_entries;
1635 }
1636
1637 sub lilypond_print_toc_div ($$)
1638 {
1639   my $fh = shift;
1640   my $tocref = shift;
1641   my @lines = @$tocref;
1642   # use default TOC if no custom lines have been generated
1643   @lines = @default_toc if (not @lines);
1644   if (@lines) {
1645
1646     print $fh "\n\n<div id=\"tocframe\">\n";
1647
1648     # Remove the leading "GNU LilyPond --- " from the manual title
1649     my $topname = $Texi2HTML::NAME{'Top'};
1650     $topname =~ s/^GNU LilyPond(:| &[mn]dash;) //;
1651
1652     # construct the top-level Docs index (relative path and including language!)
1653     my $lang = $Texi2HTML::THISDOC{current_lang};
1654     if ($lang and $lang ne "en") {
1655       $lang .= ".";
1656     } else {
1657       $lang = "";
1658     }
1659     my $reldir = $ENV{DEPTH};
1660     # strip one depth level for translations
1661     if ($lang and $lang ne "en" and substr ($reldir, 0, 3) eq '../') {
1662         $reldir = substr ($reldir, 3);
1663     }
1664     # add a / at the end if there isn't one.
1665     if (substr ($reldir, -1) ne '/') {
1666         $reldir .= '/';
1667     }
1668     my $uplink = $reldir."Documentation/web/manuals.${lang}html";
1669
1670     if (not $web_manual) {
1671       print $fh "<p class=\"toc_uplink\"><a href=\"$uplink\"
1672          title=\"Documentation Index\">&lt;&lt; " .
1673          &ly_get_string ('Back to Documentation Index') .
1674          "</a></p>\n";
1675
1676       # AJAX search box, written in JavaScript
1677       if ($ENV{'AJAX_SEARCH'} == 1) {
1678         if ($have_index_entries) {
1679           my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1680           print $fh '<script language="JavaScript">print_search_field ("' .
1681              $Texi2HTML::THISDOC{current_lang} . '", "' . 
1682              $docu_name . "\", " . $bigpage . ")</script>\n";
1683         }
1684       }
1685
1686       print $fh '<h4 class="toc_header"> ' . &$anchor('',
1687                                     $Texi2HTML::HREF{'Top'},
1688                                     $topname,
1689                                     'title="Start of the manual"'
1690                                    ) . "</h4>\n";
1691     }
1692
1693     foreach my $line (@lines) {
1694       print $fh $line;
1695     }
1696     print $fh "</div>\n\n";
1697   }
1698 }
1699
1700 # Create the custom TOC for this page (partially folded, current page is
1701 # highlighted) and store it in a global variable. The TOC is written out after
1702 # the html contents (but positioned correctly using CSS), so that browsers with
1703 # css turned off still show the contents first.
1704 our @this_page_toc = ();
1705 sub lilypond_print_element_header
1706 {
1707   my $first_in_page = shift;
1708   my $previous_is_top = shift;
1709   if ($first_in_page and not @this_page_toc) {
1710     if (defined($Texi2HTML::THIS_ELEMENT)) {
1711       # Create the TOC for this page
1712       @this_page_toc = lilypond_generate_page_toc_body($Texi2HTML::THIS_ELEMENT);
1713     }
1714   }
1715   return &$default_print_element_header( $first_in_page, $previous_is_top);
1716 }
1717
1718 # Generate the HTML output for the TOC
1719 sub lilypond_toc_body($)
1720 {
1721     my $elements_list = shift;
1722     # Generate a default TOC for pages without THIS_ELEMENT
1723     @default_toc = lilypond_generate_page_toc_body(@$elements_list[0]);
1724     return &$default_toc_body($elements_list);
1725 }
1726
1727 # Print out the TOC in a <div> at the beginning of the page
1728 sub lilypond_print_page_head($)
1729 {
1730     my $fh = shift;
1731     &$default_print_page_head($fh);
1732     print $fh "<div id=\"main\">\n";
1733 }
1734
1735 # Print out the TOC in a <div> at the end of th page, which will be formatted as a
1736 # sidebar mimicking a TOC frame
1737 sub print_lilypond_page_foot($)
1738 {
1739   my $fh = shift;
1740   my $program_string = &$program_string();
1741 #   print $fh "<p><font size='-1'>$program_string</font><br>$PRE_BODY_CLOSE</p>\n";
1742   print $fh "<!-- FOOTER -->\n\n";
1743   print $fh "<!-- end div#main here -->\n</div>\n\n";
1744   if ($web_manual) {
1745     # FIXME: This div and p#languages need to be in div#footer.
1746     #        Should we move this div to postprocess_html.py ?
1747     print $fh "<div id=\"verifier_texinfo\">\n";
1748     print $fh "<h3>Validation</h3>\n";
1749     # FIXME: inlined text substitution, move to ly_get_string as soon as another case is needed
1750     my $webdev_link = "<a href=\"http://www.webdev.nl/\">webdev.nl</a>";
1751     my $lily_site = "<code>lilypond.org</code>";
1752     my $hosting_thanks = &ly_get_string ('<p>Thanks to ${webdev_link} for hosting ${lily_site}.');
1753     # this does the variable substitution ("quoting" in Perlish) after the localization
1754     $hosting_thanks =~ s/(\$\{\w+\})/$1/eeg;
1755     print $fh $hosting_thanks . "\n";
1756     print $fh "<a href=\"http://validator.w3.org/check?uri=referer\">\n";
1757     print $fh "<img src=\"http://www.w3.org/Icons/valid-html401\"\n";
1758     print $fh "     alt=\"Valid HTML 4.01 Transitional\"\n";
1759     print $fh "     height=\"31\" width=\"88\"></a></p>\n";
1760     print $fh "</div>";
1761   }
1762
1763   # Print the TOC frame and reset the TOC:
1764   lilypond_print_toc_div ($fh, \@this_page_toc);
1765   @this_page_toc = ();
1766
1767   # Close the page:
1768   print $fh "</body>\n</html>\n";
1769 }
1770
1771
1772
1773
1774
1775 #############################################################################
1776 ###  NICER / MORE FLEXIBLE NAVIGATION PANELS
1777 #############################################################################
1778
1779 sub get_navigation_text
1780 {
1781   my $button = shift;
1782   my $text = $NAVIGATION_TEXT{$button};
1783   if ( ($button eq 'Back') or ($button eq 'FastBack') ) {
1784     $text = $text . $Texi2HTML::NODE{$button} . "&nbsp;";
1785   } elsif ( ($button eq 'Forward') or ($button eq 'FastForward') ) {
1786     $text = "&nbsp;" . $Texi2HTML::NODE{$button} . $text;
1787   } elsif ( $button eq 'Up' ) {
1788     $text = "&nbsp;".$text.":&nbsp;" . $Texi2HTML::NODE{$button} . "&nbsp;";
1789   }
1790   return $text;
1791 }
1792
1793
1794 # Don't automatically create left-aligned table cells for every link, but
1795 # instead create a <td> only on an appropriate '(left|right|center)-aligned-cell-n'
1796 # button text. It's alignment as well as the colspan will be taken from the
1797 # name of the button. Also, add 'newline' button text to create a new table
1798 # row. The texts of the buttons are generated by get_navigation_text and
1799 # will contain the name of the next/previous section/chapter.
1800 sub lilypond_print_navigation
1801 {
1802     my $buttons = shift;
1803     my $vertical = shift;
1804     my $spacing = 1;
1805     my $result = "<table class=\"nav_table\">\n";
1806
1807     $result .= "<tr>" unless $vertical;
1808     my $beginofline = 1;
1809     foreach my $button (@$buttons)
1810     {
1811         $result .= qq{<tr valign="top" align="left">\n} if $vertical;
1812         # Allow (left|right|center)-aligned-cell and newline as buttons!
1813         if ( $button =~ /^(.*)-aligned-cell-(.*)$/ )
1814         {
1815           $result .= qq{</td>} unless $beginofline;
1816           $result .= qq{<td valign="middle" align="$1" colspan="$2">};
1817           $beginofline = 0;
1818         }
1819         elsif ( $button eq 'newline' )
1820         {
1821           $result .= qq{</td>} unless $beginofline;
1822           $result .= qq{</tr>};
1823           $result .= qq{<tr>};
1824           $beginofline = 1;
1825
1826         }
1827         elsif (ref($button) eq 'CODE')
1828         {
1829             $result .= &$button($vertical);
1830         }
1831         elsif (ref($button) eq 'SCALAR')
1832         {
1833             $result .= "$$button" if defined($$button);
1834         }
1835         elsif (ref($button) eq 'ARRAY')
1836         {
1837             my $text = $button->[1];
1838             my $button_href = $button->[0];
1839             # verify that $button_href is simple text and text is a reference
1840             if (defined($button_href) and !ref($button_href)
1841                and defined($text) and (ref($text) eq 'SCALAR') and defined($$text))
1842             {             # use given text
1843                 if ($Texi2HTML::HREF{$button_href})
1844                 {
1845                   my $anchor_attributes = '';
1846                   if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button_href})) and
1847                       ($BUTTONS_ACCESSKEY{$button_href} ne ''))
1848                   {
1849                       $anchor_attributes = "accesskey=\"$BUTTONS_ACCESSKEY{$button_href}\"";
1850                   }
1851                   if ($USE_REL_REV and (defined($BUTTONS_REL{$button_href})) and
1852                       ($BUTTONS_REL{$button_href} ne ''))
1853                   {
1854                       $anchor_attributes .= " rel=\"$BUTTONS_REL{$button_href}\"";
1855                   }
1856                   $result .=  "" .
1857                         &$anchor('',
1858                                     $Texi2HTML::HREF{$button_href},
1859                                     get_navigation_text($$text),
1860                                     $anchor_attributes
1861                                    );
1862                 }
1863                 else
1864                 {
1865                   $result .=  get_navigation_text($$text);
1866                 }
1867             }
1868         }
1869         elsif ($button eq ' ')
1870         {                       # handle space button
1871             $result .=
1872                 ($ICONS && $ACTIVE_ICONS{' '}) ?
1873                     &$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{' '}) :
1874                         $NAVIGATION_TEXT{' '};
1875             #next;
1876         }
1877         elsif ($Texi2HTML::HREF{$button})
1878         {                       # button is active
1879             my $btitle = $BUTTONS_GOTO{$button} ?
1880                 'title="' . $BUTTONS_GOTO{$button} . '"' : '';
1881             if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button})) and
1882                 ($BUTTONS_ACCESSKEY{$button} ne ''))
1883             {
1884                 $btitle .= " accesskey=\"$BUTTONS_ACCESSKEY{$button}\"";
1885             }
1886             if ($USE_REL_REV and (defined($BUTTONS_REL{$button})) and
1887                 ($BUTTONS_REL{$button} ne ''))
1888             {
1889                 $btitle .= " rel=\"$BUTTONS_REL{$button}\"";
1890             }
1891             if ($ICONS && $ACTIVE_ICONS{$button})
1892             {                   # use icon
1893                 $result .= '' .
1894                     &$anchor('',
1895                         $Texi2HTML::HREF{$button},
1896                         &$button_icon_img($BUTTONS_NAME{$button},
1897                                    $ACTIVE_ICONS{$button},
1898                                    $Texi2HTML::SIMPLE_TEXT{$button}),
1899                         $btitle
1900                       );
1901             }
1902             else
1903             {                   # use text
1904                 $result .=
1905                     '[' .
1906                         &$anchor('',
1907                                     $Texi2HTML::HREF{$button},
1908                                     get_navigation_text($button),
1909                                     $btitle
1910                                    ) .
1911                                        ']';
1912             }
1913         }
1914         else
1915         {                       # button is passive
1916             $result .=
1917                 $ICONS && $PASSIVE_ICONS{$button} ?
1918                     &$button_icon_img($BUTTONS_NAME{$button},
1919                                           $PASSIVE_ICONS{$button},
1920                                           $Texi2HTML::SIMPLE_TEXT{$button}) :
1921
1922                                               "[" . get_navigation_text($button) . "]";
1923         }
1924         $result .= "</td>\n" if $vertical;
1925         $result .= "</tr>\n" if $vertical;
1926     }
1927     $result .= "</td>" unless $beginofline;
1928     $result .= "</tr>" unless $vertical;
1929     $result .= "</table>\n";
1930     if ($web_manual) {
1931       return "\n";
1932     } else {
1933       return $result;
1934     }
1935 }
1936
1937
1938 @Texi2HTML::Config::SECTION_BUTTONS =
1939     ('left-aligned-cell-1', 'FastBack',
1940      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1941      'right-aligned-cell-1', 'FastForward',
1942      'newline',
1943      'left-aligned-cell-2', 'Back',
1944      'center-aligned-cell-1', 'Up',
1945      'right-aligned-cell-2', 'Forward'
1946     );
1947
1948 # buttons for misc stuff
1949 @Texi2HTML::Config::MISC_BUTTONS = ('center-aligned-cell-3',
1950                                     'Top', 'Contents', 'Index', 'About');
1951
1952 # buttons for chapter file footers
1953 # (and headers but only if SECTION_NAVIGATION is false)
1954 @Texi2HTML::Config::CHAPTER_BUTTONS =
1955     ('left-aligned-cell-1', 'FastBack',
1956      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1957      'right-aligned-cell-1', 'FastForward',
1958     );
1959
1960 # buttons for section file footers
1961 @Texi2HTML::Config::SECTION_FOOTER_BUTTONS =
1962     ('left-aligned-cell-1', 'FastBack',
1963      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1964      'right-aligned-cell-1', 'FastForward',
1965      'newline',
1966      'left-aligned-cell-2', 'Back',
1967      'center-aligned-cell-1', 'Up',
1968      'right-aligned-cell-2', 'Forward'
1969     );
1970
1971 @Texi2HTML::Config::NODE_FOOTER_BUTTONS =
1972     ('left-aligned-cell-1', 'FastBack',
1973      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1974      'right-aligned-cell-1', 'FastForward',
1975      'newline',
1976      'left-aligned-cell-2', 'Back',
1977      'center-aligned-cell-1', 'Up',
1978      'right-aligned-cell-2', 'Forward'
1979     );
1980
1981
1982
1983
1984
1985 #############################################################################
1986 ###  FOOTNOTE FORMATTING
1987 #############################################################################
1988
1989 # Format footnotes in a nicer way: Instead of printing the number in a separate
1990 # (nr) heading line, use the standard way of prepending <sup>nr</sup> immediately
1991 # before the fn text.
1992
1993
1994 # The following code is copied from texi2html's examples/makeinfo.init and
1995 # should be updated when texi2html makes some changes there!
1996
1997 my $makekinfo_like_footnote_absolute_number = 0;
1998
1999 sub makeinfo_like_foot_line_and_ref($$$$$$$$)
2000 {
2001     my $foot_num = shift;
2002     my $relative_num = shift;
2003     my $footid = shift;
2004     my $docid = shift;
2005     my $from_file = shift;
2006     my $footnote_file = shift;
2007     my $lines = shift;
2008     my $state = shift;
2009
2010     $makekinfo_like_footnote_absolute_number++;
2011
2012     # this is a bit obscure, this allows to add an anchor only if formatted
2013     # as part of the document.
2014     $docid = '' if ($state->{'outside_document'} or $state->{'multiple_pass'});
2015
2016     if ($from_file eq $footnote_file)
2017     {
2018         $from_file = $footnote_file = '';
2019     }
2020
2021     my $foot_anchor = "<sup>" .
2022         &$anchor($docid, "$footnote_file#$footid", $relative_num) . "</sup>";
2023     $foot_anchor = &$anchor($docid,
2024                             "$footnote_file#$footid",
2025                             "($relative_num)") if ($state->{'preformatted'});
2026
2027 #    unshift @$lines, "<li>";
2028 #    push @$lines, "</li>\n";
2029     return ($lines, $foot_anchor);
2030 }
2031
2032 sub makeinfo_like_foot_lines($)
2033 {
2034     my $lines = shift;
2035     unshift @$lines, "<hr>\n<h4>$Texi2HTML::I18n::WORDS->{'Footnotes_Title'}</h4>\n";
2036 #<ol type=\"1\">\n";
2037 #    push @$lines, "</ol>";
2038     return $lines;
2039 }
2040
2041 my %makekinfo_like_paragraph_in_footnote_nr;
2042
2043 sub makeinfo_like_paragraph ($$$$$$$$$$$$$)
2044 {
2045     my $text = shift;
2046     my $align = shift;
2047     my $indent = shift;
2048     my $paragraph_command = shift;
2049     my $paragraph_command_formatted = shift;
2050     my $paragraph_number = shift;
2051     my $format = shift;
2052     my $item_nr = shift;
2053     my $enumerate_style = shift;
2054     my $number = shift;
2055     my $command_stack_at_end = shift;
2056     my $command_stack_at_begin = shift;
2057     my $state = shift;
2058 #print STDERR "format: $format\n" if (defined($format));
2059 #print STDERR "paragraph @$command_stack_at_end; @$command_stack_at_begin\n";
2060     $paragraph_command_formatted = '' if (!defined($paragraph_command_formatted) or
2061           exists($special_list_commands{$format}->{$paragraph_command}));
2062     return '' if ($text =~ /^\s*$/);
2063     foreach my $style(t2h_collect_styles($command_stack_at_begin))
2064     {
2065        $text = t2h_begin_style($style, $text);
2066     }
2067     foreach my $style(t2h_collect_styles($command_stack_at_end))
2068     {
2069        $text = t2h_end_style($style, $text);
2070     }
2071     if (defined($paragraph_number) and defined($$paragraph_number))
2072     {
2073          $$paragraph_number++;
2074          return $text  if (($format eq 'itemize' or $format eq 'enumerate') and
2075             ($$paragraph_number == 1));
2076     }
2077     my $open = '<p';
2078     if ($align)
2079     {
2080         $open .= " align=\"$paragraph_style{$align}\"";
2081     }
2082     my $footnote_text = '';
2083     if (defined($command_stack_at_begin->[0]) and $command_stack_at_begin->[0] eq 'footnote')
2084     {
2085         my $state = $Texi2HTML::THISDOC{'state'};
2086         $makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number}++;
2087         if ($makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number} <= 1)
2088         {
2089            $open.=' class="footnote"';
2090            my $document_file = $state->{'footnote_document_file'};
2091            if ($document_file eq $state->{'footnote_footnote_file'})
2092            {
2093                $document_file = '';
2094            }
2095            my $docid = $state->{'footnote_place_id'};
2096            my $doc_state = $state->{'footnote_document_state'};
2097            $docid = '' if ($doc_state->{'outside_document'} or $doc_state->{'multiple_pass'});
2098            my $foot_label = &$anchor($state->{'footnote_footnote_id'},
2099                  $document_file . "#$state->{'footnote_place_id'}",
2100                  "$state->{'footnote_number_in_page'}");
2101            $footnote_text = "<small>[${foot_label}]</small> ";
2102         }
2103     }
2104     return $open.'>'.$footnote_text.$text.'</p>';
2105 }
2106
2107
2108 #############################################################################
2109 ###  WRITING OUT THE INDEX FOR THE AJAX SEARCH FIELD
2110 #############################################################################
2111
2112 $Texi2HTML::Config::IDX_SUMMARY   = 1;
2113 $Texi2HTML::Config::init_out                  = \&lilypond_init_out;
2114 $Texi2HTML::Config::finish_out                = \&lilypond_finish_out;
2115 $Texi2HTML::Config::index_summary_file_entry  = \&lilypond_index_summary_file_entry;
2116
2117 my @index_entries;
2118
2119 sub lilypond_init_out ()
2120 {
2121   t2h_default_init_out ();
2122   # Check whether we have an index at all! If not -> don't print out a search box!
2123   my $ix = main::get_index ("cp");
2124   $have_index_entries = (scalar $ix > 0);
2125 }
2126
2127 sub lilypond_index_summary_file_entry ($$$$$$$$$)
2128 {
2129   my $index_name = shift;
2130   my $entry_text = shift;
2131   my $entry_reference = shift;
2132   my $formatted_entry = shift;
2133   my $texi_entry = shift;
2134   my $entry_element_reference = shift;
2135   my $entry_element_header = shift;
2136   my $is_printed = shift;
2137   my $manual_name = shift;
2138
2139   if ($ENV{'AJAX_SEARCH'}==1) {
2140     if ($index_name eq "cp")
2141     {
2142       # The entries in the index file have the form:
2143       # SearchText \t FormattedText \t EntryURL \t SectionText \t SectionURL
2144       push @index_entries, "$entry_text\t$formatted_entry\t$entry_reference\t$entry_element_header\t$entry_element_reference\n";
2145     }
2146   }
2147 }
2148
2149 sub lilypond_finish_out ()
2150 {
2151   if ($ENV{'AJAX_SEARCH'}==1) {
2152     if (((scalar @index_entries) > 0) and $have_index_entries) {
2153       my $lang = $Texi2HTML::THISDOC{current_lang};
2154       my $big = "";
2155       $big = "-big-page" if $bigpage;
2156       my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
2157       my $idx_file = "$docu_dir/$docu_name$big.$lang.idx";
2158       open IDXOUTFILE, ">:utf8", $idx_file;
2159       print IDXOUTFILE @index_entries;
2160       close IDXOUTFILE;
2161     }
2162   }
2163 }
2164
2165
2166
2167 #############################################################################
2168 ###  OTHER SETTINGS
2169 #############################################################################
2170
2171 # For split pages, use index.html as start page!
2172 if ($Texi2HTML::Config::SPLIT eq 'section' or
2173     $Texi2HTML::Config::SPLIT eq 'node') {
2174   $Texi2HTML::Config::TOP_FILE = 'index.html';
2175 }
2176
2177
2178 return 1;