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