2 # -*- coding: utf-8; -*-
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
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
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
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
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
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)
67 package Texi2HTML::Config;
70 use Encode qw(decode);
72 #############################################################################
74 #############################################################################
76 my $LY_LANGUAGES = {};
77 $LY_LANGUAGES->{'fr'} = {
78 'Back to Documentation Index' => 'Retour à l\'accueil de la documentation',
79 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '<p>Remerciements à ${webdev_link} pour l\'hébergement de ${lily_site}.',
82 $LY_LANGUAGES->{'es'} = {
83 'Back to Documentation Index' => 'Volver al índice de la documentación',
84 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '<p>Agradecemos a ${webdev_link} el alojamiento de ${lily_site}.',
87 $LY_LANGUAGES->{'de'} = {
88 'Back to Documentation Index' => 'Zur Dokumentationsübersicht',
89 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '',
92 $LY_LANGUAGES->{'ja'} = {
93 'Back to Documentation Index' => 'ドキュメント インデックスに戻る',
94 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '',
97 $LY_LANGUAGES->{'hu'} = {
98 'Back to Documentation Index' => 'Vissza a dokumentációk jegyzékéhez',
99 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => 'Köszönet a ${webdev_link} részére a ${lily_site} tárhelyért.',
102 $LY_LANGUAGES->{'it'} = {
103 'Back to Documentation Index' => 'Torna all\'indice della documentazione',
104 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '',
107 $LY_LANGUAGES->{'nl'} = {
108 'Back to Documentation Index' => 'Terug naar de Documentatieindex',
109 '<p>Met dank aan ${webdev_link} voor het hosten van ${lily_site}.' => '',
112 # FIXME: request the translations below then send them to texi2html/texinfo devs
113 $LANGUAGES->{'it'} = {
114 ' The buttons in the navigation panels have the following meaning:' => ' I bottoni nei pannelli di navigazione hanno il seguente significato:',
115 ' where the @strong{ Example } assumes that the current position is at @strong{ Subsubsection One-Two-Three } of a document of the following structure:' => ' dove @strong{ Esempio } assume che l\'attuale posizione è alla @strong{ Sottosottosezione Uno-Due-Tre } di un documento che ha la seguente struttura:',
117 '(outside of any element)' => '(fuori da qualsiasi elemento)',
118 '(outside of any node)' => '(fuori da qualsiasi nodo)',
119 '@b{{quotation_arg}:} ' => '@b{{quotation_arg}:} ',
120 '@cite{{book}}' => '@cite{{book}}',
121 '@{No value for `{value}\'@}' => '@{Nessun valore per `{value}\'@}',
122 'About' => 'Informazioni',
123 'About (help)' => 'Informazioni (aiuto)',
124 'About This Document' => 'Informazioni su questo documento',
126 'August' => 'Agosto',
127 'Back' => 'Indietro',
128 'Back section in previous file' => '',
129 'Beginning of this chapter or previous chapter' => 'Inizio di questo capitolo o capitolo precedente',
130 'Button' => 'Bottone',
131 'Contents' => 'Contenuti',
132 'Cover (top) of document' => 'Copertina (inizio) del documento',
133 'Current' => 'Attuale',
134 'Current Position' => 'Posizione Attuale',
135 'Current section' => 'Sezione attuale',
136 'December' => 'Dicembre',
137 'FastBack' => 'Indietro veloce',
138 'FastForward' => 'Avanti veloce',
139 'February' => 'Febbraio',
141 'First section in reading order' => 'Prima sezione in ordine di lettura',
142 'Following' => 'Seguente',
143 'Following node' => 'Nodo seguente',
144 'Footnotes' => 'Note a piè di pagina',
145 'Forward' => 'Avanti',
146 'Forward section in next file' => 'Sezione successiva nel prossimo file',
147 'From 1.2.3 go to' => 'Da 1.2.3 vai a',
150 'Index Entry' => 'Voce dell\'indice',
151 'January' => 'Gennaio',
153 'Jump to' => 'Salta a',
156 'Last section in reading order' => 'Ultima sezione in ordine di lettura',
161 'Next' => 'Successivo',
162 'Next chapter' => 'Capitolo successivo',
163 'Next file' => 'File successivo',
164 'Next node' => 'Nodo successivo',
165 'Next section in reading order' => 'Sezione successiva in ordine di lettura',
166 'Next section on same level' => 'Sezione successiva sullo stesso livello',
167 'NextFile' => 'File successivo',
168 'Node following in node reading order' => 'Nodo seguente in ordine di lettura',
169 'Node up' => 'Nodo superiore',
170 'NodeNext' => 'Nodo successivo',
171 'NodePrev' => 'Nodo precedente',
172 'NodeUp' => 'Nodo superiore',
173 'November' => 'Novembre',
174 'October' => 'Ottobre',
175 'Overview' => 'Panoramica',
177 'PrevFile' => 'File precedente',
178 'Previous' => 'Precedente',
179 'Previous file' => 'File precedente',
180 'Previous node' => 'Nodo precedente',
181 'Previous section in reading order' => 'Sezione precedente in ordine di lettura',
182 'Previous section on same level' => 'Sezione precedente sullo stesso livello',
183 'Section' => 'Sezione',
184 'Section One' => 'Sezione uno',
186 'See @cite{{book}}' => 'Vedi @cite{{book}}',
187 'See section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'Vedi la sezione `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}',
188 'See section `{section}\' in @cite{{book}}' => 'Vedi la sezione `{section}\' in @cite{{book}}',
189 'See section {reference_name}' => 'Vedi la sezione {reference_name}',
190 'See {node_file_href}' => 'Vedi {node_file_href}',
191 'See {node_file_href} @cite{{book}}' => 'Vedi {node_file_href} @cite{{book}}',
192 'See {node_file_href} section `{section}\' in @cite{{book}}' => 'Vedi {node_file_href} nella sezione `{section}\' in @cite{{book}}',
193 'See {reference_name}' => 'Vedi {reference_name}',
194 'See {ref}' => 'Vedi {ref}',
195 'See {title_ref}' => 'Vedi {title_ref}',
196 'September' => 'Settembre',
197 'Short Table of Contents' => 'Indice breve',
198 'Short table of contents' => 'Indice breve',
199 'Subsection One-Four' => 'Sottosezione Uno-Quattro',
200 'Subsection One-One' => 'Sottosezione Uno-Uno',
201 'Subsection One-Three' => 'Sottosezione Uno-Tre',
202 'Subsection One-Two' => 'Sottosezione Uno-Due',
203 'Subsubsection One-Two-Four' => 'Sottosottosezione Uno-Due-Quattro',
204 'Subsubsection One-Two-One' => 'Sottosottosezione Uno-Due-Uno',
205 'Subsubsection One-Two-Three' => 'Sottosottosezione Uno-Due-Tre',
206 'Subsubsection One-Two-Two' => 'Sottosottosezione Uno-Due-Due',
207 'T2H_today' => '%s, %d %d',
208 'Table of Contents' => 'Indice',
209 'Table of contents' => 'Indice',
210 'The node you are looking for is at {href}.' => 'Il nodo che stai cercando è {href}',
212 'This document was generated on @i{{date}} using @uref{{program_homepage}, @i{{program}}}.' => 'Questo documento è stato generato il @i{{date}} con @uref{{program_homepage}, @i{{program}}}.',
213 'This document was generated using @uref{{program_homepage}, @emph{{program}}}.' => 'Questo documento è stato generato con @uref{{program_homepage}, @emph{{program}}}.',
215 'Untitled Document' => 'Documento senza titolo',
217 'Up node' => 'Nodo superiore',
218 'Up section' => 'Sezione superiore',
219 'current' => 'attuale',
220 'on @emph{{date}}' => 'il @emph{{date}}',
221 'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'sezione `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}',
222 'section `{section}\' in @cite{{book}}' => 'sezione `{section}\' in @cite{{book}}',
224 'see @cite{{book}}' => 'vedi @cite{{book}}',
225 'see section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'vedi la sezione `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}',
226 'see section `{section}\' in @cite{{book}}' => 'vedi la sezione `{section}\' in @cite{{book}}',
227 'see section {reference_name}' => 'vedi la sezione {reference_name}',
228 'see {node_file_href}' => 'vedi {node_file_href}',
229 'see {node_file_href} @cite{{book}}' => 'vedi {node_file_href} @cite{{book}}',
230 'see {node_file_href} section `{section}\' in @cite{{book}}' => 'vedi {node_file_href} nella sezione `{section}\' in @cite{{book}}',
231 'see {reference_name}' => 'vedi {reference_name}',
232 'see {ref}' => 'vedi {ref}',
233 'see {title_ref}' => 'vedi {title_ref}',
234 '{acronym_like} ({explanation})' => '{acronym_like} ({explanation})',
235 '{name} of {class}' => '{name} di {class}',
236 '{name} on {class}' => '{name} in {class}',
237 '{node_file_href}' => '{node_file_href}',
238 '{node_file_href} @cite{{book}}' => '{node_file_href} @cite{{book}}',
239 '{node_file_href} section `{section}\' in @cite{{book}}' => '{node_file_href} nella sezione `{section}\' in @cite{{book}}',
240 '{reference_name}' => '{reference_name}',
242 '{style} {number}' => '{style} {number}',
243 '{style}: {caption_first_line}' => '{style}: {caption_first_line}',
244 '{style}: {shortcaption_first_line}' => '{style}: {shortcaption_first_line}',
245 '{title_ref}' => '{title_ref}'
248 $LANGUAGES->{'hu'} = {
249 ' The buttons in the navigation panels have the following meaning:' => ' A navigációs panelen levő gombok jelentése a következő:',
250 ' where the @strong{ Example } assumes that the current position is at @strong{ Subsubsection One-Two-Three } of a document of the following structure:' => ' @strong{ Példánkban } az aktuális pozíció az @strong{ 1.2.3 alalszakasz } egy olyan dokumentumban, melynek szerkezete a következő:',
252 '(outside of any element)' => '(bármelyik elemen kívül)',
253 '(outside of any node)' => '(bármelyik csomóponton kívül)',
254 '@b{{quotation_arg}:} ' => '@b{{quotation_arg}:} ',
255 '@cite{{book}}' => '@cite{{book}}',
256 '@{No value for `{value}\'@}' => '@{Nincs értéke ennek: `{value}\'@}',
258 'About (help)' => 'Segítség a navigációhoz',
259 'About This Document' => 'A navigációs panel használata',
260 'April' => 'április',
261 'August' => 'augusztus',
263 'Back section in previous file' => 'Előző fájl hátsó szakasza',
264 'Beginning of this chapter or previous chapter' => 'Fejezet eleje vagy előző fejezet',
266 'Contents' => 'Tartalom',
267 'Cover (top) of document' => 'Dokumentum címoldala',
268 'Current' => 'Aktuális',
269 'Current Position' => 'Aktuális pozíció',
270 'Current section' => 'Aktuális szakasz',
271 'December' => 'december',
272 'FastBack' => 'Visszaugrás',
273 'FastForward' => 'Előreugrás',
274 'February' => 'február',
276 'First section in reading order' => 'Első szakasz az olvasási sorrendben',
277 'Following' => 'Következő',
278 'Following node' => 'Következő csomópont',
279 'Footnotes' => 'Lábjegyzet',
280 'Forward' => 'Előre',
281 'Forward section in next file' => 'Következő fájl elülső szakasza',
282 'From 1.2.3 go to' => '1.2.3-ból ide jutunk',
284 'Index' => 'Tárgymutató',
285 'Index Entry' => 'Tárgymutató-bejegyzés',
286 'January' => 'január',
288 'Jump to' => 'Ugorj ide',
291 'Last section in reading order' => 'Utolsó szakasz az olvasási sorrendben',
292 'March' => 'március',
296 'Next' => 'Következő',
297 'Next chapter' => 'Következő fejezet',
298 'Next file' => 'Következő fájl',
299 'Next node' => 'Következő csomópont',
300 'Next section in reading order' => 'Következő szakasz az olvasási sorrendben',
301 'Next section on same level' => 'Következő szakasz ugyanazon a szinten',
302 'NextFile' => 'KövetkezőFájl',
303 'Node following in node reading order' => 'Következő csomópont az olvasási sorrendben',
304 'Node up' => 'Szülő csomópont',
305 'NodeNext' => 'KövetkezőCsomópont',
306 'NodePrev' => 'ElőzőCsomópont',
307 'NodeUp' => 'SzülőCsomópont',
308 'November' => 'november',
309 'October' => 'október',
310 'Overview' => 'Áttekintés',
312 'PrevFile' => 'ElőzőFájl',
313 'Previous' => 'Előző',
314 'Previous file' => 'Előző fájl',
315 'Previous node' => 'Előző csomópont',
316 'Previous section in reading order' => 'Előző szakasz az olvasási sorrendben',
317 'Previous section on same level' => 'Előző szakasz ugyanazon a szinten',
318 'Section' => 'Szakasz',
319 'Section One' => 'szakasz',
321 'See @cite{{book}}' => 'Ld. @cite{{book}}',
322 'See section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'Ld. ezt a szakaszt: `@asis{}`{section_name}\'@asis{}\' itt: @cite{{book}}',
323 'See section `{section}\' in @cite{{book}}' => 'Ld. ezt a szakaszt: `{section}\' itt: @cite{{book}}',
324 'See section {reference_name}' => 'Ld. ezt a szakaszt: {reference_name}',
325 'See {node_file_href}' => 'Ld. {node_file_href}',
326 'See {node_file_href} @cite{{book}}' => 'See {node_file_href} @cite{{book}}',
327 'See {node_file_href} section `{section}\' in @cite{{book}}' => 'Ld. {node_file_href} ezt a szakaszt: `{section}\' itt: @cite{{book}}',
328 'See {reference_name}' => 'Ld. {reference_name}',
329 'See {ref}' => 'Ld. {ref}',
330 'See {title_ref}' => 'Ld. {title_ref}',
331 'September' => 'szeptember',
332 'Short Table of Contents' => 'Rövid tartalomjegyzék',
333 'Short table of contents' => 'Rövid tartalomjegyzék',
334 'Subsection One-Four' => 'alszakasz',
335 'Subsection One-One' => 'alszakasz',
336 'Subsection One-Three' => 'alszakasz',
337 'Subsection One-Two' => 'alszakasz',
338 'Subsubsection One-Two-Four' => 'alalszakasz',
339 'Subsubsection One-Two-One' => 'alalszakasz',
340 'Subsubsection One-Two-Three' => 'alalszakasz',
341 'Subsubsection One-Two-Two' => 'alalszakasz',
342 'T2H_today' => '%s, %d %d',
343 'Table of Contents' => 'Tartalomjegyzék',
344 'Table of contents' => 'Tartalomjegyzék',
345 'The node you are looking for is at {href}.' => 'A keresett csomópont itt található: {href}.',
347 'This document was generated on @i{{date}} using @uref{{program_homepage}, @i{{program}}}.' => 'Ezt a dokumentumot @i{{date}} napon generálta a(z) @uref{{program_homepage}, @i{{program}}}.',
348 'This document was generated using @uref{{program_homepage}, @emph{{program}}}.' => 'Ezt a dokumentumot a(z) @uref{{program_homepage}, @emph{{program}}} generálta.',
350 'Untitled Document' => 'Névtelen dokumentum',
352 'Up node' => 'Szülő csomópont',
353 'Up section' => 'Szülő szakasz',
354 'current' => 'aktuális',
355 'on @emph{{date}}' => 'ekkor: @emph{{date}}',
356 'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'szakasz: `@asis{}`{section_name}\'@asis{}\' itt: @cite{{book}}',
357 'section `{section}\' in @cite{{book}}' => 'szakasz: `{section}\' itt: @cite{{book}}',
359 'see @cite{{book}}' => 'ld. @cite{{book}}',
360 'see section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'ld. ezt a szakaszt: `@asis{}`{section_name}\'@asis{}\' itt: @cite{{book}}',
361 'see section `{section}\' in @cite{{book}}' => 'ld. ezt a szakaszt: `{section}\' itt: @cite{{book}}',
362 'see section {reference_name}' => 'ld. ezt a szakaszt: {reference_name}',
363 'see {node_file_href}' => 'ld. {node_file_href}',
364 'see {node_file_href} @cite{{book}}' => 'ld. {node_file_href} @cite{{book}}',
365 'see {node_file_href} section `{section}\' in @cite{{book}}' => 'ld. {node_file_href} ezt a szakaszt: `{section}\' itt: @cite{{book}}',
366 'see {reference_name}' => 'ld. {reference_name}',
367 'see {ref}' => 'ld. {ref}',
368 'see {title_ref}' => 'ld. {title_ref}',
369 '{acronym_like} ({explanation})' => '{acronym_like} ({explanation})',
370 '{name} of {class}' => '{name} típusa: {class}',
371 '{name} on {class}' => '{name} ezen: {class}',
372 '{node_file_href}' => '{node_file_href}',
373 '{node_file_href} @cite{{book}}' => '{node_file_href} @cite{{book}}',
374 '{node_file_href} section `{section}\' in @cite{{book}}' => '{node_file_href} szakasz: `{section}\' itt: @cite{{book}}',
375 '{reference_name}' => '{reference_name}',
377 '{style} {number}' => '{style} {number}',
378 '{style}: {caption_first_line}' => '{style}: {caption_first_line}',
379 '{style}: {shortcaption_first_line}' => '{style}: {shortcaption_first_line}',
380 '{title_ref}' => '{title_ref}'
383 $LANGUAGES->{'ja'} = {
384 ' The buttons in the navigation panels have the following meaning:' => ' ナビゲーション パネルの中にあるボタンには以下のような意味があります:',
385 ' where the @strong{ Example } assumes that the current position is at @strong{ Subsubsection One-Two-Three } of a document of the following structure:' => ' この表で、@strong{ 行き先 } は、現在の位置が以下のような構造を持つドキュメントの @strong{ サブサブセクション 1-2-3 } であると仮定しています:',
387 '(outside of any element)' => '(outside of any element)',
388 '(outside of any node)' => '(outside of any node)',
389 '@b{{quotation_arg}:} ' => '@b{{quotation_arg}:} ',
390 '@cite{{book}}' => '@cite{{book}}',
391 '@{No value for `{value}\'@}' => '@{No value for `{value}\'@}',
393 'About (help)' => '情報 (ヘルプ)',
394 'About This Document' => 'このドキュメントについて',
398 'Back section in previous file' => '',
399 'Beginning of this chapter or previous chapter' => 'この章あるいは前の章の先頭',
402 'Cover (top) of document' => 'ドキュメントの表紙 (先頭)',
404 'Current Position' => '現在の位置',
405 'Current section' => '',
406 'December' => '12 月',
411 'First section in reading order' => '',
413 'Following node' => '',
416 'Forward section in next file' => '',
417 'From 1.2.3 go to' => '1.2.3 からの行き先',
420 'Index Entry' => 'インデックス エントリ',
426 'Last section in reading order' => '',
432 'Next chapter' => '次の章',
435 'Next section in reading order' => '次のセクション',
436 'Next section on same level' => '',
438 'Node following in node reading order' => '',
443 'November' => '11 月',
449 'Previous file' => '',
450 'Previous node' => '',
451 'Previous section in reading order' => '前のセクション',
452 'Previous section on same level' => '',
453 'Section' => 'セクション',
454 'Section One' => 'セクション 1',
456 'See @cite{{book}}' => '',
457 'See section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '',
458 'See section `{section}\' in @cite{{book}}' => '',
459 'See section {reference_name}' => '',
460 'See {node_file_href}' => '',
461 'See {node_file_href} @cite{{book}}' => '',
462 'See {node_file_href} section `{section}\' in @cite{{book}}' => '',
463 'See {reference_name}' => '',
465 'See {title_ref}' => '',
466 'September' => '9 月',
467 'Short Table of Contents' => '',
468 'Short table of contents' => '',
469 'Subsection One-Four' => 'サブセクション 1-4',
470 'Subsection One-One' => 'サブセクション 1-1',
471 'Subsection One-Three' => 'サブセクション 1-3',
472 'Subsection One-Two' => 'サブセクション 1-2',
473 'Subsubsection One-Two-Four' => 'サブサブセクション 1-2-4',
474 'Subsubsection One-Two-One' => 'サブサブセクション 1-2-1',
475 'Subsubsection One-Two-Three' => 'サブサブセクション 1-2-3',
476 'Subsubsection One-Two-Two' => 'サブサブセクション 1-2-2',
477 'T2H_today' => '%s, %d %d',
478 'Table of Contents' => '目次',
479 'Table of contents' => '目次',
480 'The node you are looking for is at {href}.' => '',
482 'This document was generated on @i{{date}} using @uref{{program_homepage}, @i{{program}}}.' => 'このドキュメントは @i{{date}} に、@uref{{program_homepage}, @i{{program}}} を用いて生成されました。',
483 'This document was generated using @uref{{program_homepage}, @emph{{program}}}.' => 'このドキュメントは @uref{{program_homepage}, @emph{{program}}} を用いて生成されました。',
485 'Untitled Document' => '',
488 'Up section' => '上のセクション',
490 'on @emph{{date}}' => '@emph{{date}} に',
491 'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '',
492 'section `{section}\' in @cite{{book}}' => '',
494 'see @cite{{book}}' => '',
495 'see section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '',
496 'see section `{section}\' in @cite{{book}}' => '',
497 'see section {reference_name}' => '',
498 'see {node_file_href}' => '',
499 'see {node_file_href} @cite{{book}}' => '',
500 'see {node_file_href} section `{section}\' in @cite{{book}}' => '',
501 'see {reference_name}' => '',
503 'see {title_ref}' => '',
504 '{acronym_like} ({explanation})' => '{acronym_like} ({explanation})',
505 '{name} of {class}' => '',
506 '{name} on {class}' => '',
507 '{node_file_href}' => '',
508 '{node_file_href} @cite{{book}}' => '',
509 '{node_file_href} section `{section}\' in @cite{{book}}' => '',
510 '{reference_name}' => '',
512 '{style} {number}' => '{style} {number}',
513 '{style}: {caption_first_line}' => '{style}: {caption_first_line}',
514 '{style}: {shortcaption_first_line}' => '{style}: {shortcaption_first_line}',
515 '{title_ref}' => '{title_ref}'
519 sub ly_get_string () {
520 my $lang = $Texi2HTML::THISDOC{current_lang};
522 if ($lang and $lang ne "en" and $LY_LANGUAGES->{$lang}->{$string}) {
523 return $LY_LANGUAGES->{$lang}->{$string};
530 #############################################################################
531 ### FUNCTIONALITY FOR MAIN WEB PAGES
532 #############################################################################
536 #############################################################################
537 ### SETTINGS FOR TEXI2HTML
538 #############################################################################
540 # Validation fix for texi2html<=1.82
541 $Texi2HTML::Config::DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
543 @Texi2HTML::Config::CSS_REFS = (
544 {FILENAME => "lilypond-mccarty.css", TITLE => "Default style"}
546 @Texi2HTML::Config::ALT_CSS_REFS = (
547 {FILENAME => "lilypond.css", TITLE => "Andrew Hawryluk's design" },
548 {FILENAME => "lilypond-blue.css", TITLE => "Kurt Kroon's blue design" },
552 print STDERR "Initializing settings for web site\n";
553 $Texi2HTML::Config::BODYTEXT = "";
554 @Texi2HTML::Config::CSS_REFS = (
555 {FILENAME => "lilypond-web.css", TITLE => "Patrick McCarty's design"}
557 @Texi2HTML::Config::ALT_CSS_REFS = (
558 {FILENAME => "lilypond-web-alt1.css", TITLE => "Alternate style 1"},
559 {FILENAME => "lilypond-web-alt2.css", TITLE => "Alternate style 2"},
563 $Texi2HTML::Config::USE_ACCESSKEY = 1;
564 $Texi2HTML::Config::USE_LINKS = 1;
565 $Texi2HTML::Config::USE_REL_REV = 1;
566 $Texi2HTML::Config::SPLIT_INDEX = 0;
567 $Texi2HTML::Config::SEPARATED_FOOTNOTES = 0; # Print footnotes on same page, not separated
569 if ($Texi2HTML::Config::SPLIT eq 'section' or
570 $Texi2HTML::Config::SPLIT eq 'node') {
571 $Texi2HTML::Config::element_file_name = \&lilypond_element_file_name;
574 $Texi2HTML::Config::element_target_name = \&lilypond_element_target_name;
575 $default_print_element_header = $Texi2HTML::Config::print_element_header;
576 $Texi2HTML::Config::print_element_header = \&lilypond_print_element_header;
577 $Texi2HTML::Config::print_page_foot = \&print_lilypond_page_foot;
578 $Texi2HTML::Config::print_navigation = \&lilypond_print_navigation;
579 $Texi2HTML::Config::external_ref = \&lilypond_external_ref;
580 $default_external_href = $Texi2HTML::Config::external_href;
581 $Texi2HTML::Config::external_href = \&lilypond_external_href;
582 $default_toc_body = $Texi2HTML::Config::toc_body;
583 $Texi2HTML::Config::toc_body = \&lilypond_toc_body;
584 $Texi2HTML::Config::css_lines = \&lilypond_css_lines;
585 $default_unknown = $Texi2HTML::Config::unknown;
586 $Texi2HTML::Config::unknown = \&lilypond_unknown;
587 $default_print_page_head = $Texi2HTML::Config::print_page_head;
588 $Texi2HTML::Config::print_page_head = \&lilypond_print_page_head;
589 # $Texi2HTML::Config::foot_line_and_ref = \&lilypond_foot_line_and_ref;
590 $Texi2HTML::Config::foot_line_and_ref = \&makeinfo_like_foot_line_and_ref;
591 $Texi2HTML::Config::foot_lines = \&makeinfo_like_foot_lines;
592 $Texi2HTML::Config::paragraph = \&makeinfo_like_paragraph;
596 # Examples should be formatted similar to quotes:
597 $Texi2HTML::Config::complex_format_map->{'example'} = {
598 'begin' => q{"<blockquote>"},
599 'end' => q{"</blockquote>\n"},
603 %Texi2HTML::config::misc_pages_targets = (
604 'Overview' => 'Overview',
605 'Contents' => 'Contents',
610 my @section_to_filename;
615 #############################################################################
617 #############################################################################
620 $Data::Dumper::Maxdepth = 2;
622 sub print_element_info($)
625 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
626 print "Element: $element\n";
627 print Dumper($element);
634 #############################################################################
636 #############################################################################
638 # only lc() the last portion of an href
642 my @hrefsplit = split('/', $href);
643 # change the last portion (the filename), if it exists
644 if ($#hrefsplit > 0) {
645 @hrefsplit[$#hrefsplit] = lc( @hrefsplit[$#hrefsplit] );
646 $href = join("/", @hrefsplit);
651 # Convert a given node name to its proper file name (normalization as explained
652 # in the texinfo manual:
653 # http://www.gnu.org/software/texinfo/manual/texinfo/html_node/HTML-Xref-Node-Name-Expansion.html
654 sub texinfo_file_name($)
658 # File name normalization by texinfo:
659 # 1/2: letters and numbers are left unchanged
660 # 3/4: multiple, leading and trailing whitespace is removed
661 $text = main::normalise_space($text);
662 # 5/6: all remaining spaces are converted to '-', all other 7- or 8-bit
663 # chars are replaced by _xxxx (xxxx=ascii character code)
664 while ($text ne '') {
665 if ($text =~ s/^([A-Za-z0-9]+)//o) { # number or letter stay unchanged
667 } elsif ($text =~ s/^ //o) { # space -> '-'
669 } elsif ($text =~ s/^(.)//o) { # Otherwise use _xxxx (ascii char code)
671 if ( $ccode <= 0xFFFF ) {
672 $result .= sprintf("_%04x", $ccode);
674 $result .= sprintf("__%06x", $ccode);
678 # 7: if name does not begin with a letter, prepend 't_g' (so it starts with a letter)
679 if ($result !~ /^[a-zA-Z]/) {
680 $result = 't_g' . $result;
683 return lc_last($result)
686 # Load a file containing a nodename<=>filename map (tab-sepatared, i.e.
687 # NODENAME\tFILENAME\tANCHOR
688 # Returns a ref to a hash "Node title" => ["FilenameWithoutExt", "Anchor"]
689 sub load_map_file ($)
694 # For some unknown reason, Perl on my system (5.10.0 on Fedora 12)
695 # refuses to open map files of translated documents with
696 # '<:encoding(utf8)', but decoding from UTF-8 line by line works. -jm
697 if (open(XREFFILE,'<', $mapfile)) {
699 # print STDERR "*** PRINTING MAP FILE LINES ***\n";
700 while ( $line = decode ('UTF-8', <XREFFILE>) ) {
701 # parse the tab-separated entries and insert them into the map:
703 my @entries = split(/\t/, $line);
704 if (scalar (@entries) == 3) {
705 $node_map->{$entries[0]} = [$entries[1], $entries[2]];
707 # print STDERR @entries;
710 print STDERR "Invalid entry in the node file $mapfile: $line\n";
715 print STDERR "WARNING: Unable to load the map file $mapfile\n";
721 # Split the given path into dir and basename (with .texi removed). Used mainly
722 # to get the path/basename of the original texi input file
723 sub split_texi_filename ($)
726 my ($docu_dir, $docu_name);
727 if ($docu =~ /(.*\/)/) {
728 chop($docu_dir = $1);
730 $docu_name =~ s/.*\///;
735 $docu_name =~ s/\.te?x(i|info)?$//;
736 return ($docu_dir, $docu_name);
743 #############################################################################
745 #############################################################################
747 # Include our standard CSS file, not hard-coded CSS code directly in the HTML!
748 # For IE, conditionally include the lilypond-ie-fixes.css style sheet
749 sub lilypond_css_lines ($$)
751 my $import_lines = shift;
752 my $rule_lines = shift;
753 return if (defined($Texi2HTML::THISDOC{'CSS_LINES'}));
754 if (@$rule_lines or @$import_lines)
756 $Texi2HTML::THISDOC{'CSS_LINES'} = "<style type=\"text/css\">\n<!--\n";
757 $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$import_lines) . "\n" if (@$import_lines);
758 $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$rule_lines) . "\n" if (@$rule_lines);
759 $Texi2HTML::THISDOC{'CSS_LINES'} .= "-->\n</style>\n";
761 foreach my $ref (@CSS_REFS)
763 $Texi2HTML::THISDOC{'CSS_LINES'} .=
764 "<link rel=\"stylesheet\" type=\"text/css\" title=\"$ref->{TITLE}\" href=\"$ref->{FILENAME}\">\n";
766 foreach my $ref (@Texi2HTML::Config::ALT_CSS_REFS)
768 $Texi2HTML::THISDOC{'CSS_LINES'} .=
769 "<link rel=\"alternate stylesheet\" type=\"text/css\" href=\"$ref->{FILENAME}\" title=\"$ref->{TITLE}\">\n";
771 # FIXME: the website doesn't use ie7-specific fixes; do the
772 # docs still need this? -gp
773 $Texi2HTML::THISDOC{'CSS_LINES'} .=
774 "<!--[if lte IE 7]>\n<link href=\"lilypond-ie-fixes.css\" rel=\"stylesheet\" type=\"text/css\">\n<![endif]-->\n";
781 #############################################################################
782 ### SPLITTING BASED ON NUMBERED SECTIONS
783 #############################################################################
787 my $node_to_filename_map = ();
790 # This function makes sure that files are only generated for numbered sections,
791 # but not for unnumbered ones. It is called after texi2html has done its own
792 # splitting and simply returns the filename for the node given as first argument
793 # Nodes with the same filename will be printed out to the same filename, so
794 # this really all we need. Also, make sure that the file names for sections
795 # are derived from the section title. We also might want to name the anchors
796 # according to node titles, which works by simply overriding the id element of
798 # If an external nodename<=>filename/anchor map file is found (loaded in
799 # the command handler, use the externally created values, otherwise use the
801 sub lilypond_element_file_name($$$)
805 my $docu_name = shift;
806 my $docu_ext = $Texi2HTML::Config::EXTENSION;
808 my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
809 # the snippets page does not use nodes for the snippets, so in this case
810 # we'll have to use the section name!
811 if ($node_name eq '') {
812 $node_name = main::remove_texi($element->{'texi'});
815 # If we have an entry in the section<=>filename map, use that one, otherwise
816 # generate the filename/anchor here. In the latter case, external manuals
817 # will not be able to retrieve the file name for xrefs!!! Still, I already
818 # had that code, so I'll leave it in in case something goes wrong with the
819 # extract_texi_filenames.py script in the lilypond build process!
820 if (exists ($node_to_filename_map->{$node_name})) {
821 (my $filename, my $anchor) = @{$node_to_filename_map->{$node_name}};
822 $filename .= ".$docu_ext" if (defined($docu_ext));
823 # don't do lc_last here, otherwise the colors are messed up!
824 $filename = lc($filename);
826 # unnumbered sections (except those at top-level!) always go to the same
827 # file as the previous numbered section
828 if (not ($web_manual) and not ($element->{number})
829 and not ($lastfilename eq '') and ($element->{level} > 1)) {
830 $filename = $lastfilename;
832 if (($filename eq $lastfilename)) {
833 $$element{doc_nr} = $docnr;
836 $$element{doc_nr} = $docnr;
837 $lastfilename = $filename;
839 #print STDERR "Output file name: $filename\n";
840 $filename = lc_last($filename);
843 } elsif ($type eq "top" or $type eq "toc" or $type eq "doc" or
844 $type eq "stoc" or $type eq "foot" or $type eq "about") {
847 print STDERR "WARNING: Node '$node_name' was NOT found in the map\n"
848 unless ($node_name eq '') or ($element->{'tag'} eq 'unnumberedsec')
849 or ($node_name =~ /NOT REALLY USED/);
851 # Numbered sections will get a filename Node_title, unnumbered sections will use
852 # the file name of the previous numbered section:
853 if (($element->{number}) or ($lastfilename eq '') or ($element->{level} == 1)) {
854 # normalize to the same file name as texinfo
855 if ($element->{translationof}) {
856 $node_name = main::remove_texi($element->{translationof});
858 my $filename = texinfo_file_name($node_name);
859 $filename .= ".$docu_ext" if (defined($docu_ext));
860 $filename = lc_last($filename);
862 $$element{doc_nr} = $docnr;
863 $lastfilename = $filename;
864 print STDERR "File name: $filename\n";
867 $$element{doc_nr} = $docnr;
868 $filename = lc_last($filename);
869 print STDERR "File name: $filename\n";
877 sub lilypond_element_target_name($$$)
882 # Target is based on node name (or sec name for secs without node attached)
883 my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
884 if ($node_name eq '') {
885 $node_name = main::remove_texi($element->{'texi'});
888 # If we have an entry in the section<=>filename map, use that one, otherwise
889 # generate the anchor here.
890 if (exists ($node_to_filename_map->{$node_name})) {
891 (my $filename, $target) = @{$node_to_filename_map->{$node_name}};
893 my $anchor = $node_name;
894 if ($element->{translationof}) {
895 $anchor = main::remove_texi($element->{translationof});
897 # normalize to the same file name as texinfo
898 $target = texinfo_file_name($anchor);
900 # TODO: Once texi2html correctly prints out the target and not the id for
901 # the sections, change this back to ($id, $target)
902 # I don't understand this comment, so I'm reluctant to delete it -gp
903 $target = lc_last($target);
904 if ($target eq lc_last($id)) {
907 $id = substr($id, 0, - 2); # remove the "-1"
909 return ($id, $target);
913 ## Load the map file for the corrently processed texi file. We do this
914 # using a command init handler, since texi2html does not have any
915 # other hooks that are called after THISDOC is filled but before phase 2
916 # of the texi2html conversion.
917 sub lilypond_init_map ()
919 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
920 my $map_filename = main::locate_include_file ("${docu_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
921 || main::locate_include_file ("${docu_name}.xref-map");
922 #print STDERR "Map filename is: $map_filename\nDocu name is $docu_name\n";
923 if ($docu_name eq 'web') {
927 $node_to_filename_map = load_map_file ($map_filename);
929 push @Texi2HTML::Config::command_handler_init, \&lilypond_init_map;
933 #############################################################################
934 ### CLEANER LINK TITLE FOR EXTERNAL REFS
935 #############################################################################
937 # The default formatting of external refs returns e.g.
938 # "(lilypond-internals)Timing_translator", so we remove all (...) from the
939 # file_and_node argument. Also, we want only a very simple format, so we don't
940 # even call the default handler!
941 sub lilypond_external_ref($$$$$$)
946 my $file_node = shift;
949 $href = lc_last($href);
951 my $cross_ref = shift;
953 my $displaytext = '';
955 # 1) if we have a cross ref name, that's the text to be displayed:
956 # 2) For the top node, use the (printable) name of the manual, unless we
957 # have an explicit cross ref name
958 # 3) In all other cases use the section name
959 if ($cross_ref ne '') {
960 $displaytext = $cross_ref;
961 } elsif (($section eq '') or ($section eq 'Top')) {
962 $displaytext = $book;
964 $displaytext = $section;
967 $displaytext = &$anchor('', $href, $displaytext) if ($displaytext ne '');
968 return &$I('%{node_file_href}', { 'node_file_href' => $displaytext });
975 #############################################################################
976 ### HANDLING TRANSLATED SECTIONS: handle @translationof, secname<->filename
977 ### map stored on disk, xrefs in other manuals load that map
978 #############################################################################
981 # Try to make use of @translationof to generate files according to the original
982 # English section title...
983 sub lilypond_unknown($$$$$)
991 # the @translationof macro provides the original English section title,
992 # which should be used for file/anchor naming, while the title will be
993 # translated to each language
994 # It is already used by extract_texi_filenames.py, so this should not be
995 # necessary here at all. Still, I'll leave the code in just in case the
996 # python script messed up ;-)
997 if ($pass == 1 and $macro eq "translationof") {
998 if (ref($state->{'element'}) eq 'HASH') {
999 $state->{'element'}->{'translationof'} = main::normalise_space($line);
1001 return ('', 1, undef, undef);
1003 return &$default_unknown($macro, $line, $pass, $stack, $state);
1008 my %translated_books = ();
1009 # Construct a href to an external source of information.
1010 # node is the node with texinfo @-commands
1011 # node_id is the node transliterated and transformed as explained in the
1013 # node_xhtml_id is the node transformed such that it is unique and can
1014 # be used to make an html cross ref as explained in the texinfo manual
1015 # file is the file in '(file)node'
1016 sub lilypond_external_href($$$)
1019 my $node_id = shift;
1020 my $node_hxmlt_id = shift;
1023 # 1) Keep a hash of book->section_map
1024 # 2) if not file in keys hash => try to load the map (assign empty map if
1025 # non-existent => will load only once!)
1026 # 3) if node in the section=>(file, anchor) map, replace node_id and
1027 # node_xhtml_id by the map's values
1028 # 4) call the default_external_href with these values (or the old ones if not found)
1030 if (($node_id ne '') and defined($file) and ($node_id ne 'Top')) {
1031 my $map_name = $file;
1032 $map_name =~ s/-big-page//;
1034 # Load the map if we haven't done so already
1035 if (!exists($translated_books{$map_name})) {
1036 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1037 my $map_filename = main::locate_include_file ("${map_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
1038 || main::locate_include_file ("${map_name}.xref-map");
1039 $translated_books{$map_name} = load_map_file ($map_filename);
1042 # look up translation. use these values instead of the old filename/anchor
1043 my $section_name_map = $translated_books{$map_name};
1044 my $node_text = main::remove_texi($node);
1045 if (defined($section_name_map->{$node_text})) {
1046 ($node_id, $node_hxmlt_id) = @{$section_name_map->{$node_text}};
1048 print STDERR "WARNING: Unable to find node '$node_text' in book $map_name.\n";
1052 if (defined $file) {
1053 $href = &$default_external_href($node, $node_id, $node_hxmlt_id, lc_last($file));
1054 remove_unneeded_anchor($href);
1056 # TODO: very yucky, but will be fixed in issue 1004
1058 my $only_web = $ENV{ONLY_WEB};
1060 $href = "../../doc/v2.13/Documentation/web/".$href;
1066 $href = &$default_external_href($node, $node_id, $node_hxmlt_id);
1067 remove_unneeded_anchor($href);
1072 sub remove_unneeded_anchor($)
1075 my @hrefsplit = split("/", $href);
1076 for ($i = 0; $i < @hrefsplit; $i++) {
1077 $item = @hrefsplit[$i];
1079 @splitted = split("#", $item);
1080 if (@splitted[0] == @splitted[1]) {
1081 @hrefsplit[$i] = @splitted[0]
1085 $href = join("/", @hrefsplit);
1091 #############################################################################
1092 ### CUSTOM TOC FOR EACH PAGE (in a frame on the left)
1093 #############################################################################
1095 my $page_toc_depth = 2;
1096 my @default_toc = [];
1098 # Initialize the toc_depth to 1 if the command-line option -D=short_toc is given
1099 sub lilypond_init_toc_depth ()
1101 if (exists($main::value{'short_toc'}) and not exists($main::value{'bigpage'})
1102 and not $web_manual) {
1103 $page_toc_depth = 1;
1106 # Set the TOC-depth (depending on a texinfo variable short_toc) in a
1107 # command-handler, so we have them available when creating the pages
1108 push @Texi2HTML::Config::command_handler_process, \&lilypond_init_toc_depth;
1112 # recursively generate the TOC entries for the element and its children (which
1113 # are only shown up to maxlevel. All ancestors of the current element are also
1114 # shown with their immediate children, irrespective of their level.
1115 # Unnumbered entries are only printed out if they are at top-level or 2nd level
1116 # or their parent element is an ancestor of the currently viewed node.
1117 # The conditions to call this method to print the entry for a child node is:
1118 # -) the parent is an ancestor of the current page node
1119 # -) the parent is a numbered element at top-level toplevel (i.e. show numbered
1120 # and unnumbered 2nd-level children of numbered nodes)
1121 # -) the child element is a numbered node below level maxlevel
1122 sub generate_ly_toc_entries($$$$$)
1124 my $element = shift;
1125 my $element_path = shift;
1126 my $maxlevel = shift;
1130 my $child_count = shift;
1131 my $current_element = shift;
1132 # Skip undefined sections, plus all sections generated by index splitting
1133 return() if (not defined($element) or exists($element->{'index_page'}));
1135 my $level = $element->{'toc_level'};
1136 my $is_parent_of_current = $element->{'id'} && $element_path->{$element->{'id'}};
1137 my $ind = ' ' x $level;
1138 my $this_css_class = " class=\"";
1139 # color indices for the second navigation bar on the website
1142 'introduction' => [2, 2, 2, 2, 3, 3, 4, 4],
1143 'download' => [2, 2, 2, 3, 3, 4],
1144 'manuals' => [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4],
1145 'community' => [1, 1, 1, 2, 2, 2, 3, 3],
1147 my $addColor = "colorDefault";
1148 while (($top_section, $color_indices) = each %color_maps) {
1149 if (index ($element->{'sectionup'}->{'file'}, $top_section) >= 0) {
1150 $addColor = "color" . $color_indices->[$child_count];
1153 $this_css_class .= $addColor;
1155 $this_css_class .= $is_parent_of_current ? ' toc_current"' : '"';
1156 my $entry = "$ind<li$this_css_class>" .
1157 &$anchor ($element->{'tocid'},
1158 "$element->{'file'}#$element->{'target'}",
1159 $element->{'text'});
1161 push (@result, $entry);
1162 my $children = $element->{'section_childs'};
1163 if (defined($children) and (ref($children) eq "ARRAY")) {
1164 my $force_children = $is_parent_of_current or ($level == 1 and $element->{'number'});
1165 my @child_result = ();
1166 my $sub_child_count = 0;
1167 foreach my $c (@$children) {
1168 my $is_numbered_child = defined ($c->{'number'});
1169 my $below_maxlevel = $c->{'toc_level'} le $maxlevel;
1170 if ($force_children or ($is_numbered_child and $below_maxlevel)) {
1172 generate_ly_toc_entries($c, $element_path, $maxlevel, $sub_child_count, $current_element);
1173 push (@child_result, @child_res);
1174 $sub_child_count += 1;
1177 # if no child nodes were generated, e.g. for the index, where expanded pages
1178 # are ignored, don't generate a list at all...
1179 if (@child_result) {
1180 push (@result, "\n$ind<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
1182 push (@result, "$ind<li class=\"colorDefault" .
1183 ($element->{'text'} eq $current_element->{'text'} ?
1184 ' toc_current">' : '">') .
1185 &$anchor ($element->{'tocid'},
1186 "$element->{'file'}#$element->{'target'}",
1187 $element->{'text'}) . "</li>\n");
1189 push (@result, @child_result);
1190 push (@result, "$ind</ul>\n");
1193 push (@result, "$ind</li>\n");
1198 # Print a customized TOC, containing only the first two levels plus the whole
1199 # path to the current page
1200 sub lilypond_generate_page_toc_body($)
1202 my $element = shift;
1203 my $current_element = $element;
1205 $parentelements{$element->{'id'}} = 1;
1206 # Find the path to the current element
1207 while ( defined($current_element->{'sectionup'}) and
1208 ($current_element->{'sectionup'} ne $current_element) )
1210 $parentelements{$current_element->{'sectionup'}->{'id'}} = 1
1211 if ($current_element->{'sectionup'}->{'id'} ne '');
1212 $current_element = $current_element->{'sectionup'};
1214 if (exists($main::value{'shallow_toc'})) {
1219 return () if not defined($current_element);
1220 # Create the toc entries recursively
1221 my @toc_entries = "";
1223 @toc_entries = "<ul$NO_BULLET_LIST_ATTRIBUTE>\n";
1224 # FIXME: add link to main page, really hackily.
1225 if ($element->{'sectionup'}) {
1226 # it's not the top element
1227 push (@toc_entries, "<li><a href=\"index.html\">Main</a></li>\n");
1230 "<li class=\"toc_current\"><a href=\"index.html\">Main</a></li>\n");
1233 push (@toc_entries, "<div class=\"contents\">\n");
1234 push (@toc_entries, "<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
1236 my $children = $current_element->{'section_childs'};
1237 foreach ( @$children ) {
1238 push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth, 0, $element));
1242 my $name = "search-box";
1243 $lang = $Texi2HTML::THISDOC{current_lang};
1244 open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$lang/$name.ihtml" or
1245 open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$name.ihtml" or
1246 die "no such file: $name.ihtml: $!";
1247 my $search_string = decode ('UTF-8', <FILE>);
1248 $search_string = "<li>\n" . $search_string . "</li>\n";
1249 push (@toc_entries, $search_string);
1252 push (@toc_entries, "</ul>\n");
1254 push (@toc_entries, "\n");
1256 push (@toc_entries, "</div>\n");
1258 return @toc_entries;
1261 sub lilypond_print_toc_div ($$)
1265 my @lines = @$tocref;
1266 # use default TOC if no custom lines have been generated
1267 @lines = @default_toc if (not @lines);
1270 print $fh "\n\n<div id=\"tocframe\">\n";
1272 # Remove the leading "GNU LilyPond --- " from the manual title
1273 my $topname = $Texi2HTML::NAME{'Top'};
1274 $topname =~ s/^GNU LilyPond(:| &[mn]dash;) //;
1276 # construct the top-level Docs index (relative path and including language!)
1277 my $lang = $Texi2HTML::THISDOC{current_lang};
1278 if ($lang and $lang ne "en") {
1283 my $reldir = $ENV{DEPTH};
1284 my $uplink = $reldir."/Documentation/web/manuals.${lang}html";
1286 if (not $web_manual) {
1287 print $fh "<p class=\"toc_uplink\"><a href=\"$uplink\"
1288 title=\"Documentation Index\"><< " .
1289 &ly_get_string ('Back to Documentation Index') .
1292 print $fh '<h4 class="toc_header"> ' . &$anchor('',
1293 $Texi2HTML::HREF{'Top'},
1295 'title="Start of the manual"'
1299 foreach my $line (@lines) {
1302 print $fh "</div>\n\n";
1306 # Create the custom TOC for this page (partially folded, current page is
1307 # highlighted) and store it in a global variable. The TOC is written out after
1308 # the html contents (but positioned correctly using CSS), so that browsers with
1309 # css turned off still show the contents first.
1310 our @this_page_toc = ();
1311 sub lilypond_print_element_header
1313 my $first_in_page = shift;
1314 my $previous_is_top = shift;
1315 if ($first_in_page and not @this_page_toc) {
1316 if (defined($Texi2HTML::THIS_ELEMENT)) {
1317 # Create the TOC for this page
1318 @this_page_toc = lilypond_generate_page_toc_body($Texi2HTML::THIS_ELEMENT);
1321 return &$default_print_element_header( $first_in_page, $previous_is_top);
1324 # Generate the HTML output for the TOC
1325 sub lilypond_toc_body($)
1327 my $elements_list = shift;
1328 # Generate a default TOC for pages without THIS_ELEMENT
1329 @default_toc = lilypond_generate_page_toc_body(@$elements_list[0]);
1330 return &$default_toc_body($elements_list);
1333 # Print out the TOC in a <div> at the beginning of the page
1334 sub lilypond_print_page_head($)
1337 &$default_print_page_head($fh);
1338 print $fh "<div id=\"main\">\n";
1341 # Print out the TOC in a <div> at the end of th page, which will be formatted as a
1342 # sidebar mimicking a TOC frame
1343 sub print_lilypond_page_foot($)
1346 my $program_string = &$program_string();
1347 # print $fh "<p><font size='-1'>$program_string</font><br>$PRE_BODY_CLOSE</p>\n";
1348 print $fh "<!-- FOOTER -->\n\n";
1349 print $fh "<!-- end div#main here -->\n</div>\n\n";
1351 # FIXME: This div and p#languages need to be in div#footer.
1352 # Should we move this div to postprocess_html.py ?
1353 print $fh "<div id=\"verifier_texinfo\">\n";
1354 print $fh "<h3>Validation</h3>\n";
1355 # FIXME: inlined text substitution, move to ly_get_string as soon as another case is needed
1356 my $webdev_link = "<a href=\"http://www.webdev.nl/\">webdev.nl</a>";
1357 my $lily_site = "<code>lilypond.org</code>";
1358 my $hosting_thanks = &ly_get_string ('<p>Thanks to ${webdev_link} for hosting ${lily_site}.');
1359 # this does the variable substitution ("quoting" in Perlish) after the localization
1360 $hosting_thanks =~ s/(\$\{\w+\})/$1/eeg;
1361 print $fh $hosting_thanks . "\n";
1362 print $fh "<a href=\"http://validator.w3.org/check?uri=referer\">\n";
1363 print $fh "<img src=\"http://www.w3.org/Icons/valid-html401\"\n";
1364 print $fh " alt=\"Valid HTML 4.01 Transitional\"\n";
1365 print $fh " height=\"31\" width=\"88\"></a></p>\n";
1369 # Print the TOC frame and reset the TOC:
1370 lilypond_print_toc_div ($fh, \@this_page_toc);
1371 @this_page_toc = ();
1374 print $fh "</body>\n</html>\n";
1381 #############################################################################
1382 ### NICER / MORE FLEXIBLE NAVIGATION PANELS
1383 #############################################################################
1385 sub get_navigation_text
1388 my $text = $NAVIGATION_TEXT{$button};
1389 if ( ($button eq 'Back') or ($button eq 'FastBack') ) {
1390 $text = $text . $Texi2HTML::NODE{$button} . " ";
1391 } elsif ( ($button eq 'Forward') or ($button eq 'FastForward') ) {
1392 $text = " " . $Texi2HTML::NODE{$button} . $text;
1393 } elsif ( $button eq 'Up' ) {
1394 $text = " ".$text.": " . $Texi2HTML::NODE{$button} . " ";
1400 # Don't automatically create left-aligned table cells for every link, but
1401 # instead create a <td> only on an appropriate '(left|right|center)-aligned-cell-n'
1402 # button text. It's alignment as well as the colspan will be taken from the
1403 # name of the button. Also, add 'newline' button text to create a new table
1404 # row. The texts of the buttons are generated by get_navigation_text and
1405 # will contain the name of the next/previous section/chapter.
1406 sub lilypond_print_navigation
1408 my $buttons = shift;
1409 my $vertical = shift;
1411 my $result = "<table class=\"nav_table\">\n";
1413 $result .= "<tr>" unless $vertical;
1414 my $beginofline = 1;
1415 foreach my $button (@$buttons)
1417 $result .= qq{<tr valign="top" align="left">\n} if $vertical;
1418 # Allow (left|right|center)-aligned-cell and newline as buttons!
1419 if ( $button =~ /^(.*)-aligned-cell-(.*)$/ )
1421 $result .= qq{</td>} unless $beginofline;
1422 $result .= qq{<td valign="middle" align="$1" colspan="$2">};
1425 elsif ( $button eq 'newline' )
1427 $result .= qq{</td>} unless $beginofline;
1428 $result .= qq{</tr>};
1429 $result .= qq{<tr>};
1433 elsif (ref($button) eq 'CODE')
1435 $result .= &$button($vertical);
1437 elsif (ref($button) eq 'SCALAR')
1439 $result .= "$$button" if defined($$button);
1441 elsif (ref($button) eq 'ARRAY')
1443 my $text = $button->[1];
1444 my $button_href = $button->[0];
1445 # verify that $button_href is simple text and text is a reference
1446 if (defined($button_href) and !ref($button_href)
1447 and defined($text) and (ref($text) eq 'SCALAR') and defined($$text))
1449 if ($Texi2HTML::HREF{$button_href})
1451 my $anchor_attributes = '';
1452 if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button_href})) and
1453 ($BUTTONS_ACCESSKEY{$button_href} ne ''))
1455 $anchor_attributes = "accesskey=\"$BUTTONS_ACCESSKEY{$button_href}\"";
1457 if ($USE_REL_REV and (defined($BUTTONS_REL{$button_href})) and
1458 ($BUTTONS_REL{$button_href} ne ''))
1460 $anchor_attributes .= " rel=\"$BUTTONS_REL{$button_href}\"";
1464 $Texi2HTML::HREF{$button_href},
1465 get_navigation_text($$text),
1471 $result .= get_navigation_text($$text);
1475 elsif ($button eq ' ')
1476 { # handle space button
1478 ($ICONS && $ACTIVE_ICONS{' '}) ?
1479 &$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{' '}) :
1480 $NAVIGATION_TEXT{' '};
1483 elsif ($Texi2HTML::HREF{$button})
1484 { # button is active
1485 my $btitle = $BUTTONS_GOTO{$button} ?
1486 'title="' . $BUTTONS_GOTO{$button} . '"' : '';
1487 if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button})) and
1488 ($BUTTONS_ACCESSKEY{$button} ne ''))
1490 $btitle .= " accesskey=\"$BUTTONS_ACCESSKEY{$button}\"";
1492 if ($USE_REL_REV and (defined($BUTTONS_REL{$button})) and
1493 ($BUTTONS_REL{$button} ne ''))
1495 $btitle .= " rel=\"$BUTTONS_REL{$button}\"";
1497 if ($ICONS && $ACTIVE_ICONS{$button})
1501 $Texi2HTML::HREF{$button},
1502 &$button_icon_img($BUTTONS_NAME{$button},
1503 $ACTIVE_ICONS{$button},
1504 $Texi2HTML::SIMPLE_TEXT{$button}),
1513 $Texi2HTML::HREF{$button},
1514 get_navigation_text($button),
1521 { # button is passive
1523 $ICONS && $PASSIVE_ICONS{$button} ?
1524 &$button_icon_img($BUTTONS_NAME{$button},
1525 $PASSIVE_ICONS{$button},
1526 $Texi2HTML::SIMPLE_TEXT{$button}) :
1528 "[" . get_navigation_text($button) . "]";
1530 $result .= "</td>\n" if $vertical;
1531 $result .= "</tr>\n" if $vertical;
1533 $result .= "</td>" unless $beginofline;
1534 $result .= "</tr>" unless $vertical;
1535 $result .= "</table>\n";
1544 @Texi2HTML::Config::SECTION_BUTTONS =
1545 ('left-aligned-cell-1', 'FastBack',
1546 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1547 'right-aligned-cell-1', 'FastForward',
1549 'left-aligned-cell-2', 'Back',
1550 'center-aligned-cell-1', 'Up',
1551 'right-aligned-cell-2', 'Forward'
1554 # buttons for misc stuff
1555 @Texi2HTML::Config::MISC_BUTTONS = ('center-aligned-cell-3',
1556 'Top', 'Contents', 'Index', 'About');
1558 # buttons for chapter file footers
1559 # (and headers but only if SECTION_NAVIGATION is false)
1560 @Texi2HTML::Config::CHAPTER_BUTTONS =
1561 ('left-aligned-cell-1', 'FastBack',
1562 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1563 'right-aligned-cell-1', 'FastForward',
1566 # buttons for section file footers
1567 @Texi2HTML::Config::SECTION_FOOTER_BUTTONS =
1568 ('left-aligned-cell-1', 'FastBack',
1569 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1570 'right-aligned-cell-1', 'FastForward',
1572 'left-aligned-cell-2', 'Back',
1573 'center-aligned-cell-1', 'Up',
1574 'right-aligned-cell-2', 'Forward'
1577 @Texi2HTML::Config::NODE_FOOTER_BUTTONS =
1578 ('left-aligned-cell-1', 'FastBack',
1579 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1580 'right-aligned-cell-1', 'FastForward',
1582 'left-aligned-cell-2', 'Back',
1583 'center-aligned-cell-1', 'Up',
1584 'right-aligned-cell-2', 'Forward'
1591 #############################################################################
1592 ### FOOTNOTE FORMATTING
1593 #############################################################################
1595 # Format footnotes in a nicer way: Instead of printing the number in a separate
1596 # (nr) heading line, use the standard way of prepending <sup>nr</sup> immediately
1597 # before the fn text.
1600 # The following code is copied from texi2html's examples/makeinfo.init and
1601 # should be updated when texi2html makes some changes there!
1603 my $makekinfo_like_footnote_absolute_number = 0;
1605 sub makeinfo_like_foot_line_and_ref($$$$$$$$)
1607 my $foot_num = shift;
1608 my $relative_num = shift;
1611 my $from_file = shift;
1612 my $footnote_file = shift;
1616 $makekinfo_like_footnote_absolute_number++;
1618 # this is a bit obscure, this allows to add an anchor only if formatted
1619 # as part of the document.
1620 $docid = '' if ($state->{'outside_document'} or $state->{'multiple_pass'});
1622 if ($from_file eq $footnote_file)
1624 $from_file = $footnote_file = '';
1627 my $foot_anchor = "<sup>" .
1628 &$anchor($docid, "$footnote_file#$footid", $relative_num) . "</sup>";
1629 $foot_anchor = &$anchor($docid,
1630 "$footnote_file#$footid",
1631 "($relative_num)") if ($state->{'preformatted'});
1633 # unshift @$lines, "<li>";
1634 # push @$lines, "</li>\n";
1635 return ($lines, $foot_anchor);
1638 sub makeinfo_like_foot_lines($)
1641 unshift @$lines, "<hr>\n<h4>$Texi2HTML::I18n::WORDS->{'Footnotes_Title'}</h4>\n";
1642 #<ol type=\"1\">\n";
1643 # push @$lines, "</ol>";
1647 my %makekinfo_like_paragraph_in_footnote_nr;
1649 sub makeinfo_like_paragraph ($$$$$$$$$$$$$)
1654 my $paragraph_command = shift;
1655 my $paragraph_command_formatted = shift;
1656 my $paragraph_number = shift;
1658 my $item_nr = shift;
1659 my $enumerate_style = shift;
1661 my $command_stack_at_end = shift;
1662 my $command_stack_at_begin = shift;
1664 #print STDERR "format: $format\n" if (defined($format));
1665 #print STDERR "paragraph @$command_stack_at_end; @$command_stack_at_begin\n";
1666 $paragraph_command_formatted = '' if (!defined($paragraph_command_formatted) or
1667 exists($special_list_commands{$format}->{$paragraph_command}));
1668 return '' if ($text =~ /^\s*$/);
1669 foreach my $style(t2h_collect_styles($command_stack_at_begin))
1671 $text = t2h_begin_style($style, $text);
1673 foreach my $style(t2h_collect_styles($command_stack_at_end))
1675 $text = t2h_end_style($style, $text);
1677 if (defined($paragraph_number) and defined($$paragraph_number))
1679 $$paragraph_number++;
1680 return $text if (($format eq 'itemize' or $format eq 'enumerate') and
1681 ($$paragraph_number == 1));
1686 $open .= " align=\"$paragraph_style{$align}\"";
1688 my $footnote_text = '';
1689 if (defined($command_stack_at_begin->[0]) and $command_stack_at_begin->[0] eq 'footnote')
1691 my $state = $Texi2HTML::THISDOC{'state'};
1692 $makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number}++;
1693 if ($makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number} <= 1)
1695 $open.=' class="footnote"';
1696 my $document_file = $state->{'footnote_document_file'};
1697 if ($document_file eq $state->{'footnote_footnote_file'})
1699 $document_file = '';
1701 my $docid = $state->{'footnote_place_id'};
1702 my $doc_state = $state->{'footnote_document_state'};
1703 $docid = '' if ($doc_state->{'outside_document'} or $doc_state->{'multiple_pass'});
1704 my $foot_label = &$anchor($state->{'footnote_footnote_id'},
1705 $document_file . "#$state->{'footnote_place_id'}",
1706 "$state->{'footnote_number_in_page'}");
1707 $footnote_text = "<small>[${foot_label}]</small> ";
1710 return $open.'>'.$footnote_text.$text.'</p>';
1714 #############################################################################
1716 #############################################################################
1718 # For split pages, use index.html as start page!
1719 if ($Texi2HTML::Config::SPLIT eq 'section' or
1720 $Texi2HTML::Config::SPLIT eq 'node') {
1721 $Texi2HTML::Config::TOP_FILE = 'index.html';