]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/lilypond-texi2html.init
Merge branch 'translation' into staging
[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}.' => 'Grazie a ${webdev_link} per l\'hosting di ${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   ## This section makes the manual name visible to CSS through the body tag
1099   ## so that styles can be applied per manual. It will add the manual
1100   ## directory name (e.g., 'notation' or 'learning') as a CSS class, as well
1101   ## as a development status.
1102
1103   # Parse the input file name to determine the manual we're dealing with.
1104   my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1105
1106   # Hard-coded value to indicate if this is a development version
1107   # ('devStatus') or stable version ('stableStatus')
1108   # TODO: Figure out how to automatically set this value based on the even/odd minor revision number or some other mechanism.
1109   $documentstatus = 'devStatus';
1110
1111   # Create the extra information for the <body> tag.
1112   # For example, the development Notation reference in English
1113   # will output in HTML as <body lang='en' class='notation devStatus'>
1114   $Texi2HTML::Config::BODYTEXT = 'lang="' . $Texi2HTML::THISDOC{current_lang} . '" class="' . $docu_name . ' ' . $documentstatus . '"';
1115
1116 }
1117
1118
1119
1120
1121
1122 #############################################################################
1123 ###  SPLITTING BASED ON NUMBERED SECTIONS
1124 #############################################################################
1125
1126 my $lastfilename;
1127 my $docnr = 0;
1128 my $node_to_filename_map = ();
1129 $source_to_translationof_map = ();
1130
1131
1132 # This function makes sure that files are only generated for numbered sections,
1133 # but not for unnumbered ones. It is called after texi2html has done its own
1134 # splitting and simply returns the filename for the node given as first argument
1135 # Nodes with the same filename will be printed out to the same filename, so
1136 # this really all we need. Also, make sure that the file names for sections
1137 # are derived from the section title. We also might want to name the anchors
1138 # according to node titles, which works by simply overriding the id element of
1139 # the $element hash.
1140 # If an external nodename<=>filename/anchor map file is found (loaded in
1141 # the command handler, use the externally created values, otherwise use the
1142 # same logic here.
1143 sub lilypond_element_file_name($$$)
1144 {
1145   my $element = shift;
1146   my $type = shift;
1147   my $docu_name = shift;
1148   my $docu_ext = $Texi2HTML::Config::EXTENSION;
1149
1150   my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
1151   # the snippets page does not use nodes for the snippets, so in this case
1152   # we'll have to use the section name!
1153   if ($node_name eq '') {
1154     $node_name = main::remove_texi($element->{'texi'});
1155   }
1156
1157   # If we have an entry in the section<=>filename map, use that one, otherwise
1158   # generate the filename/anchor here. In the latter case, external manuals
1159   # will not be able to retrieve the file name for xrefs!!! Still, I already
1160   # had that code, so I'll leave it in in case something goes wrong with the
1161   # extract_texi_filenames.py script in the lilypond build process!
1162   if (exists ($node_to_filename_map->{$node_name})) {
1163     (my $filename, my $anchor) = @{$node_to_filename_map->{$node_name}};
1164     $filename .= ".$docu_ext" if (defined($docu_ext));
1165     # don't do lc_last here, otherwise the colors are messed up!
1166     $filename = lc($filename);
1167
1168     # unnumbered sections (except those at top-level!) always go to the same
1169     # file as the previous numbered section
1170     if (not ($web_manual) and not ($element->{number})
1171         and not ($lastfilename eq '') and ($element->{level} > 1)) {
1172       $filename = $lastfilename;
1173     }
1174     if (($filename eq $lastfilename)) {
1175       $$element{doc_nr} = $docnr;
1176     } else {
1177       $docnr += 1;
1178       $$element{doc_nr} = $docnr;
1179       $lastfilename = $filename;
1180     }
1181     #print STDERR "Output file name: $filename\n";
1182     $filename = lc_last($filename);
1183     return $filename;
1184
1185   } elsif ($type eq "top" or $type eq "toc" or $type eq "doc" or
1186            $type eq "stoc" or $type eq "foot" or $type eq "about") {
1187     return;
1188   } else {
1189     print STDERR "WARNING: Node '$node_name' was NOT found in the map\n"
1190         unless ($node_name eq '') or ($element->{'tag'} eq 'unnumberedsec')
1191                or ($node_name =~ /NOT REALLY USED/);
1192
1193     # Numbered sections will get a filename Node_title, unnumbered sections will use
1194     # the file name of the previous numbered section:
1195     if (($element->{number}) or ($lastfilename eq '') or ($element->{level} == 1)) {
1196       # normalize to the same file name as texinfo
1197       if ($element->{translationof}) {
1198         $node_name = main::remove_texi($element->{translationof});
1199       }
1200       my $filename = texinfo_file_name($node_name);
1201       $filename .= ".$docu_ext" if (defined($docu_ext));
1202       $filename = lc_last($filename);
1203       $docnr += 1;
1204       $$element{doc_nr} = $docnr;
1205       $lastfilename = $filename;
1206       print STDERR "File name: $filename\n";
1207       return $filename;
1208     } else {
1209       $$element{doc_nr} = $docnr;
1210       $filename = lc_last($filename);
1211       print STDERR "File name: $filename\n";
1212       return $filename;
1213     }
1214   }
1215
1216   return;
1217 }
1218
1219 sub lilypond_normalise_node($)
1220 {
1221     my $text = shift;
1222     my $norm = main::t2h_default_normalise_node($text);
1223     if (exists ($source_to_translationof_map->{$text})) {
1224         my $original = $source_to_translationof_map->{$text};
1225         $norm = main::t2h_default_normalise_node($original);
1226     }
1227
1228     return $norm;
1229 }
1230
1231 # This function produces an anchor.
1232 #
1233 # arguments:
1234 # $name           :   anchor name
1235 # $href           :   anchor href
1236 # text            :   text displayed
1237 # extra_attribs   :   added to anchor attributes list
1238 sub lilypond_anchor($;$$$)
1239 {
1240     my $name = shift;
1241     my $href = shift;
1242     my $text = shift;
1243     my $attributes = shift;
1244     $href = remove_unneeded_anchor($href);
1245     if (!defined($attributes) or ($attributes !~ /\S/))
1246     {
1247         $attributes = '';
1248     }
1249     else
1250     {
1251         $attributes = ' ' . $attributes;
1252     }
1253     $name = '' if (!defined($name) or ($name !~ /\S/));
1254     $href = '' if (!defined($href) or ($href !~ /\S/));
1255     $text = '' if (!defined($text));
1256     return $text if (($name eq '') and ($href eq ''));
1257     $name = "name=\"$name\"" if ($name ne '');
1258     $href = "href=\"$href\"" if ($href ne '');
1259     $href = ' ' . $href if (($name ne '') and ($href ne ''));
1260     return "<a ${name}${href}${attributes}>$text</a>";
1261 }
1262
1263
1264 sub lilypond_element_target_name($$$)
1265 {
1266   my $element = shift;
1267   my $target = shift;
1268   my $id = shift;
1269   # Target is based on node name (or sec name for secs without node attached)
1270   my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
1271   if ($node_name eq '') {
1272     $node_name = main::remove_texi($element->{'texi'});
1273   }
1274
1275   # If we have an entry in the section<=>filename map, use that one, otherwise
1276   # generate the anchor here.
1277   if (exists ($node_to_filename_map->{$node_name})) {
1278     (my $filename, $target) = @{$node_to_filename_map->{$node_name}};
1279   } else {
1280     my $anchor = $node_name;
1281     if ($element->{translationof}) {
1282       $anchor = main::remove_texi($element->{translationof});
1283     }
1284     # normalize to the same file name as texinfo
1285     $target = texinfo_file_name($anchor);
1286   }
1287   # TODO: Once texi2html correctly prints out the target and not the id for
1288   #       the sections, change this back to ($id, $target)
1289   # I don't understand this comment, so I'm reluctant to delete it -gp
1290   $target = lc_last($target);
1291   $id = lc($target);
1292 # $id =~ s/-1$//i; # remove any trailing "-1"
1293   return ($target, $id);
1294 }
1295
1296
1297 ## Load the map file for the corrently processed texi file. We do this
1298 #  using a command init handler, since texi2html does not have any
1299 #  other hooks that are called after THISDOC is filled but before phase 2
1300 #  of the texi2html conversion.
1301 sub lilypond_init_map ()
1302 {
1303     my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1304     my $map_filename = main::locate_include_file ("${docu_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
1305         || main::locate_include_file ("${docu_name}.xref-map");
1306     #print STDERR "Map filename is: $map_filename\nDocu name is $docu_name\n";
1307     if ($docu_name eq 'web') {
1308         $web_manual = 1;
1309         web_settings();
1310     }
1311     $node_to_filename_map = load_map_file ($map_filename);
1312 }
1313 push @Texi2HTML::Config::command_handler_init, \&lilypond_init_map;
1314
1315
1316
1317 #############################################################################
1318 ###  CLEANER LINK TITLE FOR EXTERNAL REFS
1319 #############################################################################
1320
1321 # The default formatting of external refs returns e.g.
1322 # "(lilypond-internals)Timing_translator", so we remove all (...) from the
1323 # file_and_node argument. Also, we want only a very simple format, so we don't
1324 # even call the default handler!
1325 sub lilypond_external_ref($$$$$$)
1326 {
1327   my $type = shift;
1328   my $section = shift;
1329   my $book = shift;
1330   my $file_node = shift;
1331   my $href = shift;
1332
1333   $href = lc_last($href);
1334
1335   my $cross_ref = shift;
1336
1337   my $displaytext = '';
1338
1339   # 1) if we have a cross ref name, that's the text to be displayed:
1340   # 2) For the top node, use the (printable) name of the manual, unless we
1341   #    have an explicit cross ref name
1342   # 3) In all other cases use the section name
1343   if ($cross_ref ne '') {
1344     $displaytext = $cross_ref;
1345   } elsif (($section eq '') or ($section eq 'Top')) {
1346     $displaytext = $book;
1347   } else {
1348     $displaytext = $section;
1349   }
1350
1351   $displaytext = &$anchor('', $href, $displaytext) if ($displaytext ne '');
1352   return &$I('%{node_file_href}', { 'node_file_href' => $displaytext });
1353 }
1354
1355
1356
1357
1358
1359 #############################################################################
1360 ###  HANDLING TRANSLATED SECTIONS: handle @translationof, secname<->filename
1361 ###                  map stored on disk, xrefs in other manuals load that map
1362 #############################################################################
1363
1364
1365 # Try to make use of @translationof to generate files according to the original
1366 # English section title...
1367 sub lilypond_unknown($$$$$)
1368 {
1369     my $macro = shift;
1370     my $line = shift;
1371     my $pass = shift;
1372     my $stack = shift;
1373     my $state = shift;
1374
1375     # the @translationof macro provides the original English section title,
1376     # which should be used for file/anchor naming, while the title will be
1377     # translated to each language
1378     # It is already used by extract_texi_filenames.py, so this should not be
1379     # necessary here at all. Still, I'll leave the code in just in case the
1380     # python script messed up ;-)
1381     if ($pass == 1 and $macro eq "translationof") {
1382       if (ref($state->{'element'}) eq 'HASH') {
1383           $state->{'element'}->{'translationof'} = main::normalise_space($line);
1384           my $source = main::normalise_space ($line);
1385           if (ref($state->{'node_ref'}) eq 'HASH') {
1386               my $translationof = $state->{'node_ref'}->{'texi'};
1387               our %source_to_translationof_map;
1388               $source_to_translationof_map->{$source} = $translationof;
1389           }
1390       }
1391       return ('', 1, undef, undef);
1392     } else {
1393       return &$default_unknown($macro, $line, $pass, $stack, $state);
1394     }
1395 }
1396
1397
1398 my %translated_books = ();
1399 # Construct a href to an external source of information.
1400 # node is the node with texinfo @-commands
1401 # node_id is the node transliterated and transformed as explained in the
1402 #         texinfo manual
1403 # node_xhtml_id is the node transformed such that it is unique and can
1404 #     be used to make an html cross ref as explained in the texinfo manual
1405 # file is the file in '(file)node'
1406 sub lilypond_external_href($$$)
1407 {
1408   my $node = shift;
1409   my $node_id = shift;
1410   my $node_xhtml_id = shift;
1411   my $file = shift;
1412
1413   # 1) Keep a hash of book->section_map
1414   # 2) if not file in keys hash => try to load the map (assign empty map if
1415   #    non-existent => will load only once!)
1416   # 3) if node in the section=>(file, anchor) map, replace node_id and
1417   #    node_xhtml_id by the map's values
1418   # 4) call the default_external_href with these values (or the old ones if not found)
1419
1420   if (($node_id ne '') and defined($file) and ($node_id ne 'Top')) {
1421     my $map_name = $file;
1422     $map_name =~ s/-big-page//;
1423
1424     # Load the map if we haven't done so already
1425     if (!exists($translated_books{$map_name})) {
1426       my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1427       my $map_filename = main::locate_include_file ("${map_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
1428           || main::locate_include_file ("${map_name}.xref-map");
1429       $translated_books{$map_name} = load_map_file ($map_filename);
1430     }
1431
1432     # look up translation. use these values instead of the old filename/anchor
1433     my $section_name_map = $translated_books{$map_name};
1434     my $node_text = main::remove_texi($node);
1435     if (defined($section_name_map->{$node_text})) {
1436       ($node_id, $node_xhtml_id) = @{$section_name_map->{$node_text}};
1437     } else {
1438       print STDERR "WARNING: Unable to find node '$node_text' in book $map_name.\n";
1439     }
1440   }
1441
1442   if (defined $file) {
1443     $href = &$default_external_href($node, $node_id, $node_xhtml_id, lc_last($file));
1444     $href = remove_unneeded_anchor($href);
1445
1446     if ($web_manual) {
1447       my $only_web_version = $ENV{ONLY_WEB_VERSION};
1448       if ($only_web_version) {
1449         $href = "../../doc/".$only_web_version."/Documentation/web/".$href;
1450       }
1451     }
1452
1453     return $href;
1454   } else {
1455     $href = &$default_external_href($node, $node_id, $node_xhtml_id);
1456     $href = remove_unneeded_anchor($href);
1457     return $href;
1458   }
1459 }
1460
1461 sub remove_unneeded_anchor($)
1462 {
1463   my $href = shift;
1464   my @hrefsplit = split("/", $href);
1465   for ($i = 0; $i < @hrefsplit; $i++) {
1466     $item = @hrefsplit[$i];
1467     if ($item =~ /#/) {
1468       @split = split(".html#", $item);
1469       if (@split[0] eq @split[1]) {
1470         @hrefsplit[$i] = @split[0] . ".html";
1471       }
1472     }
1473   }
1474   $href = join("/", @hrefsplit);
1475   return $href
1476 }
1477
1478
1479
1480 #############################################################################
1481 ###  CUSTOM TOC FOR EACH PAGE (in a frame on the left)
1482 #############################################################################
1483
1484 my $page_toc_depth = 2;
1485 my @default_toc = [];
1486
1487 # Initialize the toc_depth to 1 if the command-line option -D=short_toc is given
1488 sub lilypond_init_toc_depth ()
1489 {
1490   if (exists($main::value{'short_toc'}) and not exists($main::value{'bigpage'})
1491       and not $web_manual) {
1492     $page_toc_depth = 1;
1493   }
1494 }
1495 # Set the TOC-depth (depending on a texinfo variable short_toc) in a
1496 # command-handler, so we have them available when creating the pages
1497 push @Texi2HTML::Config::command_handler_process, \&lilypond_init_toc_depth;
1498
1499
1500
1501 # recursively generate the TOC entries for the element and its children (which
1502 # are only shown up to maxlevel. All ancestors of the current element are also
1503 # shown with their immediate children, irrespective of their level.
1504 # Unnumbered entries are only printed out if they are at top-level or 2nd level
1505 # or their parent element is an ancestor of the currently viewed node.
1506 # The conditions to call this method to print the entry for a child node is:
1507 # -) the parent is an ancestor of the current page node
1508 # -) the parent is a numbered element at top-level toplevel (i.e. show numbered
1509 #    and unnumbered 2nd-level children of numbered nodes)
1510 # -) the child element is a numbered node below level maxlevel
1511 sub generate_ly_toc_entries($$$$$)
1512 {
1513   my $element = shift;
1514   my $element_path = shift;
1515   my $maxlevel = shift;
1516   if ($web_manual) {
1517     $maxlevel = 1;
1518   }
1519   my $child_count = shift;
1520   my $current_element = shift;
1521   # Skip undefined sections, plus all sections generated by index splitting
1522   return() if (not defined($element) or exists($element->{'index_page'}));
1523   my @result = ();
1524   my $level = $element->{'toc_level'};
1525   my $is_parent_of_current = $element->{'id'} && $element_path->{$element->{'id'}};
1526   my $ind = '  ' x $level;
1527   my $this_css_class = " class=\"";
1528   # color indices for the second navigation bar on the website
1529   if ($web_manual) {
1530       my %color_maps = (
1531           'introduction' => [2, 2, 2, 2, 3, 3, 4, 4],
1532           'download' => [2, 2, 2, 3, 3, 4],
1533           'manuals' => [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4],
1534           'community' => [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4],
1535           );
1536       my $addColor = "colorDefault";
1537       while (($top_section, $color_indices) = each %color_maps) {
1538           if (index ($element->{'sectionup'}->{'file'}, $top_section) >= 0) {
1539               $addColor = "color" . $color_indices->[$child_count];
1540           }
1541       }
1542       $this_css_class .= $addColor;
1543   }
1544   $this_css_class .= $is_parent_of_current ? ' toc_current"' : '"';
1545   my $entry = "$ind<li$this_css_class>" .
1546       &$anchor ($element->{'tocid'},
1547                 "$element->{'file'}#$element->{'target'}",
1548                 $element->{'text'});
1549
1550   push (@result, $entry);
1551   my $children = $element->{'section_childs'};
1552   if (defined($children) and (ref($children) eq "ARRAY")) {
1553     my $force_children = $is_parent_of_current or ($level == 1 and $element->{'number'});
1554     my @child_result = ();
1555     my $sub_child_count = 0;
1556     foreach my $c (@$children) {
1557       my $is_numbered_child = defined ($c->{'number'});
1558       my $below_maxlevel = $c->{'toc_level'} le $maxlevel;
1559       if ($force_children or ($is_numbered_child and $below_maxlevel)) {
1560         my @child_res =
1561             generate_ly_toc_entries($c, $element_path, $maxlevel, $sub_child_count, $current_element);
1562         push (@child_result, @child_res);
1563         $sub_child_count += 1;
1564       }
1565     }
1566     # if no child nodes were generated, e.g. for the index, where expanded pages
1567     # are ignored, don't generate a list at all...
1568     if (@child_result) {
1569       push (@result, "\n$ind<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
1570       if ($web_manual) {
1571         push (@result, "$ind<li class=\"colorDefault" .
1572               ($element->{'text'} eq $current_element->{'text'} ?
1573                ' toc_current">' : '">') .
1574               &$anchor ($element->{'tocid'},
1575                         "$element->{'file'}#$element->{'target'}",
1576                         $element->{'text'}) . "</li>\n");
1577       }
1578       push (@result, @child_result);
1579       push (@result, "$ind</ul>\n");
1580     }
1581   }
1582   push (@result, "$ind</li>\n");
1583   return @result;
1584 }
1585
1586
1587 # Print a customized TOC, containing only the first two levels plus the whole
1588 # path to the current page
1589 sub lilypond_generate_page_toc_body($)
1590 {
1591     my $element = shift;
1592     my $current_element = $element;
1593     my %parentelements;
1594     $parentelements{$element->{'id'}} = 1;
1595     # Find the path to the current element
1596     while ( defined($current_element->{'sectionup'}) and
1597            ($current_element->{'sectionup'} ne $current_element) )
1598     {
1599       $parentelements{$current_element->{'sectionup'}->{'id'}} = 1
1600               if ($current_element->{'sectionup'}->{'id'} ne '');
1601       $current_element = $current_element->{'sectionup'};
1602       if ($web_manual) {
1603         if (exists($main::value{'shallow_toc'})) {
1604           last;
1605         }
1606       }
1607     }
1608     return () if not defined($current_element);
1609     # Create the toc entries recursively
1610     my @toc_entries = "";
1611     if ($web_manual) {
1612         @toc_entries = "<ul$NO_BULLET_LIST_ATTRIBUTE>\n";
1613         # FIXME: add link to main page, really hackily.
1614         if ($element->{'sectionup'}) {
1615             # it's not the top element
1616             push (@toc_entries, "<li><a href=\"index.html\">Main</a></li>\n");
1617         } else {
1618             push (@toc_entries,
1619                   "<li class=\"toc_current\"><a href=\"index.html\">Main</a></li>\n");
1620         }
1621     } else {
1622         push (@toc_entries, "<div class=\"contents\">\n");
1623         push (@toc_entries, "<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
1624     }
1625     my $children = $current_element->{'section_childs'};
1626     foreach ( @$children ) {
1627       push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth, 0, $element));
1628     }
1629     # search box
1630     #  I'm assuming that we wouldn't keep the google search box? -gp
1631     if (!($ENV{AJAX_SEARCH} == 1)) {
1632       local $/=undef;
1633       my $name = "search-box";
1634       $lang = $Texi2HTML::THISDOC{current_lang};
1635       open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$lang/$name.ihtml" or
1636         open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$name.ihtml"  or
1637         die "no such file: $name.ihtml: $!";
1638       my $search_string = decode ('UTF-8', <FILE>);
1639       $search_string = "<li>\n" . $search_string . "</li>\n";
1640       push (@toc_entries, $search_string);
1641       close FILE;
1642     }
1643
1644     push (@toc_entries, "</ul>\n");
1645     if ($web_manual) {
1646         push (@toc_entries, "\n");
1647     } else {
1648         push (@toc_entries, "</div>\n");
1649     }
1650     return @toc_entries;
1651 }
1652
1653 sub lilypond_print_toc_div ($$)
1654 {
1655   my $fh = shift;
1656   my $tocref = shift;
1657   my @lines = @$tocref;
1658   # use default TOC if no custom lines have been generated
1659   @lines = @default_toc if (not @lines);
1660   if (@lines) {
1661
1662     print $fh "\n\n<div id=\"tocframe\">\n";
1663
1664     # Remove the leading "GNU LilyPond --- " from the manual title
1665     my $topname = $Texi2HTML::NAME{'Top'};
1666     $topname =~ s/^GNU LilyPond(:| &[mn]dash;) //;
1667
1668     # construct the top-level Docs index (relative path and including language!)
1669     my $lang = $Texi2HTML::THISDOC{current_lang};
1670     if ($lang and $lang ne "en") {
1671       $lang .= ".";
1672     } else {
1673       $lang = "";
1674     }
1675     my $reldir = $ENV{DEPTH};
1676     # strip one depth level for translations
1677     if ($lang and $lang ne "en" and substr ($reldir, 0, 3) eq '../') {
1678         $reldir = substr ($reldir, 3);
1679     }
1680     # add a / at the end if there isn't one.
1681     if (substr ($reldir, -1) ne '/') {
1682         $reldir .= '/';
1683     }
1684     my $uplink = $reldir."Documentation/web/manuals.${lang}html";
1685
1686     if (not $web_manual) {
1687       print $fh "<p class=\"toc_uplink\"><a href=\"$uplink\"
1688          title=\"Documentation Index\">&lt;&lt; " .
1689          &ly_get_string ('Back to Documentation Index') .
1690          "</a></p>\n";
1691
1692       # AJAX search box, written in JavaScript
1693       if ($ENV{'AJAX_SEARCH'} == 1) {
1694         if ($have_index_entries) {
1695           my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1696           print $fh '<script language="JavaScript">print_search_field ("' .
1697              $Texi2HTML::THISDOC{current_lang} . '", "' . 
1698              $docu_name . "\", " . $bigpage . ")</script>\n";
1699         }
1700       }
1701
1702       print $fh '<h4 class="toc_header"> ' . &$anchor('',
1703                                     $Texi2HTML::HREF{'Top'},
1704                                     $topname . " <!-- Sidebar Version Tag  --> ",
1705                                     'title="Start of the manual"'
1706                                    ) . "</h4>\n";
1707     }
1708
1709     foreach my $line (@lines) {
1710       print $fh $line;
1711     }
1712     print $fh "</div>\n\n";
1713   }
1714 }
1715
1716 # Create the custom TOC for this page (partially folded, current page is
1717 # highlighted) and store it in a global variable. The TOC is written out after
1718 # the html contents (but positioned correctly using CSS), so that browsers with
1719 # css turned off still show the contents first.
1720 our @this_page_toc = ();
1721 sub lilypond_print_element_header
1722 {
1723   my $first_in_page = shift;
1724   my $previous_is_top = shift;
1725   if ($first_in_page and not @this_page_toc) {
1726     if (defined($Texi2HTML::THIS_ELEMENT)) {
1727       # Create the TOC for this page
1728       @this_page_toc = lilypond_generate_page_toc_body($Texi2HTML::THIS_ELEMENT);
1729     }
1730   }
1731   return &$default_print_element_header( $first_in_page, $previous_is_top);
1732 }
1733
1734 # Generate the HTML output for the TOC
1735 sub lilypond_toc_body($)
1736 {
1737     my $elements_list = shift;
1738     # Generate a default TOC for pages without THIS_ELEMENT
1739     @default_toc = lilypond_generate_page_toc_body(@$elements_list[0]);
1740     return &$default_toc_body($elements_list);
1741 }
1742
1743 # Print out the TOC in a <div> at the beginning of the page
1744 sub lilypond_print_page_head($)
1745 {
1746     my $fh = shift;
1747     &$default_print_page_head($fh);
1748     print $fh "<div id=\"main\">\n";
1749 }
1750
1751 # Print out the TOC in a <div> at the end of th page, which will be formatted as a
1752 # sidebar mimicking a TOC frame
1753 sub print_lilypond_page_foot($)
1754 {
1755   my $fh = shift;
1756   my $program_string = &$program_string();
1757 #   print $fh "<p><font size='-1'>$program_string</font><br>$PRE_BODY_CLOSE</p>\n";
1758   print $fh "<!-- FOOTER -->\n\n";
1759   print $fh "<!-- end div#main here -->\n</div>\n\n";
1760   if ($web_manual) {
1761     # FIXME: This div and p#languages need to be in div#footer.
1762     #        Should we move this div to postprocess_html.py ?
1763     print $fh "<div id=\"verifier_texinfo\">\n";
1764     print $fh "<h3>Validation</h3>\n";
1765     # FIXME: inlined text substitution, move to ly_get_string as soon as another case is needed
1766     my $webdev_link = "<a href=\"http://www.webdev.nl/\">webdev.nl</a>";
1767     my $lily_site = "<code>lilypond.org</code>";
1768     my $hosting_thanks = &ly_get_string ('<p>Thanks to ${webdev_link} for hosting ${lily_site}.');
1769     # this does the variable substitution ("quoting" in Perlish) after the localization
1770     $hosting_thanks =~ s/(\$\{\w+\})/$1/eeg;
1771     print $fh $hosting_thanks . "\n";
1772     print $fh "<a href=\"http://validator.w3.org/check?uri=referer\">\n";
1773     print $fh "<img src=\"http://www.w3.org/Icons/valid-html401\"\n";
1774     print $fh "     alt=\"Valid HTML 4.01 Transitional\"\n";
1775     print $fh "     height=\"31\" width=\"88\"></a></p>\n";
1776     print $fh "</div>";
1777   }
1778
1779   # Print the TOC frame and reset the TOC:
1780   lilypond_print_toc_div ($fh, \@this_page_toc);
1781   @this_page_toc = ();
1782
1783   # Close the page:
1784   print $fh "</body>\n</html>\n";
1785 }
1786
1787
1788
1789
1790
1791 #############################################################################
1792 ###  NICER / MORE FLEXIBLE NAVIGATION PANELS
1793 #############################################################################
1794
1795 sub get_navigation_text
1796 {
1797   my $button = shift;
1798   my $text = $NAVIGATION_TEXT{$button};
1799   if ( ($button eq 'Back') or ($button eq 'FastBack') ) {
1800     $text = $text . $Texi2HTML::NODE{$button} . "&nbsp;";
1801   } elsif ( ($button eq 'Forward') or ($button eq 'FastForward') ) {
1802     $text = "&nbsp;" . $Texi2HTML::NODE{$button} . $text;
1803   } elsif ( $button eq 'Up' ) {
1804     $text = "&nbsp;".$text.":&nbsp;" . $Texi2HTML::NODE{$button} . "&nbsp;";
1805   }
1806   return $text;
1807 }
1808
1809
1810 # Don't automatically create left-aligned table cells for every link, but
1811 # instead create a <td> only on an appropriate '(left|right|center)-aligned-cell-n'
1812 # button text. It's alignment as well as the colspan will be taken from the
1813 # name of the button. Also, add 'newline' button text to create a new table
1814 # row. The texts of the buttons are generated by get_navigation_text and
1815 # will contain the name of the next/previous section/chapter.
1816 sub lilypond_print_navigation
1817 {
1818     my $buttons = shift;
1819     my $vertical = shift;
1820     my $spacing = 1;
1821     my $result = "<table class=\"nav_table\">\n";
1822
1823     $result .= "<tr>" unless $vertical;
1824     my $beginofline = 1;
1825     foreach my $button (@$buttons)
1826     {
1827         $result .= qq{<tr valign="top" align="left">\n} if $vertical;
1828         # Allow (left|right|center)-aligned-cell and newline as buttons!
1829         if ( $button =~ /^(.*)-aligned-cell-(.*)$/ )
1830         {
1831           $result .= qq{</td>} unless $beginofline;
1832           $result .= qq{<td valign="middle" align="$1" colspan="$2">};
1833           $beginofline = 0;
1834         }
1835         elsif ( $button eq 'newline' )
1836         {
1837           $result .= qq{</td>} unless $beginofline;
1838           $result .= qq{</tr>};
1839           $result .= qq{<tr>};
1840           $beginofline = 1;
1841
1842         }
1843         elsif (ref($button) eq 'CODE')
1844         {
1845             $result .= &$button($vertical);
1846         }
1847         elsif (ref($button) eq 'SCALAR')
1848         {
1849             $result .= "$$button" if defined($$button);
1850         }
1851         elsif (ref($button) eq 'ARRAY')
1852         {
1853             my $text = $button->[1];
1854             my $button_href = $button->[0];
1855             # verify that $button_href is simple text and text is a reference
1856             if (defined($button_href) and !ref($button_href)
1857                and defined($text) and (ref($text) eq 'SCALAR') and defined($$text))
1858             {             # use given text
1859                 if ($Texi2HTML::HREF{$button_href})
1860                 {
1861                   my $anchor_attributes = '';
1862                   if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button_href})) and
1863                       ($BUTTONS_ACCESSKEY{$button_href} ne ''))
1864                   {
1865                       $anchor_attributes = "accesskey=\"$BUTTONS_ACCESSKEY{$button_href}\"";
1866                   }
1867                   if ($USE_REL_REV and (defined($BUTTONS_REL{$button_href})) and
1868                       ($BUTTONS_REL{$button_href} ne ''))
1869                   {
1870                       $anchor_attributes .= " rel=\"$BUTTONS_REL{$button_href}\"";
1871                   }
1872                   $result .=  "" .
1873                         &$anchor('',
1874                                     $Texi2HTML::HREF{$button_href},
1875                                     get_navigation_text($$text),
1876                                     $anchor_attributes
1877                                    );
1878                 }
1879                 else
1880                 {
1881                   $result .=  get_navigation_text($$text);
1882                 }
1883             }
1884         }
1885         elsif ($button eq ' ')
1886         {                       # handle space button
1887             $result .=
1888                 ($ICONS && $ACTIVE_ICONS{' '}) ?
1889                     &$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{' '}) :
1890                         $NAVIGATION_TEXT{' '};
1891             #next;
1892         }
1893         elsif ($Texi2HTML::HREF{$button})
1894         {                       # button is active
1895             my $btitle = $BUTTONS_GOTO{$button} ?
1896                 'title="' . $BUTTONS_GOTO{$button} . '"' : '';
1897             if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button})) and
1898                 ($BUTTONS_ACCESSKEY{$button} ne ''))
1899             {
1900                 $btitle .= " accesskey=\"$BUTTONS_ACCESSKEY{$button}\"";
1901             }
1902             if ($USE_REL_REV and (defined($BUTTONS_REL{$button})) and
1903                 ($BUTTONS_REL{$button} ne ''))
1904             {
1905                 $btitle .= " rel=\"$BUTTONS_REL{$button}\"";
1906             }
1907             if ($ICONS && $ACTIVE_ICONS{$button})
1908             {                   # use icon
1909                 $result .= '' .
1910                     &$anchor('',
1911                         $Texi2HTML::HREF{$button},
1912                         &$button_icon_img($BUTTONS_NAME{$button},
1913                                    $ACTIVE_ICONS{$button},
1914                                    $Texi2HTML::SIMPLE_TEXT{$button}),
1915                         $btitle
1916                       );
1917             }
1918             else
1919             {                   # use text
1920                 $result .=
1921                     '[' .
1922                         &$anchor('',
1923                                     $Texi2HTML::HREF{$button},
1924                                     get_navigation_text($button),
1925                                     $btitle
1926                                    ) .
1927                                        ']';
1928             }
1929         }
1930         else
1931         {                       # button is passive
1932             $result .=
1933                 $ICONS && $PASSIVE_ICONS{$button} ?
1934                     &$button_icon_img($BUTTONS_NAME{$button},
1935                                           $PASSIVE_ICONS{$button},
1936                                           $Texi2HTML::SIMPLE_TEXT{$button}) :
1937
1938                                               "[" . get_navigation_text($button) . "]";
1939         }
1940         $result .= "</td>\n" if $vertical;
1941         $result .= "</tr>\n" if $vertical;
1942     }
1943     $result .= "</td>" unless $beginofline;
1944     $result .= "</tr>" unless $vertical;
1945     $result .= "</table>\n";
1946     if ($web_manual) {
1947       return "\n";
1948     } else {
1949       return $result;
1950     }
1951 }
1952
1953
1954 @Texi2HTML::Config::SECTION_BUTTONS =
1955     ('left-aligned-cell-1', 'FastBack',
1956      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1957      'right-aligned-cell-1', 'FastForward',
1958      'newline',
1959      'left-aligned-cell-2', 'Back',
1960      'center-aligned-cell-1', 'Up',
1961      'right-aligned-cell-2', 'Forward'
1962     );
1963
1964 # buttons for misc stuff
1965 @Texi2HTML::Config::MISC_BUTTONS = ('center-aligned-cell-3',
1966                                     'Top', 'Contents', 'Index', 'About');
1967
1968 # buttons for chapter file footers
1969 # (and headers but only if SECTION_NAVIGATION is false)
1970 @Texi2HTML::Config::CHAPTER_BUTTONS =
1971     ('left-aligned-cell-1', 'FastBack',
1972      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1973      'right-aligned-cell-1', 'FastForward',
1974     );
1975
1976 # buttons for section file footers
1977 @Texi2HTML::Config::SECTION_FOOTER_BUTTONS =
1978     ('left-aligned-cell-1', 'FastBack',
1979      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1980      'right-aligned-cell-1', 'FastForward',
1981      'newline',
1982      'left-aligned-cell-2', 'Back',
1983      'center-aligned-cell-1', 'Up',
1984      'right-aligned-cell-2', 'Forward'
1985     );
1986
1987 @Texi2HTML::Config::NODE_FOOTER_BUTTONS =
1988     ('left-aligned-cell-1', 'FastBack',
1989      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1990      'right-aligned-cell-1', 'FastForward',
1991      'newline',
1992      'left-aligned-cell-2', 'Back',
1993      'center-aligned-cell-1', 'Up',
1994      'right-aligned-cell-2', 'Forward'
1995     );
1996
1997
1998
1999
2000
2001 #############################################################################
2002 ###  FOOTNOTE FORMATTING
2003 #############################################################################
2004
2005 # Format footnotes in a nicer way: Instead of printing the number in a separate
2006 # (nr) heading line, use the standard way of prepending <sup>nr</sup> immediately
2007 # before the fn text.
2008
2009
2010 # The following code is copied from texi2html's examples/makeinfo.init and
2011 # should be updated when texi2html makes some changes there!
2012
2013 my $makekinfo_like_footnote_absolute_number = 0;
2014
2015 sub makeinfo_like_foot_line_and_ref($$$$$$$$)
2016 {
2017     my $foot_num = shift;
2018     my $relative_num = shift;
2019     my $footid = shift;
2020     my $docid = shift;
2021     my $from_file = shift;
2022     my $footnote_file = shift;
2023     my $lines = shift;
2024     my $state = shift;
2025
2026     $makekinfo_like_footnote_absolute_number++;
2027
2028     # this is a bit obscure, this allows to add an anchor only if formatted
2029     # as part of the document.
2030     $docid = '' if ($state->{'outside_document'} or $state->{'multiple_pass'});
2031
2032     if ($from_file eq $footnote_file)
2033     {
2034         $from_file = $footnote_file = '';
2035     }
2036
2037     my $foot_anchor = "<sup>" .
2038         &$anchor($docid, "$footnote_file#$footid", $relative_num) . "</sup>";
2039     $foot_anchor = &$anchor($docid,
2040                             "$footnote_file#$footid",
2041                             "($relative_num)") if ($state->{'preformatted'});
2042
2043 #    unshift @$lines, "<li>";
2044 #    push @$lines, "</li>\n";
2045     return ($lines, $foot_anchor);
2046 }
2047
2048 sub makeinfo_like_foot_lines($)
2049 {
2050     my $lines = shift;
2051     unshift @$lines, "<hr>\n<h4>$Texi2HTML::I18n::WORDS->{'Footnotes_Title'}</h4>\n";
2052 #<ol type=\"1\">\n";
2053 #    push @$lines, "</ol>";
2054     return $lines;
2055 }
2056
2057 my %makekinfo_like_paragraph_in_footnote_nr;
2058
2059 sub makeinfo_like_paragraph ($$$$$$$$$$$$$)
2060 {
2061     my $text = shift;
2062     my $align = shift;
2063     my $indent = shift;
2064     my $paragraph_command = shift;
2065     my $paragraph_command_formatted = shift;
2066     my $paragraph_number = shift;
2067     my $format = shift;
2068     my $item_nr = shift;
2069     my $enumerate_style = shift;
2070     my $number = shift;
2071     my $command_stack_at_end = shift;
2072     my $command_stack_at_begin = shift;
2073     my $state = shift;
2074 #print STDERR "format: $format\n" if (defined($format));
2075 #print STDERR "paragraph @$command_stack_at_end; @$command_stack_at_begin\n";
2076     $paragraph_command_formatted = '' if (!defined($paragraph_command_formatted) or
2077           exists($special_list_commands{$format}->{$paragraph_command}));
2078     return '' if ($text =~ /^\s*$/);
2079     foreach my $style(t2h_collect_styles($command_stack_at_begin))
2080     {
2081        $text = t2h_begin_style($style, $text);
2082     }
2083     foreach my $style(t2h_collect_styles($command_stack_at_end))
2084     {
2085        $text = t2h_end_style($style, $text);
2086     }
2087     if (defined($paragraph_number) and defined($$paragraph_number))
2088     {
2089          $$paragraph_number++;
2090          return $text  if (($format eq 'itemize' or $format eq 'enumerate') and
2091             ($$paragraph_number == 1));
2092     }
2093     # The cells of a table should not be wrapped in a <p> tag, so just return the text
2094     if (defined($command_stack_at_begin->[0]) and $command_stack_at_begin->[0] eq 'multitable')
2095     {
2096         return $text;
2097     }
2098
2099     # Adjust all footnotes so that they look like good old makeinfo
2100     my $open = '<p';
2101     if ($align)
2102     {
2103         $open .= " align=\"$paragraph_style{$align}\"";
2104     }
2105     my $footnote_text = '';
2106     if (defined($command_stack_at_begin->[0]) and $command_stack_at_begin->[0] eq 'footnote')
2107     {
2108         my $state = $Texi2HTML::THISDOC{'state'};
2109         $makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number}++;
2110         if ($makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number} <= 1)
2111         {
2112            $open.=' class="footnote"';
2113            my $document_file = $state->{'footnote_document_file'};
2114            if ($document_file eq $state->{'footnote_footnote_file'})
2115            {
2116                $document_file = '';
2117            }
2118            my $docid = $state->{'footnote_place_id'};
2119            my $doc_state = $state->{'footnote_document_state'};
2120            $docid = '' if ($doc_state->{'outside_document'} or $doc_state->{'multiple_pass'});
2121            my $foot_label = &$anchor($state->{'footnote_footnote_id'},
2122                  $document_file . "#$state->{'footnote_place_id'}",
2123                  "$state->{'footnote_number_in_page'}");
2124            $footnote_text = "<small>[${foot_label}]</small> ";
2125         }
2126     }
2127     return $open.'>'.$footnote_text.$text.'</p>';
2128 }
2129
2130
2131 #############################################################################
2132 ###  WRITING OUT THE INDEX FOR THE AJAX SEARCH FIELD
2133 #############################################################################
2134
2135 $Texi2HTML::Config::IDX_SUMMARY   = 1;
2136 $Texi2HTML::Config::init_out                  = \&lilypond_init_out;
2137 $Texi2HTML::Config::finish_out                = \&lilypond_finish_out;
2138 $Texi2HTML::Config::index_summary_file_entry  = \&lilypond_index_summary_file_entry;
2139
2140 my @index_entries;
2141
2142 sub lilypond_init_out ()
2143 {
2144   t2h_default_init_out ();
2145   # Check whether we have an index at all! If not -> don't print out a search box!
2146   my $ix = main::get_index ("cp");
2147   $have_index_entries = (scalar $ix > 0);
2148 }
2149
2150 sub lilypond_index_summary_file_entry ($$$$$$$$$)
2151 {
2152   my $index_name = shift;
2153   my $entry_text = shift;
2154   my $entry_reference = shift;
2155   my $formatted_entry = shift;
2156   my $texi_entry = shift;
2157   my $entry_element_reference = shift;
2158   my $entry_element_header = shift;
2159   my $is_printed = shift;
2160   my $manual_name = shift;
2161
2162   if ($ENV{'AJAX_SEARCH'}==1) {
2163     if ($index_name eq "cp")
2164     {
2165       # The entries in the index file have the form:
2166       # SearchText \t FormattedText \t EntryURL \t SectionText \t SectionURL
2167       push @index_entries, "$entry_text\t$formatted_entry\t$entry_reference\t$entry_element_header\t$entry_element_reference\n";
2168     }
2169   }
2170 }
2171
2172 sub lilypond_finish_out ()
2173 {
2174   if ($ENV{'AJAX_SEARCH'}==1) {
2175     if (((scalar @index_entries) > 0) and $have_index_entries) {
2176       my $lang = $Texi2HTML::THISDOC{current_lang};
2177       my $big = "";
2178       $big = "-big-page" if $bigpage;
2179       my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
2180       my $idx_file = "$docu_dir/$docu_name$big.$lang.idx";
2181       open IDXOUTFILE, ">:utf8", $idx_file;
2182       print IDXOUTFILE @index_entries;
2183       close IDXOUTFILE;
2184     }
2185   }
2186 }
2187
2188
2189
2190 #############################################################################
2191 ###  OTHER SETTINGS
2192 #############################################################################
2193
2194 # For split pages, use index.html as start page!
2195 if ($Texi2HTML::Config::SPLIT eq 'section' or
2196     $Texi2HTML::Config::SPLIT eq 'node') {
2197   $Texi2HTML::Config::TOP_FILE = 'index.html';
2198 }
2199
2200
2201 return 1;