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