]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/lilypond-texi2html.init
Doc: [web] Make texi2html notice non-constant, refactor cut-and-paste coding.
[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::element_target_name  = \&lilypond_element_target_name;
592 $default_print_element_header = $Texi2HTML::Config::print_element_header;
593 $Texi2HTML::Config::print_element_header = \&lilypond_print_element_header;
594 $Texi2HTML::Config::print_page_foot      = \&print_lilypond_page_foot;
595 $Texi2HTML::Config::print_navigation     = \&lilypond_print_navigation;
596 $Texi2HTML::Config::external_ref         = \&lilypond_external_ref;
597 $default_external_href = $Texi2HTML::Config::external_href;
598 $Texi2HTML::Config::external_href        = \&lilypond_external_href;
599 $default_toc_body = $Texi2HTML::Config::toc_body;
600 $Texi2HTML::Config::toc_body             = \&lilypond_toc_body;
601 $Texi2HTML::Config::css_lines            = \&lilypond_css_lines;
602 $default_unknown = $Texi2HTML::Config::unknown;
603 $Texi2HTML::Config::unknown              = \&lilypond_unknown;
604 $default_print_page_head = $Texi2HTML::Config::print_page_head;
605 $Texi2HTML::Config::print_page_head      = \&lilypond_print_page_head;
606 # $Texi2HTML::Config::foot_line_and_ref    = \&lilypond_foot_line_and_ref;
607 $Texi2HTML::Config::foot_line_and_ref  = \&makeinfo_like_foot_line_and_ref;
608 $Texi2HTML::Config::foot_lines         = \&makeinfo_like_foot_lines;
609 $Texi2HTML::Config::paragraph          = \&makeinfo_like_paragraph;
610
611
612
613 # Examples should be formatted similar to quotes:
614 $Texi2HTML::Config::complex_format_map->{'example'} = {
615   'begin' => q{"<blockquote>"},
616   'end' => q{"</blockquote>\n"},
617   'style' => 'code',
618  };
619
620 %Texi2HTML::config::misc_pages_targets = (
621    'Overview' => 'Overview',
622    'Contents' => 'Contents',
623    'About' => 'About'
624 );
625
626
627 my @section_to_filename;
628
629
630
631
632 #############################################################################
633 ###  DEBUGGING
634 #############################################################################
635
636 use Data::Dumper;
637 $Data::Dumper::Maxdepth = 2;
638
639 sub print_element_info($)
640 {
641   my $element = shift;
642   print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
643   print "Element: $element\n";
644   print Dumper($element);
645 }
646
647
648
649
650
651 #############################################################################
652 ###  HELPER FUNCTIONS
653 #############################################################################
654
655 # only lc() the last portion of an href
656 sub lc_last($)
657 {
658   my $href = shift;
659   my @hrefsplit = split('/', $href);
660   # change the last portion (the filename), if it exists
661   if ($#hrefsplit > 0) {
662     @hrefsplit[$#hrefsplit] = lc( @hrefsplit[$#hrefsplit] );
663     $href = join("/", @hrefsplit);
664   }
665   return $href;
666 }
667
668 # Convert a given node name to its proper file name (normalization as explained
669 # in the texinfo manual:
670 # http://www.gnu.org/software/texinfo/manual/texinfo/html_node/HTML-Xref-Node-Name-Expansion.html
671 sub texinfo_file_name($)
672 {
673   my $text = shift;
674   my $result = '';
675   # File name normalization by texinfo:
676   # 1/2: letters and numbers are left unchanged
677   # 3/4: multiple, leading and trailing whitespace is removed
678   $text = main::normalise_space($text);
679   # 5/6: all remaining spaces are converted to '-', all other 7- or 8-bit
680   #      chars are replaced by _xxxx (xxxx=ascii character code)
681   while ($text ne '') {
682     if ($text =~ s/^([A-Za-z0-9]+)//o) { # number or letter stay unchanged
683       $result .= $1;
684     } elsif ($text =~ s/^ //o) { # space -> '-'
685       $result .= '-';
686     } elsif ($text =~ s/^(.)//o) { # Otherwise use _xxxx (ascii char code)
687       my $ccode = ord($1);
688       if ( $ccode <= 0xFFFF ) {
689         $result .= sprintf("_%04x", $ccode);
690       } else {
691         $result .= sprintf("__%06x", $ccode);
692       }
693     }
694   }
695   # 7: if name does not begin with a letter, prepend 't_g' (so it starts with a letter)
696   if ($result !~ /^[a-zA-Z]/) {
697     $result = 't_g' . $result;
698   }
699   # DONE
700   return lc_last($result)
701 }
702
703 # Load a file containing a nodename<=>filename map (tab-sepatared, i.e.
704 # NODENAME\tFILENAME\tANCHOR
705 # Returns a ref to a hash "Node title" => ["FilenameWithoutExt", "Anchor"]
706 sub load_map_file ($)
707 {
708   my $mapfile = shift;
709   my $node_map = ();
710
711   # For some unknown reason, Perl on my system (5.10.0 on Fedora 12)
712   # refuses to open map files of translated documents with
713   # '<:encoding(utf8)', but decoding from UTF-8 line by line works. -jm
714   if (open(XREFFILE,'<', $mapfile)) {
715     my $line;
716     # print STDERR "*** PRINTING MAP FILE LINES ***\n";
717     while ( $line = decode ('UTF-8', <XREFFILE>) ) {
718       # parse the tab-separated entries and insert them into the map:
719       chomp($line);
720       my @entries = split(/\t/, $line);
721       if (scalar (@entries) == 3) {
722         $node_map->{$entries[0]} = [$entries[1], $entries[2]];
723         $, = " ";
724         # print STDERR @entries;
725         # print STDERR "\n";
726       } else {
727         print STDERR "Invalid entry in the node file $mapfile: $line\n";
728       }
729     }
730     close (XREFFILE);
731   } else {
732     print STDERR "WARNING: Unable to load the map file $mapfile\n";
733   }
734   return $node_map;
735 }
736
737
738 # Split the given path into dir and basename (with .texi removed). Used mainly
739 # to get the path/basename of the original texi input file
740 sub split_texi_filename ($)
741 {
742   my $docu = shift;
743   my ($docu_dir, $docu_name);
744   if ($docu =~ /(.*\/)/) {
745     chop($docu_dir = $1);
746     $docu_name = $docu;
747     $docu_name =~ s/.*\///;
748   } else {
749      $docu_dir = '.';
750      $docu_name = $docu;
751   }
752   $docu_name =~ s/\.te?x(i|info)?$//;
753   return ($docu_dir, $docu_name);
754 }
755
756
757
758
759
760 #############################################################################
761 ###  CSS HANDLING
762 #############################################################################
763
764 # Include our standard CSS file, not hard-coded CSS code directly in the HTML!
765 # For IE, conditionally include the lilypond-ie-fixes.css style sheet
766 sub lilypond_css_lines ($$)
767 {
768   my $import_lines = shift;
769   my $rule_lines = shift;
770   return if (defined($Texi2HTML::THISDOC{'CSS_LINES'}));
771   if (@$rule_lines or @$import_lines)
772   {
773     $Texi2HTML::THISDOC{'CSS_LINES'} = "<style type=\"text/css\">\n<!--\n";
774     $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$import_lines) . "\n" if (@$import_lines);
775     $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$rule_lines) . "\n" if (@$rule_lines);
776     $Texi2HTML::THISDOC{'CSS_LINES'} .= "-->\n</style>\n";
777   }
778   foreach my $ref (@CSS_REFS)
779   {
780     $Texi2HTML::THISDOC{'CSS_LINES'} .=
781         "<link rel=\"stylesheet\" type=\"text/css\" title=\"$ref->{TITLE}\" href=\"$ref->{FILENAME}\">\n";
782   }
783   foreach my $ref (@Texi2HTML::Config::ALT_CSS_REFS)
784   {
785     $Texi2HTML::THISDOC{'CSS_LINES'} .=
786         "<link rel=\"alternate stylesheet\" type=\"text/css\" href=\"$ref->{FILENAME}\" title=\"$ref->{TITLE}\">\n";
787   }
788   # FIXME: the website doesn't use ie7-specific fixes; do the
789   # docs still need this?  -gp
790   $Texi2HTML::THISDOC{'CSS_LINES'} .=
791       "<!--[if lte IE 7]>\n<link href=\"lilypond-ie-fixes.css\" rel=\"stylesheet\" type=\"text/css\">\n<![endif]-->\n";
792 }
793
794
795
796
797
798 #############################################################################
799 ###  SPLITTING BASED ON NUMBERED SECTIONS
800 #############################################################################
801
802 my $lastfilename;
803 my $docnr = 0;
804 my $node_to_filename_map = ();
805 $source_to_translationof_map = ();
806
807
808 # This function makes sure that files are only generated for numbered sections,
809 # but not for unnumbered ones. It is called after texi2html has done its own
810 # splitting and simply returns the filename for the node given as first argument
811 # Nodes with the same filename will be printed out to the same filename, so
812 # this really all we need. Also, make sure that the file names for sections
813 # are derived from the section title. We also might want to name the anchors
814 # according to node titles, which works by simply overriding the id element of
815 # the $element hash.
816 # If an external nodename<=>filename/anchor map file is found (loaded in
817 # the command handler, use the externally created values, otherwise use the
818 # same logic here.
819 sub lilypond_element_file_name($$$)
820 {
821   my $element = shift;
822   my $type = shift;
823   my $docu_name = shift;
824   my $docu_ext = $Texi2HTML::Config::EXTENSION;
825
826   my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
827   # the snippets page does not use nodes for the snippets, so in this case
828   # we'll have to use the section name!
829   if ($node_name eq '') {
830     $node_name = main::remove_texi($element->{'texi'});
831   }
832
833   # If we have an entry in the section<=>filename map, use that one, otherwise
834   # generate the filename/anchor here. In the latter case, external manuals
835   # will not be able to retrieve the file name for xrefs!!! Still, I already
836   # had that code, so I'll leave it in in case something goes wrong with the
837   # extract_texi_filenames.py script in the lilypond build process!
838   if (exists ($node_to_filename_map->{$node_name})) {
839     (my $filename, my $anchor) = @{$node_to_filename_map->{$node_name}};
840     $filename .= ".$docu_ext" if (defined($docu_ext));
841     # don't do lc_last here, otherwise the colors are messed up!
842     $filename = lc($filename);
843
844     # unnumbered sections (except those at top-level!) always go to the same
845     # file as the previous numbered section
846     if (not ($web_manual) and not ($element->{number})
847         and not ($lastfilename eq '') and ($element->{level} > 1)) {
848       $filename = $lastfilename;
849     }
850     if (($filename eq $lastfilename)) {
851       $$element{doc_nr} = $docnr;
852     } else {
853       $docnr += 1;
854       $$element{doc_nr} = $docnr;
855       $lastfilename = $filename;
856     }
857     #print STDERR "Output file name: $filename\n";
858     $filename = lc_last($filename);
859     return $filename;
860
861   } elsif ($type eq "top" or $type eq "toc" or $type eq "doc" or
862            $type eq "stoc" or $type eq "foot" or $type eq "about") {
863     return;
864   } else {
865     print STDERR "WARNING: Node '$node_name' was NOT found in the map\n"
866         unless ($node_name eq '') or ($element->{'tag'} eq 'unnumberedsec')
867                or ($node_name =~ /NOT REALLY USED/);
868
869     # Numbered sections will get a filename Node_title, unnumbered sections will use
870     # the file name of the previous numbered section:
871     if (($element->{number}) or ($lastfilename eq '') or ($element->{level} == 1)) {
872       # normalize to the same file name as texinfo
873       if ($element->{translationof}) {
874         $node_name = main::remove_texi($element->{translationof});
875       }
876       my $filename = texinfo_file_name($node_name);
877       $filename .= ".$docu_ext" if (defined($docu_ext));
878       $filename = lc_last($filename);
879       $docnr += 1;
880       $$element{doc_nr} = $docnr;
881       $lastfilename = $filename;
882       print STDERR "File name: $filename\n";
883       return $filename;
884     } else {
885       $$element{doc_nr} = $docnr;
886       $filename = lc_last($filename);
887       print STDERR "File name: $filename\n";
888       return $filename;
889     }
890   }
891
892   return;
893 }
894
895 sub lilypond_normalise_node($)
896 {
897     my $text = shift;
898     my $norm = main::t2h_default_normalise_node($text);
899     if (exists ($source_to_translationof_map->{$text})) {
900         my $original = $source_to_translationof_map->{$text};
901         $norm = main::t2h_default_normalise_node($original);
902     }
903
904     return $norm;
905 }
906
907 sub lilypond_element_target_name($$$)
908 {
909   my $element = shift;
910   my $target = shift;
911   my $id = shift;
912   # Target is based on node name (or sec name for secs without node attached)
913   my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
914   if ($node_name eq '') {
915     $node_name = main::remove_texi($element->{'texi'});
916   }
917
918   # If we have an entry in the section<=>filename map, use that one, otherwise
919   # generate the anchor here.
920   if (exists ($node_to_filename_map->{$node_name})) {
921     (my $filename, $target) = @{$node_to_filename_map->{$node_name}};
922   } else {
923     my $anchor = $node_name;
924     if ($element->{translationof}) {
925       $anchor = main::remove_texi($element->{translationof});
926     }
927     # normalize to the same file name as texinfo
928     $target = texinfo_file_name($anchor);
929   }
930   # TODO: Once texi2html correctly prints out the target and not the id for
931   #       the sections, change this back to ($id, $target)
932   # I don't understand this comment, so I'm reluctant to delete it -gp
933   $target = lc_last($target);
934   if ($target eq lc_last($id)) {
935     $id = "";
936   } else {
937     $id = substr($id, 0, - 2); # remove the "-1"
938   }
939   return ($id, $target);
940 }
941
942
943 ## Load the map file for the corrently processed texi file. We do this
944 #  using a command init handler, since texi2html does not have any
945 #  other hooks that are called after THISDOC is filled but before phase 2
946 #  of the texi2html conversion.
947 sub lilypond_init_map ()
948 {
949     my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
950     my $map_filename = main::locate_include_file ("${docu_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
951         || main::locate_include_file ("${docu_name}.xref-map");
952     #print STDERR "Map filename is: $map_filename\nDocu name is $docu_name\n";
953     if ($docu_name eq 'web') {
954         $web_manual = 1;
955         web_settings();
956     }
957     $node_to_filename_map = load_map_file ($map_filename);
958 }
959 push @Texi2HTML::Config::command_handler_init, \&lilypond_init_map;
960
961
962
963 #############################################################################
964 ###  CLEANER LINK TITLE FOR EXTERNAL REFS
965 #############################################################################
966
967 # The default formatting of external refs returns e.g.
968 # "(lilypond-internals)Timing_translator", so we remove all (...) from the
969 # file_and_node argument. Also, we want only a very simple format, so we don't
970 # even call the default handler!
971 sub lilypond_external_ref($$$$$$)
972 {
973   my $type = shift;
974   my $section = shift;
975   my $book = shift;
976   my $file_node = shift;
977   my $href = shift;
978
979   $href = lc_last($href);
980
981   my $cross_ref = shift;
982
983   my $displaytext = '';
984
985   # 1) if we have a cross ref name, that's the text to be displayed:
986   # 2) For the top node, use the (printable) name of the manual, unless we
987   #    have an explicit cross ref name
988   # 3) In all other cases use the section name
989   if ($cross_ref ne '') {
990     $displaytext = $cross_ref;
991   } elsif (($section eq '') or ($section eq 'Top')) {
992     $displaytext = $book;
993   } else {
994     $displaytext = $section;
995   }
996
997   $displaytext = &$anchor('', $href, $displaytext) if ($displaytext ne '');
998   return &$I('%{node_file_href}', { 'node_file_href' => $displaytext });
999 }
1000
1001
1002
1003
1004
1005 #############################################################################
1006 ###  HANDLING TRANSLATED SECTIONS: handle @translationof, secname<->filename
1007 ###                  map stored on disk, xrefs in other manuals load that map
1008 #############################################################################
1009
1010
1011 # Try to make use of @translationof to generate files according to the original
1012 # English section title...
1013 sub lilypond_unknown($$$$$)
1014 {
1015     my $macro = shift;
1016     my $line = shift;
1017     my $pass = shift;
1018     my $stack = shift;
1019     my $state = shift;
1020
1021     # the @translationof macro provides the original English section title,
1022     # which should be used for file/anchor naming, while the title will be
1023     # translated to each language
1024     # It is already used by extract_texi_filenames.py, so this should not be
1025     # necessary here at all. Still, I'll leave the code in just in case the
1026     # python script messed up ;-)
1027     if ($pass == 1 and $macro eq "translationof") {
1028       if (ref($state->{'element'}) eq 'HASH') {
1029           $state->{'element'}->{'translationof'} = main::normalise_space($line);
1030           my $source = main::normalise_space ($line);
1031           if (ref($state->{'node_ref'}) eq 'HASH') {
1032               my $translationof = $state->{'node_ref'}->{'texi'};
1033               our %source_to_translationof_map;
1034               $source_to_translationof_map->{$source} = $translationof;
1035           }
1036       }
1037       return ('', 1, undef, undef);
1038     } else {
1039       return &$default_unknown($macro, $line, $pass, $stack, $state);
1040     }
1041 }
1042
1043
1044 my %translated_books = ();
1045 # Construct a href to an external source of information.
1046 # node is the node with texinfo @-commands
1047 # node_id is the node transliterated and transformed as explained in the
1048 #         texinfo manual
1049 # node_xhtml_id is the node transformed such that it is unique and can
1050 #     be used to make an html cross ref as explained in the texinfo manual
1051 # file is the file in '(file)node'
1052 sub lilypond_external_href($$$)
1053 {
1054   my $node = shift;
1055   my $node_id = shift;
1056   my $node_hxmlt_id = shift;
1057   my $file = shift;
1058
1059   # 1) Keep a hash of book->section_map
1060   # 2) if not file in keys hash => try to load the map (assign empty map if
1061   #    non-existent => will load only once!)
1062   # 3) if node in the section=>(file, anchor) map, replace node_id and
1063   #    node_xhtml_id by the map's values
1064   # 4) call the default_external_href with these values (or the old ones if not found)
1065
1066   if (($node_id ne '') and defined($file) and ($node_id ne 'Top')) {
1067     my $map_name = $file;
1068     $map_name =~ s/-big-page//;
1069
1070     # Load the map if we haven't done so already
1071     if (!exists($translated_books{$map_name})) {
1072       my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1073       my $map_filename = main::locate_include_file ("${map_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
1074           || main::locate_include_file ("${map_name}.xref-map");
1075       $translated_books{$map_name} = load_map_file ($map_filename);
1076     }
1077
1078     # look up translation. use these values instead of the old filename/anchor
1079     my $section_name_map = $translated_books{$map_name};
1080     my $node_text = main::remove_texi($node);
1081     if (defined($section_name_map->{$node_text})) {
1082       ($node_id, $node_hxmlt_id) = @{$section_name_map->{$node_text}};
1083     } else {
1084       print STDERR "WARNING: Unable to find node '$node_text' in book $map_name.\n";
1085     }
1086   }
1087
1088   if (defined $file) {
1089     $href = &$default_external_href($node, $node_id, $node_hxmlt_id, lc_last($file));
1090     remove_unneeded_anchor($href);
1091
1092     # TODO: very yucky, but will be fixed in issue 1004
1093     if ($web_manual) {
1094       my $only_web = $ENV{ONLY_WEB};
1095       if ($only_web) {
1096         $href = "../../doc/v2.13/Documentation/web/".$href;
1097       }
1098     }
1099
1100     return $href;
1101   } else {
1102     $href = &$default_external_href($node, $node_id, $node_hxmlt_id);
1103     remove_unneeded_anchor($href);
1104     return $href;
1105   }
1106 }
1107
1108 sub remove_unneeded_anchor($)
1109 {
1110   my $ref = shift;
1111   my @hrefsplit = split("/", $href);
1112   for ($i = 0; $i < @hrefsplit; $i++) {
1113     $item = @hrefsplit[$i];
1114     if ($item =~ /#/) {
1115       @splitted = split("#", $item);
1116       if (@splitted[0] == @splitted[1]) {
1117         @hrefsplit[$i] = @splitted[0]
1118       }
1119     }
1120   }
1121   $href = join("/", @hrefsplit);
1122   return $href
1123 }
1124
1125
1126
1127 #############################################################################
1128 ###  CUSTOM TOC FOR EACH PAGE (in a frame on the left)
1129 #############################################################################
1130
1131 my $page_toc_depth = 2;
1132 my @default_toc = [];
1133
1134 # Initialize the toc_depth to 1 if the command-line option -D=short_toc is given
1135 sub lilypond_init_toc_depth ()
1136 {
1137   if (exists($main::value{'short_toc'}) and not exists($main::value{'bigpage'})
1138       and not $web_manual) {
1139     $page_toc_depth = 1;
1140   }
1141 }
1142 # Set the TOC-depth (depending on a texinfo variable short_toc) in a
1143 # command-handler, so we have them available when creating the pages
1144 push @Texi2HTML::Config::command_handler_process, \&lilypond_init_toc_depth;
1145
1146
1147
1148 # recursively generate the TOC entries for the element and its children (which
1149 # are only shown up to maxlevel. All ancestors of the current element are also
1150 # shown with their immediate children, irrespective of their level.
1151 # Unnumbered entries are only printed out if they are at top-level or 2nd level
1152 # or their parent element is an ancestor of the currently viewed node.
1153 # The conditions to call this method to print the entry for a child node is:
1154 # -) the parent is an ancestor of the current page node
1155 # -) the parent is a numbered element at top-level toplevel (i.e. show numbered
1156 #    and unnumbered 2nd-level children of numbered nodes)
1157 # -) the child element is a numbered node below level maxlevel
1158 sub generate_ly_toc_entries($$$$$)
1159 {
1160   my $element = shift;
1161   my $element_path = shift;
1162   my $maxlevel = shift;
1163   if ($web_manual) {
1164     $maxlevel = 1;
1165   }
1166   my $child_count = shift;
1167   my $current_element = shift;
1168   # Skip undefined sections, plus all sections generated by index splitting
1169   return() if (not defined($element) or exists($element->{'index_page'}));
1170   my @result = ();
1171   my $level = $element->{'toc_level'};
1172   my $is_parent_of_current = $element->{'id'} && $element_path->{$element->{'id'}};
1173   my $ind = '  ' x $level;
1174   my $this_css_class = " class=\"";
1175   # color indices for the second navigation bar on the website
1176   if ($web_manual) {
1177       my %color_maps = (
1178           'introduction' => [2, 2, 2, 2, 3, 3, 4, 4],
1179           'download' => [2, 2, 2, 3, 3, 4],
1180           'manuals' => [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4],
1181           'community' => [1, 1, 1, 2, 2, 2, 3, 3],
1182           );
1183       my $addColor = "colorDefault";
1184       while (($top_section, $color_indices) = each %color_maps) {
1185           if (index ($element->{'sectionup'}->{'file'}, $top_section) >= 0) {
1186               $addColor = "color" . $color_indices->[$child_count];
1187           }
1188       }
1189       $this_css_class .= $addColor;
1190   }
1191   $this_css_class .= $is_parent_of_current ? ' toc_current"' : '"';
1192   my $entry = "$ind<li$this_css_class>" .
1193       &$anchor ($element->{'tocid'},
1194                 "$element->{'file'}#$element->{'target'}",
1195                 $element->{'text'});
1196
1197   push (@result, $entry);
1198   my $children = $element->{'section_childs'};
1199   if (defined($children) and (ref($children) eq "ARRAY")) {
1200     my $force_children = $is_parent_of_current or ($level == 1 and $element->{'number'});
1201     my @child_result = ();
1202     my $sub_child_count = 0;
1203     foreach my $c (@$children) {
1204       my $is_numbered_child = defined ($c->{'number'});
1205       my $below_maxlevel = $c->{'toc_level'} le $maxlevel;
1206       if ($force_children or ($is_numbered_child and $below_maxlevel)) {
1207         my @child_res =
1208             generate_ly_toc_entries($c, $element_path, $maxlevel, $sub_child_count, $current_element);
1209         push (@child_result, @child_res);
1210         $sub_child_count += 1;
1211       }
1212     }
1213     # if no child nodes were generated, e.g. for the index, where expanded pages
1214     # are ignored, don't generate a list at all...
1215     if (@child_result) {
1216       push (@result, "\n$ind<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
1217       if ($web_manual) {
1218         push (@result, "$ind<li class=\"colorDefault" .
1219               ($element->{'text'} eq $current_element->{'text'} ?
1220                ' toc_current">' : '">') .
1221               &$anchor ($element->{'tocid'},
1222                         "$element->{'file'}#$element->{'target'}",
1223                         $element->{'text'}) . "</li>\n");
1224       }
1225       push (@result, @child_result);
1226       push (@result, "$ind</ul>\n");
1227     }
1228   }
1229   push (@result, "$ind</li>\n");
1230   return @result;
1231 }
1232
1233
1234 # Print a customized TOC, containing only the first two levels plus the whole
1235 # path to the current page
1236 sub lilypond_generate_page_toc_body($)
1237 {
1238     my $element = shift;
1239     my $current_element = $element;
1240     my %parentelements;
1241     $parentelements{$element->{'id'}} = 1;
1242     # Find the path to the current element
1243     while ( defined($current_element->{'sectionup'}) and
1244            ($current_element->{'sectionup'} ne $current_element) )
1245     {
1246       $parentelements{$current_element->{'sectionup'}->{'id'}} = 1
1247               if ($current_element->{'sectionup'}->{'id'} ne '');
1248       $current_element = $current_element->{'sectionup'};
1249       if ($web_manual) {
1250         if (exists($main::value{'shallow_toc'})) {
1251           last;
1252         }
1253       }
1254     }
1255     return () if not defined($current_element);
1256     # Create the toc entries recursively
1257     my @toc_entries = "";
1258     if ($web_manual) {
1259         @toc_entries = "<ul$NO_BULLET_LIST_ATTRIBUTE>\n";
1260         # FIXME: add link to main page, really hackily.
1261         if ($element->{'sectionup'}) {
1262             # it's not the top element
1263             push (@toc_entries, "<li><a href=\"index.html\">Main</a></li>\n");
1264         } else {
1265             push (@toc_entries,
1266                   "<li class=\"toc_current\"><a href=\"index.html\">Main</a></li>\n");
1267         }
1268     } else {
1269         push (@toc_entries, "<div class=\"contents\">\n");
1270         push (@toc_entries, "<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
1271     }
1272     my $children = $current_element->{'section_childs'};
1273     foreach ( @$children ) {
1274       push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth, 0, $element));
1275     }
1276     # search box
1277     local $/=undef;
1278     my $name = "search-box";
1279     $lang = $Texi2HTML::THISDOC{current_lang};
1280     open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$lang/$name.ihtml" or
1281         open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$name.ihtml"  or
1282         die "no such file: $name.ihtml: $!";
1283     my $search_string = decode ('UTF-8', <FILE>);
1284     $search_string = "<li>\n" . $search_string . "</li>\n";
1285     push (@toc_entries, $search_string);
1286     close FILE;
1287
1288     push (@toc_entries, "</ul>\n");
1289     if ($web_manual) {
1290         push (@toc_entries, "\n");
1291     } else {
1292         push (@toc_entries, "</div>\n");
1293     }
1294     return @toc_entries;
1295 }
1296
1297 sub lilypond_print_toc_div ($$)
1298 {
1299   my $fh = shift;
1300   my $tocref = shift;
1301   my @lines = @$tocref;
1302   # use default TOC if no custom lines have been generated
1303   @lines = @default_toc if (not @lines);
1304   if (@lines) {
1305
1306     print $fh "\n\n<div id=\"tocframe\">\n";
1307
1308     # Remove the leading "GNU LilyPond --- " from the manual title
1309     my $topname = $Texi2HTML::NAME{'Top'};
1310     $topname =~ s/^GNU LilyPond(:| &[mn]dash;) //;
1311
1312     # construct the top-level Docs index (relative path and including language!)
1313     my $lang = $Texi2HTML::THISDOC{current_lang};
1314     if ($lang and $lang ne "en") {
1315       $lang .= ".";
1316     } else {
1317       $lang = "";
1318     }
1319     my $reldir = $ENV{DEPTH};
1320     my $uplink = $reldir."/Documentation/web/manuals.${lang}html";
1321
1322     if (not $web_manual) {
1323       print $fh "<p class=\"toc_uplink\"><a href=\"$uplink\"
1324          title=\"Documentation Index\">&lt;&lt; " .
1325          &ly_get_string ('Back to Documentation Index') .
1326          "</a></p>\n";
1327
1328       print $fh '<h4 class="toc_header"> ' . &$anchor('',
1329                                     $Texi2HTML::HREF{'Top'},
1330                                     $topname,
1331                                     'title="Start of the manual"'
1332                                    ) . "</h4>\n";
1333     }
1334
1335     foreach my $line (@lines) {
1336       print $fh $line;
1337     }
1338     print $fh "</div>\n\n";
1339   }
1340 }
1341
1342 # Create the custom TOC for this page (partially folded, current page is
1343 # highlighted) and store it in a global variable. The TOC is written out after
1344 # the html contents (but positioned correctly using CSS), so that browsers with
1345 # css turned off still show the contents first.
1346 our @this_page_toc = ();
1347 sub lilypond_print_element_header
1348 {
1349   my $first_in_page = shift;
1350   my $previous_is_top = shift;
1351   if ($first_in_page and not @this_page_toc) {
1352     if (defined($Texi2HTML::THIS_ELEMENT)) {
1353       # Create the TOC for this page
1354       @this_page_toc = lilypond_generate_page_toc_body($Texi2HTML::THIS_ELEMENT);
1355     }
1356   }
1357   return &$default_print_element_header( $first_in_page, $previous_is_top);
1358 }
1359
1360 # Generate the HTML output for the TOC
1361 sub lilypond_toc_body($)
1362 {
1363     my $elements_list = shift;
1364     # Generate a default TOC for pages without THIS_ELEMENT
1365     @default_toc = lilypond_generate_page_toc_body(@$elements_list[0]);
1366     return &$default_toc_body($elements_list);
1367 }
1368
1369 # Print out the TOC in a <div> at the beginning of the page
1370 sub lilypond_print_page_head($)
1371 {
1372     my $fh = shift;
1373     &$default_print_page_head($fh);
1374     print $fh "<div id=\"main\">\n";
1375 }
1376
1377 # Print out the TOC in a <div> at the end of th page, which will be formatted as a
1378 # sidebar mimicking a TOC frame
1379 sub print_lilypond_page_foot($)
1380 {
1381   my $fh = shift;
1382   my $program_string = &$program_string();
1383 #   print $fh "<p><font size='-1'>$program_string</font><br>$PRE_BODY_CLOSE</p>\n";
1384   print $fh "<!-- FOOTER -->\n\n";
1385   print $fh "<!-- end div#main here -->\n</div>\n\n";
1386   if ($web_manual) {
1387     # FIXME: This div and p#languages need to be in div#footer.
1388     #        Should we move this div to postprocess_html.py ?
1389     print $fh "<div id=\"verifier_texinfo\">\n";
1390     print $fh "<h3>Validation</h3>\n";
1391     # FIXME: inlined text substitution, move to ly_get_string as soon as another case is needed
1392     my $webdev_link = "<a href=\"http://www.webdev.nl/\">webdev.nl</a>";
1393     my $lily_site = "<code>lilypond.org</code>";
1394     my $hosting_thanks = &ly_get_string ('<p>Thanks to ${webdev_link} for hosting ${lily_site}.');
1395     # this does the variable substitution ("quoting" in Perlish) after the localization
1396     $hosting_thanks =~ s/(\$\{\w+\})/$1/eeg;
1397     print $fh $hosting_thanks . "\n";
1398     print $fh "<a href=\"http://validator.w3.org/check?uri=referer\">\n";
1399     print $fh "<img src=\"http://www.w3.org/Icons/valid-html401\"\n";
1400     print $fh "     alt=\"Valid HTML 4.01 Transitional\"\n";
1401     print $fh "     height=\"31\" width=\"88\"></a></p>\n";
1402     print $fh "</div>";
1403   }
1404
1405   # Print the TOC frame and reset the TOC:
1406   lilypond_print_toc_div ($fh, \@this_page_toc);
1407   @this_page_toc = ();
1408
1409   # Close the page:
1410   print $fh "</body>\n</html>\n";
1411 }
1412
1413
1414
1415
1416
1417 #############################################################################
1418 ###  NICER / MORE FLEXIBLE NAVIGATION PANELS
1419 #############################################################################
1420
1421 sub get_navigation_text
1422 {
1423   my $button = shift;
1424   my $text = $NAVIGATION_TEXT{$button};
1425   if ( ($button eq 'Back') or ($button eq 'FastBack') ) {
1426     $text = $text . $Texi2HTML::NODE{$button} . "&nbsp;";
1427   } elsif ( ($button eq 'Forward') or ($button eq 'FastForward') ) {
1428     $text = "&nbsp;" . $Texi2HTML::NODE{$button} . $text;
1429   } elsif ( $button eq 'Up' ) {
1430     $text = "&nbsp;".$text.":&nbsp;" . $Texi2HTML::NODE{$button} . "&nbsp;";
1431   }
1432   return $text;
1433 }
1434
1435
1436 # Don't automatically create left-aligned table cells for every link, but
1437 # instead create a <td> only on an appropriate '(left|right|center)-aligned-cell-n'
1438 # button text. It's alignment as well as the colspan will be taken from the
1439 # name of the button. Also, add 'newline' button text to create a new table
1440 # row. The texts of the buttons are generated by get_navigation_text and
1441 # will contain the name of the next/previous section/chapter.
1442 sub lilypond_print_navigation
1443 {
1444     my $buttons = shift;
1445     my $vertical = shift;
1446     my $spacing = 1;
1447     my $result = "<table class=\"nav_table\">\n";
1448
1449     $result .= "<tr>" unless $vertical;
1450     my $beginofline = 1;
1451     foreach my $button (@$buttons)
1452     {
1453         $result .= qq{<tr valign="top" align="left">\n} if $vertical;
1454         # Allow (left|right|center)-aligned-cell and newline as buttons!
1455         if ( $button =~ /^(.*)-aligned-cell-(.*)$/ )
1456         {
1457           $result .= qq{</td>} unless $beginofline;
1458           $result .= qq{<td valign="middle" align="$1" colspan="$2">};
1459           $beginofline = 0;
1460         }
1461         elsif ( $button eq 'newline' )
1462         {
1463           $result .= qq{</td>} unless $beginofline;
1464           $result .= qq{</tr>};
1465           $result .= qq{<tr>};
1466           $beginofline = 1;
1467
1468         }
1469         elsif (ref($button) eq 'CODE')
1470         {
1471             $result .= &$button($vertical);
1472         }
1473         elsif (ref($button) eq 'SCALAR')
1474         {
1475             $result .= "$$button" if defined($$button);
1476         }
1477         elsif (ref($button) eq 'ARRAY')
1478         {
1479             my $text = $button->[1];
1480             my $button_href = $button->[0];
1481             # verify that $button_href is simple text and text is a reference
1482             if (defined($button_href) and !ref($button_href)
1483                and defined($text) and (ref($text) eq 'SCALAR') and defined($$text))
1484             {             # use given text
1485                 if ($Texi2HTML::HREF{$button_href})
1486                 {
1487                   my $anchor_attributes = '';
1488                   if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button_href})) and
1489                       ($BUTTONS_ACCESSKEY{$button_href} ne ''))
1490                   {
1491                       $anchor_attributes = "accesskey=\"$BUTTONS_ACCESSKEY{$button_href}\"";
1492                   }
1493                   if ($USE_REL_REV and (defined($BUTTONS_REL{$button_href})) and
1494                       ($BUTTONS_REL{$button_href} ne ''))
1495                   {
1496                       $anchor_attributes .= " rel=\"$BUTTONS_REL{$button_href}\"";
1497                   }
1498                   $result .=  "" .
1499                         &$anchor('',
1500                                     $Texi2HTML::HREF{$button_href},
1501                                     get_navigation_text($$text),
1502                                     $anchor_attributes
1503                                    );
1504                 }
1505                 else
1506                 {
1507                   $result .=  get_navigation_text($$text);
1508                 }
1509             }
1510         }
1511         elsif ($button eq ' ')
1512         {                       # handle space button
1513             $result .=
1514                 ($ICONS && $ACTIVE_ICONS{' '}) ?
1515                     &$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{' '}) :
1516                         $NAVIGATION_TEXT{' '};
1517             #next;
1518         }
1519         elsif ($Texi2HTML::HREF{$button})
1520         {                       # button is active
1521             my $btitle = $BUTTONS_GOTO{$button} ?
1522                 'title="' . $BUTTONS_GOTO{$button} . '"' : '';
1523             if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button})) and
1524                 ($BUTTONS_ACCESSKEY{$button} ne ''))
1525             {
1526                 $btitle .= " accesskey=\"$BUTTONS_ACCESSKEY{$button}\"";
1527             }
1528             if ($USE_REL_REV and (defined($BUTTONS_REL{$button})) and
1529                 ($BUTTONS_REL{$button} ne ''))
1530             {
1531                 $btitle .= " rel=\"$BUTTONS_REL{$button}\"";
1532             }
1533             if ($ICONS && $ACTIVE_ICONS{$button})
1534             {                   # use icon
1535                 $result .= '' .
1536                     &$anchor('',
1537                         $Texi2HTML::HREF{$button},
1538                         &$button_icon_img($BUTTONS_NAME{$button},
1539                                    $ACTIVE_ICONS{$button},
1540                                    $Texi2HTML::SIMPLE_TEXT{$button}),
1541                         $btitle
1542                       );
1543             }
1544             else
1545             {                   # use text
1546                 $result .=
1547                     '[' .
1548                         &$anchor('',
1549                                     $Texi2HTML::HREF{$button},
1550                                     get_navigation_text($button),
1551                                     $btitle
1552                                    ) .
1553                                        ']';
1554             }
1555         }
1556         else
1557         {                       # button is passive
1558             $result .=
1559                 $ICONS && $PASSIVE_ICONS{$button} ?
1560                     &$button_icon_img($BUTTONS_NAME{$button},
1561                                           $PASSIVE_ICONS{$button},
1562                                           $Texi2HTML::SIMPLE_TEXT{$button}) :
1563
1564                                               "[" . get_navigation_text($button) . "]";
1565         }
1566         $result .= "</td>\n" if $vertical;
1567         $result .= "</tr>\n" if $vertical;
1568     }
1569     $result .= "</td>" unless $beginofline;
1570     $result .= "</tr>" unless $vertical;
1571     $result .= "</table>\n";
1572     if ($web_manual) {
1573       return "\n";
1574     } else {
1575       return $result;
1576     }
1577 }
1578
1579
1580 @Texi2HTML::Config::SECTION_BUTTONS =
1581     ('left-aligned-cell-1', 'FastBack',
1582      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1583      'right-aligned-cell-1', 'FastForward',
1584      'newline',
1585      'left-aligned-cell-2', 'Back',
1586      'center-aligned-cell-1', 'Up',
1587      'right-aligned-cell-2', 'Forward'
1588     );
1589
1590 # buttons for misc stuff
1591 @Texi2HTML::Config::MISC_BUTTONS = ('center-aligned-cell-3',
1592                                     'Top', 'Contents', 'Index', 'About');
1593
1594 # buttons for chapter file footers
1595 # (and headers but only if SECTION_NAVIGATION is false)
1596 @Texi2HTML::Config::CHAPTER_BUTTONS =
1597     ('left-aligned-cell-1', 'FastBack',
1598      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1599      'right-aligned-cell-1', 'FastForward',
1600     );
1601
1602 # buttons for section file footers
1603 @Texi2HTML::Config::SECTION_FOOTER_BUTTONS =
1604     ('left-aligned-cell-1', 'FastBack',
1605      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1606      'right-aligned-cell-1', 'FastForward',
1607      'newline',
1608      'left-aligned-cell-2', 'Back',
1609      'center-aligned-cell-1', 'Up',
1610      'right-aligned-cell-2', 'Forward'
1611     );
1612
1613 @Texi2HTML::Config::NODE_FOOTER_BUTTONS =
1614     ('left-aligned-cell-1', 'FastBack',
1615      'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1616      'right-aligned-cell-1', 'FastForward',
1617      'newline',
1618      'left-aligned-cell-2', 'Back',
1619      'center-aligned-cell-1', 'Up',
1620      'right-aligned-cell-2', 'Forward'
1621     );
1622
1623
1624
1625
1626
1627 #############################################################################
1628 ###  FOOTNOTE FORMATTING
1629 #############################################################################
1630
1631 # Format footnotes in a nicer way: Instead of printing the number in a separate
1632 # (nr) heading line, use the standard way of prepending <sup>nr</sup> immediately
1633 # before the fn text.
1634
1635
1636 # The following code is copied from texi2html's examples/makeinfo.init and
1637 # should be updated when texi2html makes some changes there!
1638
1639 my $makekinfo_like_footnote_absolute_number = 0;
1640
1641 sub makeinfo_like_foot_line_and_ref($$$$$$$$)
1642 {
1643     my $foot_num = shift;
1644     my $relative_num = shift;
1645     my $footid = shift;
1646     my $docid = shift;
1647     my $from_file = shift;
1648     my $footnote_file = shift;
1649     my $lines = shift;
1650     my $state = shift;
1651
1652     $makekinfo_like_footnote_absolute_number++;
1653
1654     # this is a bit obscure, this allows to add an anchor only if formatted
1655     # as part of the document.
1656     $docid = '' if ($state->{'outside_document'} or $state->{'multiple_pass'});
1657
1658     if ($from_file eq $footnote_file)
1659     {
1660         $from_file = $footnote_file = '';
1661     }
1662
1663     my $foot_anchor = "<sup>" .
1664         &$anchor($docid, "$footnote_file#$footid", $relative_num) . "</sup>";
1665     $foot_anchor = &$anchor($docid,
1666                             "$footnote_file#$footid",
1667                             "($relative_num)") if ($state->{'preformatted'});
1668
1669 #    unshift @$lines, "<li>";
1670 #    push @$lines, "</li>\n";
1671     return ($lines, $foot_anchor);
1672 }
1673
1674 sub makeinfo_like_foot_lines($)
1675 {
1676     my $lines = shift;
1677     unshift @$lines, "<hr>\n<h4>$Texi2HTML::I18n::WORDS->{'Footnotes_Title'}</h4>\n";
1678 #<ol type=\"1\">\n";
1679 #    push @$lines, "</ol>";
1680     return $lines;
1681 }
1682
1683 my %makekinfo_like_paragraph_in_footnote_nr;
1684
1685 sub makeinfo_like_paragraph ($$$$$$$$$$$$$)
1686 {
1687     my $text = shift;
1688     my $align = shift;
1689     my $indent = shift;
1690     my $paragraph_command = shift;
1691     my $paragraph_command_formatted = shift;
1692     my $paragraph_number = shift;
1693     my $format = shift;
1694     my $item_nr = shift;
1695     my $enumerate_style = shift;
1696     my $number = shift;
1697     my $command_stack_at_end = shift;
1698     my $command_stack_at_begin = shift;
1699     my $state = shift;
1700 #print STDERR "format: $format\n" if (defined($format));
1701 #print STDERR "paragraph @$command_stack_at_end; @$command_stack_at_begin\n";
1702     $paragraph_command_formatted = '' if (!defined($paragraph_command_formatted) or
1703           exists($special_list_commands{$format}->{$paragraph_command}));
1704     return '' if ($text =~ /^\s*$/);
1705     foreach my $style(t2h_collect_styles($command_stack_at_begin))
1706     {
1707        $text = t2h_begin_style($style, $text);
1708     }
1709     foreach my $style(t2h_collect_styles($command_stack_at_end))
1710     {
1711        $text = t2h_end_style($style, $text);
1712     }
1713     if (defined($paragraph_number) and defined($$paragraph_number))
1714     {
1715          $$paragraph_number++;
1716          return $text  if (($format eq 'itemize' or $format eq 'enumerate') and
1717             ($$paragraph_number == 1));
1718     }
1719     my $open = '<p';
1720     if ($align)
1721     {
1722         $open .= " align=\"$paragraph_style{$align}\"";
1723     }
1724     my $footnote_text = '';
1725     if (defined($command_stack_at_begin->[0]) and $command_stack_at_begin->[0] eq 'footnote')
1726     {
1727         my $state = $Texi2HTML::THISDOC{'state'};
1728         $makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number}++;
1729         if ($makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number} <= 1)
1730         {
1731            $open.=' class="footnote"';
1732            my $document_file = $state->{'footnote_document_file'};
1733            if ($document_file eq $state->{'footnote_footnote_file'})
1734            {
1735                $document_file = '';
1736            }
1737            my $docid = $state->{'footnote_place_id'};
1738            my $doc_state = $state->{'footnote_document_state'};
1739            $docid = '' if ($doc_state->{'outside_document'} or $doc_state->{'multiple_pass'});
1740            my $foot_label = &$anchor($state->{'footnote_footnote_id'},
1741                  $document_file . "#$state->{'footnote_place_id'}",
1742                  "$state->{'footnote_number_in_page'}");
1743            $footnote_text = "<small>[${foot_label}]</small> ";
1744         }
1745     }
1746     return $open.'>'.$footnote_text.$text.'</p>';
1747 }
1748
1749
1750 #############################################################################
1751 ###  OTHER SETTINGS
1752 #############################################################################
1753
1754 # For split pages, use index.html as start page!
1755 if ($Texi2HTML::Config::SPLIT eq 'section' or
1756     $Texi2HTML::Config::SPLIT eq 'node') {
1757   $Texi2HTML::Config::TOP_FILE = 'index.html';
1758 }
1759
1760
1761 return 1;