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 ### implemented 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 $original_normalise_node = \&normalise_node;
69 sub t2h_default_normalise_node($)
72 $original_normalise_node->($text);
75 *normalise_node = sub($)
78 return &$Texi2HTML::Config::normalise_node($text);
81 package Texi2HTML::Config;
82 ##$normalise_node = \&t2h_default_normalise_node;
83 $normalise_node = \&lilypond_normalise_node;
87 use Encode qw(decode);
89 #############################################################################
91 #############################################################################
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}.',
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}.',
104 $LY_LANGUAGES->{'de'} = {
105 'Back to Documentation Index' => 'Zur Dokumentationsübersicht',
106 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '',
109 $LY_LANGUAGES->{'ja'} = {
110 'Back to Documentation Index' => 'ドキュメント インデックスに戻る',
111 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '',
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.',
119 $LY_LANGUAGES->{'it'} = {
120 'Back to Documentation Index' => 'Torna all\'indice della documentazione',
121 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '',
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}.' => '',
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:',
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',
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',
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',
167 'Index Entry' => 'Voce dell\'indice',
168 'January' => 'Gennaio',
170 'Jump to' => 'Salta a',
173 'Last section in reading order' => 'Ultima sezione in ordine di lettura',
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',
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',
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}',
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}}}.',
232 'Untitled Document' => 'Documento senza titolo',
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}}',
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}',
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}'
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ő:',
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}\'@}',
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',
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',
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',
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',
301 'Index' => 'Tárgymutató',
302 'Index Entry' => 'Tárgymutató-bejegyzés',
303 'January' => 'január',
305 'Jump to' => 'Ugorj ide',
308 'Last section in reading order' => 'Utolsó szakasz az olvasási sorrendben',
309 'March' => 'március',
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',
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',
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}.',
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.',
367 'Untitled Document' => 'Névtelen dokumentum',
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}}',
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}',
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}'
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 } であると仮定しています:',
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}\'@}',
410 'About (help)' => '情報 (ヘルプ)',
411 'About This Document' => 'このドキュメントについて',
415 'Back section in previous file' => '',
416 'Beginning of this chapter or previous chapter' => 'この章あるいは前の章の先頭',
419 'Cover (top) of document' => 'ドキュメントの表紙 (先頭)',
421 'Current Position' => '現在の位置',
422 'Current section' => '',
423 'December' => '12 月',
428 'First section in reading order' => '',
430 'Following node' => '',
433 'Forward section in next file' => '',
434 'From 1.2.3 go to' => '1.2.3 からの行き先',
437 'Index Entry' => 'インデックス エントリ',
443 'Last section in reading order' => '',
449 'Next chapter' => '次の章',
452 'Next section in reading order' => '次のセクション',
453 'Next section on same level' => '',
455 'Node following in node reading order' => '',
460 'November' => '11 月',
466 'Previous file' => '',
467 'Previous node' => '',
468 'Previous section in reading order' => '前のセクション',
469 'Previous section on same level' => '',
470 'Section' => 'セクション',
471 'Section One' => 'セクション 1',
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}' => '',
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}.' => '',
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}}} を用いて生成されました。',
502 'Untitled Document' => '',
505 'Up section' => '上のセクション',
507 'on @emph{{date}}' => '@emph{{date}} に',
508 'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '',
509 'section `{section}\' in @cite{{book}}' => '',
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}' => '',
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}' => '',
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}'
536 sub ly_get_string () {
537 my $lang = $Texi2HTML::THISDOC{current_lang};
539 if ($lang and $lang ne "en" and $LY_LANGUAGES->{$lang}->{$string}) {
540 return $LY_LANGUAGES->{$lang}->{$string};
547 #############################################################################
548 ### FUNCTIONALITY FOR MAIN WEB PAGES
549 #############################################################################
553 #############################################################################
554 ### SETTINGS FOR TEXI2HTML
555 #############################################################################
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">';
560 @Texi2HTML::Config::CSS_REFS = (
561 {FILENAME => "lilypond-manuals.css", TITLE => "Default style"}
563 @Texi2HTML::Config::ALT_CSS_REFS = (
567 print STDERR "Initializing settings for web site: [$Texi2HTML::THISDOC{current_lang}]\n";
568 $Texi2HTML::Config::BODYTEXT = "";
569 @Texi2HTML::Config::CSS_REFS = (
570 {FILENAME => "lilypond-website.css", TITLE => "Default style"}
572 @Texi2HTML::Config::ALT_CSS_REFS = (
576 $Texi2HTML::Config::USE_ACCESSKEY = 1;
577 $Texi2HTML::Config::USE_LINKS = 1;
578 $Texi2HTML::Config::USE_REL_REV = 1;
579 $Texi2HTML::Config::SPLIT_INDEX = 0;
580 $Texi2HTML::Config::SEPARATED_FOOTNOTES = 0; # Print footnotes on same page, not separated
583 my $have_index_entries = 0;
584 if ($Texi2HTML::Config::SPLIT eq 'section' or
585 $Texi2HTML::Config::SPLIT eq 'node') {
586 $Texi2HTML::Config::element_file_name = \&lilypond_element_file_name;
592 $Texi2HTML::Config::anchor = \&lilypond_anchor;
593 $Texi2HTML::Config::element_target_name = \&lilypond_element_target_name;
594 $default_print_element_header = $Texi2HTML::Config::print_element_header;
595 $Texi2HTML::Config::print_element_header = \&lilypond_print_element_header;
596 $Texi2HTML::Config::print_page_foot = \&print_lilypond_page_foot;
597 $Texi2HTML::Config::print_navigation = \&lilypond_print_navigation;
598 $Texi2HTML::Config::external_ref = \&lilypond_external_ref;
599 $default_external_href = $Texi2HTML::Config::external_href;
600 $Texi2HTML::Config::external_href = \&lilypond_external_href;
601 $default_toc_body = $Texi2HTML::Config::toc_body;
602 $Texi2HTML::Config::toc_body = \&lilypond_toc_body;
603 $Texi2HTML::Config::css_lines = \&lilypond_css_lines;
604 $default_unknown = $Texi2HTML::Config::unknown;
605 $Texi2HTML::Config::unknown = \&lilypond_unknown;
606 $default_print_page_head = $Texi2HTML::Config::print_page_head;
607 $Texi2HTML::Config::print_page_head = \&lilypond_print_page_head;
608 # $Texi2HTML::Config::foot_line_and_ref = \&lilypond_foot_line_and_ref;
609 $Texi2HTML::Config::foot_line_and_ref = \&makeinfo_like_foot_line_and_ref;
610 $Texi2HTML::Config::foot_lines = \&makeinfo_like_foot_lines;
611 $Texi2HTML::Config::paragraph = \&makeinfo_like_paragraph;
615 # Examples should be formatted similar to quotes:
616 $Texi2HTML::Config::complex_format_map->{'example'} = {
617 'begin' => q{"<blockquote>"},
618 'end' => q{"</blockquote>\n"},
622 %Texi2HTML::config::misc_pages_targets = (
623 'Overview' => 'Overview',
624 'Contents' => 'Contents',
629 my @section_to_filename;
634 #############################################################################
636 #############################################################################
639 $Data::Dumper::Maxdepth = 2;
641 sub print_element_info($)
644 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
645 print "Element: $element\n";
646 print Dumper($element);
653 #############################################################################
655 #############################################################################
657 # only lc() the last portion of an href
661 my @hrefsplit = split('/', $href);
662 # change the last portion (the filename), if it exists;
663 # if it is a plain filename with no path, change the string as a whole
664 if ($#hrefsplit > 0) {
665 @hrefsplit[$#hrefsplit] = lc( @hrefsplit[$#hrefsplit] );
666 $href = join("/", @hrefsplit);
673 # Convert a given node name to its proper file name (normalization as explained
674 # in the texinfo manual:
675 # http://www.gnu.org/software/texinfo/manual/texinfo/html_node/HTML-Xref-Node-Name-Expansion.html
676 sub texinfo_file_name($)
680 # File name normalization by texinfo:
681 # 1/2: letters and numbers are left unchanged
682 # 3/4: multiple, leading and trailing whitespace is removed
683 $text = main::normalise_space($text);
684 # 5/6: all remaining spaces are converted to '-', all other 7- or 8-bit
685 # chars are replaced by _xxxx (xxxx=ascii character code)
686 while ($text ne '') {
687 if ($text =~ s/^([A-Za-z0-9]+)//o) { # number or letter stay unchanged
689 } elsif ($text =~ s/^ //o) { # space -> '-'
691 } elsif ($text =~ s/^(.)//o) { # Otherwise use _xxxx (ascii char code)
693 if ( $ccode <= 0xFFFF ) {
694 $result .= sprintf("_%04x", $ccode);
696 $result .= sprintf("__%06x", $ccode);
700 # 7: if name does not begin with a letter, prepend 't_g' (so it starts with a letter)
701 if ($result !~ /^[a-zA-Z]/) {
702 $result = 't_g' . $result;
705 return lc_last($result)
708 # Load a file containing a nodename<=>filename map (tab-sepatared, i.e.
709 # NODENAME\tFILENAME\tANCHOR
710 # Returns a ref to a hash "Node title" => ["FilenameWithoutExt", "Anchor"]
711 sub load_map_file ($)
716 # For some unknown reason, Perl on my system (5.10.0 on Fedora 12)
717 # refuses to open map files of translated documents with
718 # '<:encoding(utf8)', but decoding from UTF-8 line by line works. -jm
719 if (open(XREFFILE,'<', $mapfile)) {
721 # print STDERR "*** PRINTING MAP FILE LINES ***\n";
722 while ( $line = decode ('UTF-8', <XREFFILE>) ) {
723 # parse the tab-separated entries and insert them into the map:
725 my @entries = split(/\t/, $line);
726 if (scalar (@entries) == 3) {
727 $node_map->{$entries[0]} = [$entries[1], $entries[2]];
729 # print STDERR @entries;
732 print STDERR "Invalid entry in the node file $mapfile: $line\n";
737 print STDERR "WARNING: Unable to load the map file $mapfile\n";
743 # Split the given path into dir and basename (with .texi removed). Used mainly
744 # to get the path/basename of the original texi input file
745 sub split_texi_filename ($)
748 my ($docu_dir, $docu_name);
749 if ($docu =~ /(.*\/)/) {
750 chop($docu_dir = $1);
752 $docu_name =~ s/.*\///;
757 $docu_name =~ s/\.te?x(i|info)?$//;
758 return ($docu_dir, $docu_name);
765 #############################################################################
767 #############################################################################
769 # Include our standard CSS file, not hard-coded CSS code directly in the HTML!
770 # For IE, conditionally include the lilypond-ie-fixes.css style sheet
771 sub lilypond_css_lines ($$)
773 my $import_lines = shift;
774 my $rule_lines = shift;
775 return if (defined($Texi2HTML::THISDOC{'CSS_LINES'}));
776 if (@$rule_lines or @$import_lines)
778 $Texi2HTML::THISDOC{'CSS_LINES'} = "<style type=\"text/css\">\n<!--\n";
779 $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$import_lines) . "\n" if (@$import_lines);
780 $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$rule_lines) . "\n" if (@$rule_lines);
781 $Texi2HTML::THISDOC{'CSS_LINES'} .= "-->\n</style>\n";
783 foreach my $ref (@CSS_REFS)
785 $Texi2HTML::THISDOC{'CSS_LINES'} .=
786 "<link rel=\"stylesheet\" type=\"text/css\" title=\"$ref->{TITLE}\" href=\"$ref->{FILENAME}\">\n";
788 foreach my $ref (@Texi2HTML::Config::ALT_CSS_REFS)
790 $Texi2HTML::THISDOC{'CSS_LINES'} .=
791 "<link rel=\"alternate stylesheet\" type=\"text/css\" href=\"$ref->{FILENAME}\" title=\"$ref->{TITLE}\">\n";
794 # The ie-fixes stylesheet is needed for the docs, but not the website.
795 if (not ($web_manual)) {
796 $Texi2HTML::THISDOC{'CSS_LINES'} .=
797 "<!--[if lte IE 7]>\n<link href=\"lilypond-ie-fixes.css\" rel=\"stylesheet\" type=\"text/css\">\n<![endif]-->\n";
800 if ($ENV{'AJAX_SEARCH'} == 1) {
801 # Add the JavaScript file only if we have an index.
802 # Unfortunately, init_out is called after css_lines, so as a workaround
803 # here we have to check again for the existence of an index...
804 my $ix = main::get_index ("cp");
805 $have_index_entries = (scalar $ix > 0);
807 $reldir = "../" unless $bigpage;
808 if ($have_index_entries) {
809 $Texi2HTML::THISDOC{'CSS_LINES'} .= "<script language=\"JavaScript\" src=\"${reldir}lily_search.js\"></script>\n";
818 #############################################################################
819 ### SPLITTING BASED ON NUMBERED SECTIONS
820 #############################################################################
824 my $node_to_filename_map = ();
825 $source_to_translationof_map = ();
828 # This function makes sure that files are only generated for numbered sections,
829 # but not for unnumbered ones. It is called after texi2html has done its own
830 # splitting and simply returns the filename for the node given as first argument
831 # Nodes with the same filename will be printed out to the same filename, so
832 # this really all we need. Also, make sure that the file names for sections
833 # are derived from the section title. We also might want to name the anchors
834 # according to node titles, which works by simply overriding the id element of
836 # If an external nodename<=>filename/anchor map file is found (loaded in
837 # the command handler, use the externally created values, otherwise use the
839 sub lilypond_element_file_name($$$)
843 my $docu_name = shift;
844 my $docu_ext = $Texi2HTML::Config::EXTENSION;
846 my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
847 # the snippets page does not use nodes for the snippets, so in this case
848 # we'll have to use the section name!
849 if ($node_name eq '') {
850 $node_name = main::remove_texi($element->{'texi'});
853 # If we have an entry in the section<=>filename map, use that one, otherwise
854 # generate the filename/anchor here. In the latter case, external manuals
855 # will not be able to retrieve the file name for xrefs!!! Still, I already
856 # had that code, so I'll leave it in in case something goes wrong with the
857 # extract_texi_filenames.py script in the lilypond build process!
858 if (exists ($node_to_filename_map->{$node_name})) {
859 (my $filename, my $anchor) = @{$node_to_filename_map->{$node_name}};
860 $filename .= ".$docu_ext" if (defined($docu_ext));
861 # don't do lc_last here, otherwise the colors are messed up!
862 $filename = lc($filename);
864 # unnumbered sections (except those at top-level!) always go to the same
865 # file as the previous numbered section
866 if (not ($web_manual) and not ($element->{number})
867 and not ($lastfilename eq '') and ($element->{level} > 1)) {
868 $filename = $lastfilename;
870 if (($filename eq $lastfilename)) {
871 $$element{doc_nr} = $docnr;
874 $$element{doc_nr} = $docnr;
875 $lastfilename = $filename;
877 #print STDERR "Output file name: $filename\n";
878 $filename = lc_last($filename);
881 } elsif ($type eq "top" or $type eq "toc" or $type eq "doc" or
882 $type eq "stoc" or $type eq "foot" or $type eq "about") {
885 print STDERR "WARNING: Node '$node_name' was NOT found in the map\n"
886 unless ($node_name eq '') or ($element->{'tag'} eq 'unnumberedsec')
887 or ($node_name =~ /NOT REALLY USED/);
889 # Numbered sections will get a filename Node_title, unnumbered sections will use
890 # the file name of the previous numbered section:
891 if (($element->{number}) or ($lastfilename eq '') or ($element->{level} == 1)) {
892 # normalize to the same file name as texinfo
893 if ($element->{translationof}) {
894 $node_name = main::remove_texi($element->{translationof});
896 my $filename = texinfo_file_name($node_name);
897 $filename .= ".$docu_ext" if (defined($docu_ext));
898 $filename = lc_last($filename);
900 $$element{doc_nr} = $docnr;
901 $lastfilename = $filename;
902 print STDERR "File name: $filename\n";
905 $$element{doc_nr} = $docnr;
906 $filename = lc_last($filename);
907 print STDERR "File name: $filename\n";
915 sub lilypond_normalise_node($)
918 my $norm = main::t2h_default_normalise_node($text);
919 if (exists ($source_to_translationof_map->{$text})) {
920 my $original = $source_to_translationof_map->{$text};
921 $norm = main::t2h_default_normalise_node($original);
927 # This function produces an anchor.
930 # $name : anchor name
931 # $href : anchor href
932 # text : text displayed
933 # extra_attribs : added to anchor attributes list
934 sub lilypond_anchor($;$$$)
939 my $attributes = shift;
940 $href = remove_unneeded_anchor($href);
941 if (!defined($attributes) or ($attributes !~ /\S/))
947 $attributes = ' ' . $attributes;
949 $name = '' if (!defined($name) or ($name !~ /\S/));
950 $href = '' if (!defined($href) or ($href !~ /\S/));
951 $text = '' if (!defined($text));
952 return $text if (($name eq '') and ($href eq ''));
953 $name = "name=\"$name\"" if ($name ne '');
954 $href = "href=\"$href\"" if ($href ne '');
955 $href = ' ' . $href if (($name ne '') and ($href ne ''));
956 return "<a ${name}${href}${attributes}>$text</a>";
960 sub lilypond_element_target_name($$$)
965 # Target is based on node name (or sec name for secs without node attached)
966 my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
967 if ($node_name eq '') {
968 $node_name = main::remove_texi($element->{'texi'});
971 # If we have an entry in the section<=>filename map, use that one, otherwise
972 # generate the anchor here.
973 if (exists ($node_to_filename_map->{$node_name})) {
974 (my $filename, $target) = @{$node_to_filename_map->{$node_name}};
976 my $anchor = $node_name;
977 if ($element->{translationof}) {
978 $anchor = main::remove_texi($element->{translationof});
980 # normalize to the same file name as texinfo
981 $target = texinfo_file_name($anchor);
983 # TODO: Once texi2html correctly prints out the target and not the id for
984 # the sections, change this back to ($id, $target)
985 # I don't understand this comment, so I'm reluctant to delete it -gp
986 $target = lc_last($target);
988 # $id =~ s/-1$//i; # remove any trailing "-1"
989 return ($target, $id);
993 ## Load the map file for the corrently processed texi file. We do this
994 # using a command init handler, since texi2html does not have any
995 # other hooks that are called after THISDOC is filled but before phase 2
996 # of the texi2html conversion.
997 sub lilypond_init_map ()
999 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1000 my $map_filename = main::locate_include_file ("${docu_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
1001 || main::locate_include_file ("${docu_name}.xref-map");
1002 #print STDERR "Map filename is: $map_filename\nDocu name is $docu_name\n";
1003 if ($docu_name eq 'web') {
1007 $node_to_filename_map = load_map_file ($map_filename);
1009 push @Texi2HTML::Config::command_handler_init, \&lilypond_init_map;
1013 #############################################################################
1014 ### CLEANER LINK TITLE FOR EXTERNAL REFS
1015 #############################################################################
1017 # The default formatting of external refs returns e.g.
1018 # "(lilypond-internals)Timing_translator", so we remove all (...) from the
1019 # file_and_node argument. Also, we want only a very simple format, so we don't
1020 # even call the default handler!
1021 sub lilypond_external_ref($$$$$$)
1024 my $section = shift;
1026 my $file_node = shift;
1029 $href = lc_last($href);
1031 my $cross_ref = shift;
1033 my $displaytext = '';
1035 # 1) if we have a cross ref name, that's the text to be displayed:
1036 # 2) For the top node, use the (printable) name of the manual, unless we
1037 # have an explicit cross ref name
1038 # 3) In all other cases use the section name
1039 if ($cross_ref ne '') {
1040 $displaytext = $cross_ref;
1041 } elsif (($section eq '') or ($section eq 'Top')) {
1042 $displaytext = $book;
1044 $displaytext = $section;
1047 $displaytext = &$anchor('', $href, $displaytext) if ($displaytext ne '');
1048 return &$I('%{node_file_href}', { 'node_file_href' => $displaytext });
1055 #############################################################################
1056 ### HANDLING TRANSLATED SECTIONS: handle @translationof, secname<->filename
1057 ### map stored on disk, xrefs in other manuals load that map
1058 #############################################################################
1061 # Try to make use of @translationof to generate files according to the original
1062 # English section title...
1063 sub lilypond_unknown($$$$$)
1071 # the @translationof macro provides the original English section title,
1072 # which should be used for file/anchor naming, while the title will be
1073 # translated to each language
1074 # It is already used by extract_texi_filenames.py, so this should not be
1075 # necessary here at all. Still, I'll leave the code in just in case the
1076 # python script messed up ;-)
1077 if ($pass == 1 and $macro eq "translationof") {
1078 if (ref($state->{'element'}) eq 'HASH') {
1079 $state->{'element'}->{'translationof'} = main::normalise_space($line);
1080 my $source = main::normalise_space ($line);
1081 if (ref($state->{'node_ref'}) eq 'HASH') {
1082 my $translationof = $state->{'node_ref'}->{'texi'};
1083 our %source_to_translationof_map;
1084 $source_to_translationof_map->{$source} = $translationof;
1087 return ('', 1, undef, undef);
1089 return &$default_unknown($macro, $line, $pass, $stack, $state);
1094 my %translated_books = ();
1095 # Construct a href to an external source of information.
1096 # node is the node with texinfo @-commands
1097 # node_id is the node transliterated and transformed as explained in the
1099 # node_xhtml_id is the node transformed such that it is unique and can
1100 # be used to make an html cross ref as explained in the texinfo manual
1101 # file is the file in '(file)node'
1102 sub lilypond_external_href($$$)
1105 my $node_id = shift;
1106 my $node_xhtml_id = shift;
1109 # 1) Keep a hash of book->section_map
1110 # 2) if not file in keys hash => try to load the map (assign empty map if
1111 # non-existent => will load only once!)
1112 # 3) if node in the section=>(file, anchor) map, replace node_id and
1113 # node_xhtml_id by the map's values
1114 # 4) call the default_external_href with these values (or the old ones if not found)
1116 if (($node_id ne '') and defined($file) and ($node_id ne 'Top')) {
1117 my $map_name = $file;
1118 $map_name =~ s/-big-page//;
1120 # Load the map if we haven't done so already
1121 if (!exists($translated_books{$map_name})) {
1122 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1123 my $map_filename = main::locate_include_file ("${map_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
1124 || main::locate_include_file ("${map_name}.xref-map");
1125 $translated_books{$map_name} = load_map_file ($map_filename);
1128 # look up translation. use these values instead of the old filename/anchor
1129 my $section_name_map = $translated_books{$map_name};
1130 my $node_text = main::remove_texi($node);
1131 if (defined($section_name_map->{$node_text})) {
1132 ($node_id, $node_xhtml_id) = @{$section_name_map->{$node_text}};
1134 print STDERR "WARNING: Unable to find node '$node_text' in book $map_name.\n";
1138 if (defined $file) {
1139 $href = &$default_external_href($node, $node_id, $node_xhtml_id, lc_last($file));
1140 $href = remove_unneeded_anchor($href);
1142 # TODO: very yucky, but will be fixed in issue 1004
1144 my $only_web = $ENV{ONLY_WEB};
1146 $href = "../../doc/v2.13/Documentation/web/".$href;
1152 $href = &$default_external_href($node, $node_id, $node_xhtml_id);
1153 $href = remove_unneeded_anchor($href);
1158 sub remove_unneeded_anchor($)
1161 my @hrefsplit = split("/", $href);
1162 for ($i = 0; $i < @hrefsplit; $i++) {
1163 $item = @hrefsplit[$i];
1165 @splitted = split(".html#", $item);
1166 if (@splitted[0] eq @splitted[1]) {
1167 @hrefsplit[$i] = @splitted[0] . ".html";
1171 $href = join("/", @hrefsplit);
1177 #############################################################################
1178 ### CUSTOM TOC FOR EACH PAGE (in a frame on the left)
1179 #############################################################################
1181 my $page_toc_depth = 2;
1182 my @default_toc = [];
1184 # Initialize the toc_depth to 1 if the command-line option -D=short_toc is given
1185 sub lilypond_init_toc_depth ()
1187 if (exists($main::value{'short_toc'}) and not exists($main::value{'bigpage'})
1188 and not $web_manual) {
1189 $page_toc_depth = 1;
1192 # Set the TOC-depth (depending on a texinfo variable short_toc) in a
1193 # command-handler, so we have them available when creating the pages
1194 push @Texi2HTML::Config::command_handler_process, \&lilypond_init_toc_depth;
1198 # recursively generate the TOC entries for the element and its children (which
1199 # are only shown up to maxlevel. All ancestors of the current element are also
1200 # shown with their immediate children, irrespective of their level.
1201 # Unnumbered entries are only printed out if they are at top-level or 2nd level
1202 # or their parent element is an ancestor of the currently viewed node.
1203 # The conditions to call this method to print the entry for a child node is:
1204 # -) the parent is an ancestor of the current page node
1205 # -) the parent is a numbered element at top-level toplevel (i.e. show numbered
1206 # and unnumbered 2nd-level children of numbered nodes)
1207 # -) the child element is a numbered node below level maxlevel
1208 sub generate_ly_toc_entries($$$$$)
1210 my $element = shift;
1211 my $element_path = shift;
1212 my $maxlevel = shift;
1216 my $child_count = shift;
1217 my $current_element = shift;
1218 # Skip undefined sections, plus all sections generated by index splitting
1219 return() if (not defined($element) or exists($element->{'index_page'}));
1221 my $level = $element->{'toc_level'};
1222 my $is_parent_of_current = $element->{'id'} && $element_path->{$element->{'id'}};
1223 my $ind = ' ' x $level;
1224 my $this_css_class = " class=\"";
1225 # color indices for the second navigation bar on the website
1228 'introduction' => [2, 2, 2, 2, 3, 3, 4, 4],
1229 'download' => [2, 2, 2, 3, 3, 4],
1230 'manuals' => [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4],
1231 'community' => [1, 1, 1, 2, 2, 2, 3, 3],
1233 my $addColor = "colorDefault";
1234 while (($top_section, $color_indices) = each %color_maps) {
1235 if (index ($element->{'sectionup'}->{'file'}, $top_section) >= 0) {
1236 $addColor = "color" . $color_indices->[$child_count];
1239 $this_css_class .= $addColor;
1241 $this_css_class .= $is_parent_of_current ? ' toc_current"' : '"';
1242 my $entry = "$ind<li$this_css_class>" .
1243 &$anchor ($element->{'tocid'},
1244 "$element->{'file'}#$element->{'target'}",
1245 $element->{'text'});
1247 push (@result, $entry);
1248 my $children = $element->{'section_childs'};
1249 if (defined($children) and (ref($children) eq "ARRAY")) {
1250 my $force_children = $is_parent_of_current or ($level == 1 and $element->{'number'});
1251 my @child_result = ();
1252 my $sub_child_count = 0;
1253 foreach my $c (@$children) {
1254 my $is_numbered_child = defined ($c->{'number'});
1255 my $below_maxlevel = $c->{'toc_level'} le $maxlevel;
1256 if ($force_children or ($is_numbered_child and $below_maxlevel)) {
1258 generate_ly_toc_entries($c, $element_path, $maxlevel, $sub_child_count, $current_element);
1259 push (@child_result, @child_res);
1260 $sub_child_count += 1;
1263 # if no child nodes were generated, e.g. for the index, where expanded pages
1264 # are ignored, don't generate a list at all...
1265 if (@child_result) {
1266 push (@result, "\n$ind<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
1268 push (@result, "$ind<li class=\"colorDefault" .
1269 ($element->{'text'} eq $current_element->{'text'} ?
1270 ' toc_current">' : '">') .
1271 &$anchor ($element->{'tocid'},
1272 "$element->{'file'}#$element->{'target'}",
1273 $element->{'text'}) . "</li>\n");
1275 push (@result, @child_result);
1276 push (@result, "$ind</ul>\n");
1279 push (@result, "$ind</li>\n");
1284 # Print a customized TOC, containing only the first two levels plus the whole
1285 # path to the current page
1286 sub lilypond_generate_page_toc_body($)
1288 my $element = shift;
1289 my $current_element = $element;
1291 $parentelements{$element->{'id'}} = 1;
1292 # Find the path to the current element
1293 while ( defined($current_element->{'sectionup'}) and
1294 ($current_element->{'sectionup'} ne $current_element) )
1296 $parentelements{$current_element->{'sectionup'}->{'id'}} = 1
1297 if ($current_element->{'sectionup'}->{'id'} ne '');
1298 $current_element = $current_element->{'sectionup'};
1300 if (exists($main::value{'shallow_toc'})) {
1305 return () if not defined($current_element);
1306 # Create the toc entries recursively
1307 my @toc_entries = "";
1309 @toc_entries = "<ul$NO_BULLET_LIST_ATTRIBUTE>\n";
1310 # FIXME: add link to main page, really hackily.
1311 if ($element->{'sectionup'}) {
1312 # it's not the top element
1313 push (@toc_entries, "<li><a href=\"index.html\">Main</a></li>\n");
1316 "<li class=\"toc_current\"><a href=\"index.html\">Main</a></li>\n");
1319 push (@toc_entries, "<div class=\"contents\">\n");
1320 push (@toc_entries, "<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
1322 my $children = $current_element->{'section_childs'};
1323 foreach ( @$children ) {
1324 push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth, 0, $element));
1327 # I'm assuming that we wouldn't keep the google search box? -gp
1328 if (!($ENV{AJAX_SEARCH} == 1)) {
1330 my $name = "search-box";
1331 $lang = $Texi2HTML::THISDOC{current_lang};
1332 open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$lang/$name.ihtml" or
1333 open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$name.ihtml" or
1334 die "no such file: $name.ihtml: $!";
1335 my $search_string = decode ('UTF-8', <FILE>);
1336 $search_string = "<li>\n" . $search_string . "</li>\n";
1337 push (@toc_entries, $search_string);
1341 push (@toc_entries, "</ul>\n");
1343 push (@toc_entries, "\n");
1345 push (@toc_entries, "</div>\n");
1347 return @toc_entries;
1350 sub lilypond_print_toc_div ($$)
1354 my @lines = @$tocref;
1355 # use default TOC if no custom lines have been generated
1356 @lines = @default_toc if (not @lines);
1359 print $fh "\n\n<div id=\"tocframe\">\n";
1361 # Remove the leading "GNU LilyPond --- " from the manual title
1362 my $topname = $Texi2HTML::NAME{'Top'};
1363 $topname =~ s/^GNU LilyPond(:| &[mn]dash;) //;
1365 # construct the top-level Docs index (relative path and including language!)
1366 my $lang = $Texi2HTML::THISDOC{current_lang};
1367 if ($lang and $lang ne "en") {
1372 my $reldir = $ENV{DEPTH};
1373 # strip one depth level for translations
1374 if ($lang and $lang ne "en" and substr ($reldir, 0, 3) eq '../') {
1375 $reldir = substr ($reldir, 3);
1377 # add a / at the end if there isn't one.
1378 if (substr ($reldir, -1) ne '/') {
1381 my $uplink = $reldir."Documentation/web/manuals.${lang}html";
1383 if (not $web_manual) {
1384 print $fh "<p class=\"toc_uplink\"><a href=\"$uplink\"
1385 title=\"Documentation Index\"><< " .
1386 &ly_get_string ('Back to Documentation Index') .
1389 # AJAX search box, written in JavaScript
1390 if ($ENV{'AJAX_SEARCH'} == 1) {
1391 if ($have_index_entries) {
1392 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1393 print $fh '<script language="JavaScript">print_search_field ("' .
1394 $Texi2HTML::THISDOC{current_lang} . '", "' .
1395 $docu_name . "\", " . $bigpage . ")</script>\n";
1399 print $fh '<h4 class="toc_header"> ' . &$anchor('',
1400 $Texi2HTML::HREF{'Top'},
1402 'title="Start of the manual"'
1406 foreach my $line (@lines) {
1409 print $fh "</div>\n\n";
1413 # Create the custom TOC for this page (partially folded, current page is
1414 # highlighted) and store it in a global variable. The TOC is written out after
1415 # the html contents (but positioned correctly using CSS), so that browsers with
1416 # css turned off still show the contents first.
1417 our @this_page_toc = ();
1418 sub lilypond_print_element_header
1420 my $first_in_page = shift;
1421 my $previous_is_top = shift;
1422 if ($first_in_page and not @this_page_toc) {
1423 if (defined($Texi2HTML::THIS_ELEMENT)) {
1424 # Create the TOC for this page
1425 @this_page_toc = lilypond_generate_page_toc_body($Texi2HTML::THIS_ELEMENT);
1428 return &$default_print_element_header( $first_in_page, $previous_is_top);
1431 # Generate the HTML output for the TOC
1432 sub lilypond_toc_body($)
1434 my $elements_list = shift;
1435 # Generate a default TOC for pages without THIS_ELEMENT
1436 @default_toc = lilypond_generate_page_toc_body(@$elements_list[0]);
1437 return &$default_toc_body($elements_list);
1440 # Print out the TOC in a <div> at the beginning of the page
1441 sub lilypond_print_page_head($)
1444 &$default_print_page_head($fh);
1445 print $fh "<div id=\"main\">\n";
1448 # Print out the TOC in a <div> at the end of th page, which will be formatted as a
1449 # sidebar mimicking a TOC frame
1450 sub print_lilypond_page_foot($)
1453 my $program_string = &$program_string();
1454 # print $fh "<p><font size='-1'>$program_string</font><br>$PRE_BODY_CLOSE</p>\n";
1455 print $fh "<!-- FOOTER -->\n\n";
1456 print $fh "<!-- end div#main here -->\n</div>\n\n";
1458 # FIXME: This div and p#languages need to be in div#footer.
1459 # Should we move this div to postprocess_html.py ?
1460 print $fh "<div id=\"verifier_texinfo\">\n";
1461 print $fh "<h3>Validation</h3>\n";
1462 # FIXME: inlined text substitution, move to ly_get_string as soon as another case is needed
1463 my $webdev_link = "<a href=\"http://www.webdev.nl/\">webdev.nl</a>";
1464 my $lily_site = "<code>lilypond.org</code>";
1465 my $hosting_thanks = &ly_get_string ('<p>Thanks to ${webdev_link} for hosting ${lily_site}.');
1466 # this does the variable substitution ("quoting" in Perlish) after the localization
1467 $hosting_thanks =~ s/(\$\{\w+\})/$1/eeg;
1468 print $fh $hosting_thanks . "\n";
1469 print $fh "<a href=\"http://validator.w3.org/check?uri=referer\">\n";
1470 print $fh "<img src=\"http://www.w3.org/Icons/valid-html401\"\n";
1471 print $fh " alt=\"Valid HTML 4.01 Transitional\"\n";
1472 print $fh " height=\"31\" width=\"88\"></a></p>\n";
1476 # Print the TOC frame and reset the TOC:
1477 lilypond_print_toc_div ($fh, \@this_page_toc);
1478 @this_page_toc = ();
1481 print $fh "</body>\n</html>\n";
1488 #############################################################################
1489 ### NICER / MORE FLEXIBLE NAVIGATION PANELS
1490 #############################################################################
1492 sub get_navigation_text
1495 my $text = $NAVIGATION_TEXT{$button};
1496 if ( ($button eq 'Back') or ($button eq 'FastBack') ) {
1497 $text = $text . $Texi2HTML::NODE{$button} . " ";
1498 } elsif ( ($button eq 'Forward') or ($button eq 'FastForward') ) {
1499 $text = " " . $Texi2HTML::NODE{$button} . $text;
1500 } elsif ( $button eq 'Up' ) {
1501 $text = " ".$text.": " . $Texi2HTML::NODE{$button} . " ";
1507 # Don't automatically create left-aligned table cells for every link, but
1508 # instead create a <td> only on an appropriate '(left|right|center)-aligned-cell-n'
1509 # button text. It's alignment as well as the colspan will be taken from the
1510 # name of the button. Also, add 'newline' button text to create a new table
1511 # row. The texts of the buttons are generated by get_navigation_text and
1512 # will contain the name of the next/previous section/chapter.
1513 sub lilypond_print_navigation
1515 my $buttons = shift;
1516 my $vertical = shift;
1518 my $result = "<table class=\"nav_table\">\n";
1520 $result .= "<tr>" unless $vertical;
1521 my $beginofline = 1;
1522 foreach my $button (@$buttons)
1524 $result .= qq{<tr valign="top" align="left">\n} if $vertical;
1525 # Allow (left|right|center)-aligned-cell and newline as buttons!
1526 if ( $button =~ /^(.*)-aligned-cell-(.*)$/ )
1528 $result .= qq{</td>} unless $beginofline;
1529 $result .= qq{<td valign="middle" align="$1" colspan="$2">};
1532 elsif ( $button eq 'newline' )
1534 $result .= qq{</td>} unless $beginofline;
1535 $result .= qq{</tr>};
1536 $result .= qq{<tr>};
1540 elsif (ref($button) eq 'CODE')
1542 $result .= &$button($vertical);
1544 elsif (ref($button) eq 'SCALAR')
1546 $result .= "$$button" if defined($$button);
1548 elsif (ref($button) eq 'ARRAY')
1550 my $text = $button->[1];
1551 my $button_href = $button->[0];
1552 # verify that $button_href is simple text and text is a reference
1553 if (defined($button_href) and !ref($button_href)
1554 and defined($text) and (ref($text) eq 'SCALAR') and defined($$text))
1556 if ($Texi2HTML::HREF{$button_href})
1558 my $anchor_attributes = '';
1559 if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button_href})) and
1560 ($BUTTONS_ACCESSKEY{$button_href} ne ''))
1562 $anchor_attributes = "accesskey=\"$BUTTONS_ACCESSKEY{$button_href}\"";
1564 if ($USE_REL_REV and (defined($BUTTONS_REL{$button_href})) and
1565 ($BUTTONS_REL{$button_href} ne ''))
1567 $anchor_attributes .= " rel=\"$BUTTONS_REL{$button_href}\"";
1571 $Texi2HTML::HREF{$button_href},
1572 get_navigation_text($$text),
1578 $result .= get_navigation_text($$text);
1582 elsif ($button eq ' ')
1583 { # handle space button
1585 ($ICONS && $ACTIVE_ICONS{' '}) ?
1586 &$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{' '}) :
1587 $NAVIGATION_TEXT{' '};
1590 elsif ($Texi2HTML::HREF{$button})
1591 { # button is active
1592 my $btitle = $BUTTONS_GOTO{$button} ?
1593 'title="' . $BUTTONS_GOTO{$button} . '"' : '';
1594 if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button})) and
1595 ($BUTTONS_ACCESSKEY{$button} ne ''))
1597 $btitle .= " accesskey=\"$BUTTONS_ACCESSKEY{$button}\"";
1599 if ($USE_REL_REV and (defined($BUTTONS_REL{$button})) and
1600 ($BUTTONS_REL{$button} ne ''))
1602 $btitle .= " rel=\"$BUTTONS_REL{$button}\"";
1604 if ($ICONS && $ACTIVE_ICONS{$button})
1608 $Texi2HTML::HREF{$button},
1609 &$button_icon_img($BUTTONS_NAME{$button},
1610 $ACTIVE_ICONS{$button},
1611 $Texi2HTML::SIMPLE_TEXT{$button}),
1620 $Texi2HTML::HREF{$button},
1621 get_navigation_text($button),
1628 { # button is passive
1630 $ICONS && $PASSIVE_ICONS{$button} ?
1631 &$button_icon_img($BUTTONS_NAME{$button},
1632 $PASSIVE_ICONS{$button},
1633 $Texi2HTML::SIMPLE_TEXT{$button}) :
1635 "[" . get_navigation_text($button) . "]";
1637 $result .= "</td>\n" if $vertical;
1638 $result .= "</tr>\n" if $vertical;
1640 $result .= "</td>" unless $beginofline;
1641 $result .= "</tr>" unless $vertical;
1642 $result .= "</table>\n";
1651 @Texi2HTML::Config::SECTION_BUTTONS =
1652 ('left-aligned-cell-1', 'FastBack',
1653 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1654 'right-aligned-cell-1', 'FastForward',
1656 'left-aligned-cell-2', 'Back',
1657 'center-aligned-cell-1', 'Up',
1658 'right-aligned-cell-2', 'Forward'
1661 # buttons for misc stuff
1662 @Texi2HTML::Config::MISC_BUTTONS = ('center-aligned-cell-3',
1663 'Top', 'Contents', 'Index', 'About');
1665 # buttons for chapter file footers
1666 # (and headers but only if SECTION_NAVIGATION is false)
1667 @Texi2HTML::Config::CHAPTER_BUTTONS =
1668 ('left-aligned-cell-1', 'FastBack',
1669 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1670 'right-aligned-cell-1', 'FastForward',
1673 # buttons for section file footers
1674 @Texi2HTML::Config::SECTION_FOOTER_BUTTONS =
1675 ('left-aligned-cell-1', 'FastBack',
1676 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1677 'right-aligned-cell-1', 'FastForward',
1679 'left-aligned-cell-2', 'Back',
1680 'center-aligned-cell-1', 'Up',
1681 'right-aligned-cell-2', 'Forward'
1684 @Texi2HTML::Config::NODE_FOOTER_BUTTONS =
1685 ('left-aligned-cell-1', 'FastBack',
1686 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1687 'right-aligned-cell-1', 'FastForward',
1689 'left-aligned-cell-2', 'Back',
1690 'center-aligned-cell-1', 'Up',
1691 'right-aligned-cell-2', 'Forward'
1698 #############################################################################
1699 ### FOOTNOTE FORMATTING
1700 #############################################################################
1702 # Format footnotes in a nicer way: Instead of printing the number in a separate
1703 # (nr) heading line, use the standard way of prepending <sup>nr</sup> immediately
1704 # before the fn text.
1707 # The following code is copied from texi2html's examples/makeinfo.init and
1708 # should be updated when texi2html makes some changes there!
1710 my $makekinfo_like_footnote_absolute_number = 0;
1712 sub makeinfo_like_foot_line_and_ref($$$$$$$$)
1714 my $foot_num = shift;
1715 my $relative_num = shift;
1718 my $from_file = shift;
1719 my $footnote_file = shift;
1723 $makekinfo_like_footnote_absolute_number++;
1725 # this is a bit obscure, this allows to add an anchor only if formatted
1726 # as part of the document.
1727 $docid = '' if ($state->{'outside_document'} or $state->{'multiple_pass'});
1729 if ($from_file eq $footnote_file)
1731 $from_file = $footnote_file = '';
1734 my $foot_anchor = "<sup>" .
1735 &$anchor($docid, "$footnote_file#$footid", $relative_num) . "</sup>";
1736 $foot_anchor = &$anchor($docid,
1737 "$footnote_file#$footid",
1738 "($relative_num)") if ($state->{'preformatted'});
1740 # unshift @$lines, "<li>";
1741 # push @$lines, "</li>\n";
1742 return ($lines, $foot_anchor);
1745 sub makeinfo_like_foot_lines($)
1748 unshift @$lines, "<hr>\n<h4>$Texi2HTML::I18n::WORDS->{'Footnotes_Title'}</h4>\n";
1749 #<ol type=\"1\">\n";
1750 # push @$lines, "</ol>";
1754 my %makekinfo_like_paragraph_in_footnote_nr;
1756 sub makeinfo_like_paragraph ($$$$$$$$$$$$$)
1761 my $paragraph_command = shift;
1762 my $paragraph_command_formatted = shift;
1763 my $paragraph_number = shift;
1765 my $item_nr = shift;
1766 my $enumerate_style = shift;
1768 my $command_stack_at_end = shift;
1769 my $command_stack_at_begin = shift;
1771 #print STDERR "format: $format\n" if (defined($format));
1772 #print STDERR "paragraph @$command_stack_at_end; @$command_stack_at_begin\n";
1773 $paragraph_command_formatted = '' if (!defined($paragraph_command_formatted) or
1774 exists($special_list_commands{$format}->{$paragraph_command}));
1775 return '' if ($text =~ /^\s*$/);
1776 foreach my $style(t2h_collect_styles($command_stack_at_begin))
1778 $text = t2h_begin_style($style, $text);
1780 foreach my $style(t2h_collect_styles($command_stack_at_end))
1782 $text = t2h_end_style($style, $text);
1784 if (defined($paragraph_number) and defined($$paragraph_number))
1786 $$paragraph_number++;
1787 return $text if (($format eq 'itemize' or $format eq 'enumerate') and
1788 ($$paragraph_number == 1));
1793 $open .= " align=\"$paragraph_style{$align}\"";
1795 my $footnote_text = '';
1796 if (defined($command_stack_at_begin->[0]) and $command_stack_at_begin->[0] eq 'footnote')
1798 my $state = $Texi2HTML::THISDOC{'state'};
1799 $makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number}++;
1800 if ($makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number} <= 1)
1802 $open.=' class="footnote"';
1803 my $document_file = $state->{'footnote_document_file'};
1804 if ($document_file eq $state->{'footnote_footnote_file'})
1806 $document_file = '';
1808 my $docid = $state->{'footnote_place_id'};
1809 my $doc_state = $state->{'footnote_document_state'};
1810 $docid = '' if ($doc_state->{'outside_document'} or $doc_state->{'multiple_pass'});
1811 my $foot_label = &$anchor($state->{'footnote_footnote_id'},
1812 $document_file . "#$state->{'footnote_place_id'}",
1813 "$state->{'footnote_number_in_page'}");
1814 $footnote_text = "<small>[${foot_label}]</small> ";
1817 return $open.'>'.$footnote_text.$text.'</p>';
1821 #############################################################################
1822 ### WRITING OUT THE INDEX FOR THE AJAX SEARCH FIELD
1823 #############################################################################
1825 $Texi2HTML::Config::IDX_SUMMARY = 1;
1826 $Texi2HTML::Config::init_out = \&lilypond_init_out;
1827 $Texi2HTML::Config::finish_out = \&lilypond_finish_out;
1828 $Texi2HTML::Config::index_summary_file_entry = \&lilypond_index_summary_file_entry;
1832 sub lilypond_init_out ()
1834 t2h_default_init_out ();
1835 # Check whether we have an index at all! If not -> don't print out a search box!
1836 my $ix = main::get_index ("cp");
1837 $have_index_entries = (scalar $ix > 0);
1840 sub lilypond_index_summary_file_entry ($$$$$$$$$)
1842 my $index_name = shift;
1843 my $entry_text = shift;
1844 my $entry_reference = shift;
1845 my $formatted_entry = shift;
1846 my $texi_entry = shift;
1847 my $entry_element_reference = shift;
1848 my $entry_element_header = shift;
1849 my $is_printed = shift;
1850 my $manual_name = shift;
1852 if ($ENV{'AJAX_SEARCH'}==1) {
1853 if ($index_name eq "cp")
1855 # The entries in the index file have the form:
1856 # SearchText \t FormattedText \t EntryURL \t SectionText \t SectionURL
1857 push @index_entries, "$entry_text\t$formatted_entry\t$entry_reference\t$entry_element_header\t$entry_element_reference\n";
1862 sub lilypond_finish_out ()
1864 if ($ENV{'AJAX_SEARCH'}==1) {
1865 if (((scalar @index_entries) > 0) and $have_index_entries) {
1866 my $lang = $Texi2HTML::THISDOC{current_lang};
1868 $big = "-big-page" if $bigpage;
1869 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1870 my $idx_file = "$docu_dir/$docu_name$big.$lang.idx";
1871 open IDXOUTFILE, ">:utf8", $idx_file;
1872 print IDXOUTFILE @index_entries;
1880 #############################################################################
1882 #############################################################################
1884 # For split pages, use index.html as start page!
1885 if ($Texi2HTML::Config::SPLIT eq 'section' or
1886 $Texi2HTML::Config::SPLIT eq 'node') {
1887 $Texi2HTML::Config::TOP_FILE = 'index.html';