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