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