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