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->{'cs'} = {
95 'Back to Documentation Index' => '',
96 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '',
99 $LY_LANGUAGES->{'de'} = {
100 'Back to Documentation Index' => 'Zur Dokumentationsübersicht',
101 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '',
104 $LY_LANGUAGES->{'es'} = {
105 'Back to Documentation Index' => 'Volver al índice de la documentación',
106 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '<p>Agradecemos a ${webdev_link} el alojamiento de ${lily_site}.',
109 $LY_LANGUAGES->{'fr'} = {
110 'Back to Documentation Index' => 'Retour à l\'accueil de la documentation',
111 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '<p>Remerciements à ${webdev_link} pour l\'hébergement de ${lily_site}.',
115 $LY_LANGUAGES->{'hu'} = {
116 'Back to Documentation Index' => 'Vissza a dokumentációk jegyzékéhez',
117 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => 'Köszönet a ${webdev_link} részére a ${lily_site} tárhelyért.',
120 $LY_LANGUAGES->{'it'} = {
121 'Back to Documentation Index' => 'Torna all\'indice della documentazione',
122 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '',
125 $LY_LANGUAGES->{'ja'} = {
126 'Back to Documentation Index' => 'ドキュメント インデックスに戻る',
127 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '${lily_site} をホスティングしてくれている ${webdev_link} に感謝します。',
131 $LY_LANGUAGES->{'nl'} = {
132 'Back to Documentation Index' => 'Terug naar de Documentatieindex',
133 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '<p>Met dank aan ${webdev_link} voor het hosten van ${lily_site}.',
136 $LY_LANGUAGES->{'zh'} = {
137 'Back to Documentation Index' => '回到文档索引',
138 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '非常感谢 ${webdev_link} 提供 ${lily_site} 的主机空间。',
141 # FIXME: request the translations below then send them to texi2html/texinfo devs
143 $LANGUAGES->{'it'} = {
144 ' The buttons in the navigation panels have the following meaning:' => ' I bottoni nei pannelli di navigazione hanno il seguente significato:',
145 ' 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:',
147 '(outside of any element)' => '(fuori da qualsiasi elemento)',
148 '(outside of any node)' => '(fuori da qualsiasi nodo)',
149 '@b{{quotation_arg}:} ' => '@b{{quotation_arg}:} ',
150 '@cite{{book}}' => '@cite{{book}}',
151 '@{No value for `{value}\'@}' => '@{Nessun valore per `{value}\'@}',
152 'About' => 'Informazioni',
153 'About (help)' => 'Informazioni (aiuto)',
154 'About This Document' => 'Informazioni su questo documento',
156 'August' => 'Agosto',
157 'Back' => 'Indietro',
158 'Back section in previous file' => '',
159 'Beginning of this chapter or previous chapter' => 'Inizio di questo capitolo o capitolo precedente',
160 'Button' => 'Bottone',
161 'Contents' => 'Contenuti',
162 'Cover (top) of document' => 'Copertina (inizio) del documento',
163 'Current' => 'Attuale',
164 'Current Position' => 'Posizione Attuale',
165 'Current section' => 'Sezione attuale',
166 'December' => 'Dicembre',
167 'FastBack' => 'Indietro veloce',
168 'FastForward' => 'Avanti veloce',
169 'February' => 'Febbraio',
171 'First section in reading order' => 'Prima sezione in ordine di lettura',
172 'Following' => 'Seguente',
173 'Following node' => 'Nodo seguente',
174 'Footnotes' => 'Note a piè di pagina',
175 'Forward' => 'Avanti',
176 'Forward section in next file' => 'Sezione successiva nel prossimo file',
177 'From 1.2.3 go to' => 'Da 1.2.3 vai a',
180 'Index Entry' => 'Voce dell\'indice',
181 'January' => 'Gennaio',
183 'Jump to' => 'Salta a',
186 'Last section in reading order' => 'Ultima sezione in ordine di lettura',
191 'Next' => 'Successivo',
192 'Next chapter' => 'Capitolo successivo',
193 'Next file' => 'File successivo',
194 'Next node' => 'Nodo successivo',
195 'Next section in reading order' => 'Sezione successiva in ordine di lettura',
196 'Next section on same level' => 'Sezione successiva sullo stesso livello',
197 'NextFile' => 'File successivo',
198 'Node following in node reading order' => 'Nodo seguente in ordine di lettura',
199 'Node up' => 'Nodo superiore',
200 'NodeNext' => 'Nodo successivo',
201 'NodePrev' => 'Nodo precedente',
202 'NodeUp' => 'Nodo superiore',
203 'November' => 'Novembre',
204 'October' => 'Ottobre',
205 'Overview' => 'Panoramica',
207 'PrevFile' => 'File precedente',
208 'Previous' => 'Precedente',
209 'Previous file' => 'File precedente',
210 'Previous node' => 'Nodo precedente',
211 'Previous section in reading order' => 'Sezione precedente in ordine di lettura',
212 'Previous section on same level' => 'Sezione precedente sullo stesso livello',
213 'Section' => 'Sezione',
214 'Section One' => 'Sezione uno',
216 'See @cite{{book}}' => 'Vedi @cite{{book}}',
217 'See section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'Vedi la sezione `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}',
218 'See section `{section}\' in @cite{{book}}' => 'Vedi la sezione `{section}\' in @cite{{book}}',
219 'See section {reference_name}' => 'Vedi la sezione {reference_name}',
220 'See {node_file_href}' => 'Vedi {node_file_href}',
221 'See {node_file_href} @cite{{book}}' => 'Vedi {node_file_href} @cite{{book}}',
222 'See {node_file_href} section `{section}\' in @cite{{book}}' => 'Vedi {node_file_href} nella sezione `{section}\' in @cite{{book}}',
223 'See {reference_name}' => 'Vedi {reference_name}',
224 'See {ref}' => 'Vedi {ref}',
225 'See {title_ref}' => 'Vedi {title_ref}',
226 'September' => 'Settembre',
227 'Short Table of Contents' => 'Indice breve',
228 'Short table of contents' => 'Indice breve',
229 'Subsection One-Four' => 'Sottosezione Uno-Quattro',
230 'Subsection One-One' => 'Sottosezione Uno-Uno',
231 'Subsection One-Three' => 'Sottosezione Uno-Tre',
232 'Subsection One-Two' => 'Sottosezione Uno-Due',
233 'Subsubsection One-Two-Four' => 'Sottosottosezione Uno-Due-Quattro',
234 'Subsubsection One-Two-One' => 'Sottosottosezione Uno-Due-Uno',
235 'Subsubsection One-Two-Three' => 'Sottosottosezione Uno-Due-Tre',
236 'Subsubsection One-Two-Two' => 'Sottosottosezione Uno-Due-Due',
237 'T2H_today' => '%s, %d %d',
238 'Table of Contents' => 'Indice',
239 'Table of contents' => 'Indice',
240 'The node you are looking for is at {href}.' => 'Il nodo che stai cercando è {href}',
242 '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}}}.',
243 'This document was generated using @uref{{program_homepage}, @emph{{program}}}.' => 'Questo documento è stato generato con @uref{{program_homepage}, @emph{{program}}}.',
245 'Untitled Document' => 'Documento senza titolo',
247 'Up node' => 'Nodo superiore',
248 'Up section' => 'Sezione superiore',
249 'current' => 'attuale',
250 'on @emph{{date}}' => 'il @emph{{date}}',
251 'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'sezione `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}',
252 'section `{section}\' in @cite{{book}}' => 'sezione `{section}\' in @cite{{book}}',
254 'see @cite{{book}}' => 'vedi @cite{{book}}',
255 'see section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'vedi la sezione `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}',
256 'see section `{section}\' in @cite{{book}}' => 'vedi la sezione `{section}\' in @cite{{book}}',
257 'see section {reference_name}' => 'vedi la sezione {reference_name}',
258 'see {node_file_href}' => 'vedi {node_file_href}',
259 'see {node_file_href} @cite{{book}}' => 'vedi {node_file_href} @cite{{book}}',
260 'see {node_file_href} section `{section}\' in @cite{{book}}' => 'vedi {node_file_href} nella sezione `{section}\' in @cite{{book}}',
261 'see {reference_name}' => 'vedi {reference_name}',
262 'see {ref}' => 'vedi {ref}',
263 'see {title_ref}' => 'vedi {title_ref}',
264 '{acronym_like} ({explanation})' => '{acronym_like} ({explanation})',
265 '{name} of {class}' => '{name} di {class}',
266 '{name} on {class}' => '{name} in {class}',
267 '{node_file_href}' => '{node_file_href}',
268 '{node_file_href} @cite{{book}}' => '{node_file_href} @cite{{book}}',
269 '{node_file_href} section `{section}\' in @cite{{book}}' => '{node_file_href} nella sezione `{section}\' in @cite{{book}}',
270 '{reference_name}' => '{reference_name}',
272 '{style} {number}' => '{style} {number}',
273 '{style}: {caption_first_line}' => '{style}: {caption_first_line}',
274 '{style}: {shortcaption_first_line}' => '{style}: {shortcaption_first_line}',
275 '{title_ref}' => '{title_ref}'
278 $LANGUAGES->{'hu'} = {
279 ' The buttons in the navigation panels have the following meaning:' => ' A navigációs panelen levő gombok jelentése a következő:',
280 ' 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ő:',
282 '(outside of any element)' => '(bármelyik elemen kívül)',
283 '(outside of any node)' => '(bármelyik csomóponton kívül)',
284 '@b{{quotation_arg}:} ' => '@b{{quotation_arg}:} ',
285 '@cite{{book}}' => '@cite{{book}}',
286 '@{No value for `{value}\'@}' => '@{Nincs értéke ennek: `{value}\'@}',
288 'About (help)' => 'Segítség a navigációhoz',
289 'About This Document' => 'A navigációs panel használata',
290 'April' => 'április',
291 'August' => 'augusztus',
293 'Back section in previous file' => 'Előző fájl hátsó szakasza',
294 'Beginning of this chapter or previous chapter' => 'Fejezet eleje vagy előző fejezet',
296 'Contents' => 'Tartalom',
297 'Cover (top) of document' => 'Dokumentum címoldala',
298 'Current' => 'Aktuális',
299 'Current Position' => 'Aktuális pozíció',
300 'Current section' => 'Aktuális szakasz',
301 'December' => 'december',
302 'FastBack' => 'Visszaugrás',
303 'FastForward' => 'Előreugrás',
304 'February' => 'február',
306 'First section in reading order' => 'Első szakasz az olvasási sorrendben',
307 'Following' => 'Következő',
308 'Following node' => 'Következő csomópont',
309 'Footnotes' => 'Lábjegyzet',
310 'Forward' => 'Előre',
311 'Forward section in next file' => 'Következő fájl elülső szakasza',
312 'From 1.2.3 go to' => '1.2.3-ból ide jutunk',
314 'Index' => 'Tárgymutató',
315 'Index Entry' => 'Tárgymutató-bejegyzés',
316 'January' => 'január',
318 'Jump to' => 'Ugorj ide',
321 'Last section in reading order' => 'Utolsó szakasz az olvasási sorrendben',
322 'March' => 'március',
326 'Next' => 'Következő',
327 'Next chapter' => 'Következő fejezet',
328 'Next file' => 'Következő fájl',
329 'Next node' => 'Következő csomópont',
330 'Next section in reading order' => 'Következő szakasz az olvasási sorrendben',
331 'Next section on same level' => 'Következő szakasz ugyanazon a szinten',
332 'NextFile' => 'KövetkezőFájl',
333 'Node following in node reading order' => 'Következő csomópont az olvasási sorrendben',
334 'Node up' => 'Szülő csomópont',
335 'NodeNext' => 'KövetkezőCsomópont',
336 'NodePrev' => 'ElőzőCsomópont',
337 'NodeUp' => 'SzülőCsomópont',
338 'November' => 'november',
339 'October' => 'október',
340 'Overview' => 'Áttekintés',
342 'PrevFile' => 'ElőzőFájl',
343 'Previous' => 'Előző',
344 'Previous file' => 'Előző fájl',
345 'Previous node' => 'Előző csomópont',
346 'Previous section in reading order' => 'Előző szakasz az olvasási sorrendben',
347 'Previous section on same level' => 'Előző szakasz ugyanazon a szinten',
348 'Section' => 'Szakasz',
349 'Section One' => 'szakasz',
351 'See @cite{{book}}' => 'Ld. @cite{{book}}',
352 'See section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'Ld. ezt a szakaszt: `@asis{}`{section_name}\'@asis{}\' itt: @cite{{book}}',
353 'See section `{section}\' in @cite{{book}}' => 'Ld. ezt a szakaszt: `{section}\' itt: @cite{{book}}',
354 'See section {reference_name}' => 'Ld. ezt a szakaszt: {reference_name}',
355 'See {node_file_href}' => 'Ld. {node_file_href}',
356 'See {node_file_href} @cite{{book}}' => 'See {node_file_href} @cite{{book}}',
357 'See {node_file_href} section `{section}\' in @cite{{book}}' => 'Ld. {node_file_href} ezt a szakaszt: `{section}\' itt: @cite{{book}}',
358 'See {reference_name}' => 'Ld. {reference_name}',
359 'See {ref}' => 'Ld. {ref}',
360 'See {title_ref}' => 'Ld. {title_ref}',
361 'September' => 'szeptember',
362 'Short Table of Contents' => 'Rövid tartalomjegyzék',
363 'Short table of contents' => 'Rövid tartalomjegyzék',
364 'Subsection One-Four' => 'alszakasz',
365 'Subsection One-One' => 'alszakasz',
366 'Subsection One-Three' => 'alszakasz',
367 'Subsection One-Two' => 'alszakasz',
368 'Subsubsection One-Two-Four' => 'alalszakasz',
369 'Subsubsection One-Two-One' => 'alalszakasz',
370 'Subsubsection One-Two-Three' => 'alalszakasz',
371 'Subsubsection One-Two-Two' => 'alalszakasz',
372 'T2H_today' => '%s, %d %d',
373 'Table of Contents' => 'Tartalomjegyzék',
374 'Table of contents' => 'Tartalomjegyzék',
375 'The node you are looking for is at {href}.' => 'A keresett csomópont itt található: {href}.',
377 '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}}}.',
378 'This document was generated using @uref{{program_homepage}, @emph{{program}}}.' => 'Ezt a dokumentumot a(z) @uref{{program_homepage}, @emph{{program}}} generálta.',
380 'Untitled Document' => 'Névtelen dokumentum',
382 'Up node' => 'Szülő csomópont',
383 'Up section' => 'Szülő szakasz',
384 'current' => 'aktuális',
385 'on @emph{{date}}' => 'ekkor: @emph{{date}}',
386 'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'szakasz: `@asis{}`{section_name}\'@asis{}\' itt: @cite{{book}}',
387 'section `{section}\' in @cite{{book}}' => 'szakasz: `{section}\' itt: @cite{{book}}',
389 'see @cite{{book}}' => 'ld. @cite{{book}}',
390 'see section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'ld. ezt a szakaszt: `@asis{}`{section_name}\'@asis{}\' itt: @cite{{book}}',
391 'see section `{section}\' in @cite{{book}}' => 'ld. ezt a szakaszt: `{section}\' itt: @cite{{book}}',
392 'see section {reference_name}' => 'ld. ezt a szakaszt: {reference_name}',
393 'see {node_file_href}' => 'ld. {node_file_href}',
394 'see {node_file_href} @cite{{book}}' => 'ld. {node_file_href} @cite{{book}}',
395 'see {node_file_href} section `{section}\' in @cite{{book}}' => 'ld. {node_file_href} ezt a szakaszt: `{section}\' itt: @cite{{book}}',
396 'see {reference_name}' => 'ld. {reference_name}',
397 'see {ref}' => 'ld. {ref}',
398 'see {title_ref}' => 'ld. {title_ref}',
399 '{acronym_like} ({explanation})' => '{acronym_like} ({explanation})',
400 '{name} of {class}' => '{name} típusa: {class}',
401 '{name} on {class}' => '{name} ezen: {class}',
402 '{node_file_href}' => '{node_file_href}',
403 '{node_file_href} @cite{{book}}' => '{node_file_href} @cite{{book}}',
404 '{node_file_href} section `{section}\' in @cite{{book}}' => '{node_file_href} szakasz: `{section}\' itt: @cite{{book}}',
405 '{reference_name}' => '{reference_name}',
407 '{style} {number}' => '{style} {number}',
408 '{style}: {caption_first_line}' => '{style}: {caption_first_line}',
409 '{style}: {shortcaption_first_line}' => '{style}: {shortcaption_first_line}',
410 '{title_ref}' => '{title_ref}'
413 $LANGUAGES->{'ja'} = {
414 ' The buttons in the navigation panels have the following meaning:' => ' ナビゲーション パネルの中にあるボタンには以下のような意味があります:',
415 ' 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 } であると仮定しています:',
417 '(outside of any element)' => '(outside of any element)',
418 '(outside of any node)' => '(outside of any node)',
419 '@b{{quotation_arg}:} ' => '@b{{quotation_arg}:} ',
420 '@cite{{book}}' => '@cite{{book}}',
421 '@{No value for `{value}\'@}' => '@{No value for `{value}\'@}',
423 'About (help)' => '情報 (ヘルプ)',
424 'About This Document' => 'このドキュメントについて',
428 'Back section in previous file' => '前のファイルのセクションに戻る',
429 'Beginning of this chapter or previous chapter' => 'この章あるいは前の章の先頭',
432 'Cover (top) of document' => 'ドキュメントの表紙 (先頭)',
434 'Current Position' => '現在の位置',
435 'Current section' => '現在のセクション',
436 'December' => '12 月',
437 'FastBack' => '大きく戻る',
438 'FastForward' => '大きく進む',
441 'First section in reading order' => '最初のセクション',
443 'Following node' => '次のノード',
446 'Forward section in next file' => '次のファイルのセクションに進む',
447 'From 1.2.3 go to' => '1.2.3 からの行き先',
450 'Index Entry' => 'インデックス エントリ',
456 'Last section in reading order' => '最後のセクション',
462 'Next chapter' => '次の章',
463 'Next file' => '次のファイル',
464 'Next node' => '次のノード',
465 'Next section in reading order' => '次のセクション',
466 'Next section on same level' => '次のセクション',
467 'NextFile' => '次のファイル',
468 'Node following in node reading order' => '次のノード',
469 'Node up' => '上のノード',
470 'NodeNext' => '次のノード',
471 'NodePrev' => '前のノード',
473 'November' => '11 月',
477 'PrevFile' => '前のファイル',
479 'Previous file' => '前のファイル',
480 'Previous node' => '前のノード',
481 'Previous section in reading order' => '前のセクション',
482 'Previous section on same level' => '前のセクション',
483 'Section' => 'セクション',
484 'Section One' => 'セクション 1',
486 'See @cite{{book}}' => '@cite{{book}} を参照してください',
487 'See section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '@cite{{book}} のセクション `@asis{}`{section_name}\'@asis{}\' を参照してください',
488 'See section `{section}\' in @cite{{book}}' => '@cite{{book}} のセクション `{section}\' を参照してください',
489 'See section {reference_name}' => 'セクション {reference_name} を参照してください',
490 'See {node_file_href}' => '{node_file_href} を参照してください',
491 'See {node_file_href} @cite{{book}}' => '@cite{{book}} の {node_file_href} を参照してください',
492 'See {node_file_href} section `{section}\' in @cite{{book}}' => '@cite{{book}} の {node_file_href} セクション `{section}\' を参照してください',
493 'See {reference_name}' => '{reference_name} を参照してください',
494 'See {ref}' => '{ref} を参照してください',
495 'See {title_ref}' => '{title_ref} を参照してください',
496 'September' => '9 月',
497 'Short Table of Contents' => '簡単な目次',
498 'Short table of contents' => '簡単な目次',
499 'Subsection One-Four' => 'サブセクション 1-4',
500 'Subsection One-One' => 'サブセクション 1-1',
501 'Subsection One-Three' => 'サブセクション 1-3',
502 'Subsection One-Two' => 'サブセクション 1-2',
503 'Subsubsection One-Two-Four' => 'サブサブセクション 1-2-4',
504 'Subsubsection One-Two-One' => 'サブサブセクション 1-2-1',
505 'Subsubsection One-Two-Three' => 'サブサブセクション 1-2-3',
506 'Subsubsection One-Two-Two' => 'サブサブセクション 1-2-2',
507 'T2H_today' => '%s, %d %d',
508 'Table of Contents' => '目次',
509 'Table of contents' => '目次',
510 'The node you are looking for is at {href}.' => 'あなたが探しているノードは {href} にあります。',
512 'This document was generated on @i{{date}} using @uref{{program_homepage}, @i{{program}}}.' => 'このドキュメントは @i{{date}} に、@uref{{program_homepage}, @i{{program}}} を用いて生成されました。',
513 'This document was generated using @uref{{program_homepage}, @emph{{program}}}.' => 'このドキュメントは @uref{{program_homepage}, @emph{{program}}} を用いて生成されました。',
515 'Untitled Document' => '無題のドキュメント',
517 'Up node' => '上のノード',
518 'Up section' => '上のセクション',
520 'on @emph{{date}}' => '@emph{{date}} に',
521 'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '@cite{{book}} のセクション `@asis{}`{section_name}\'@asis{}\'',
522 'section `{section}\' in @cite{{book}}' => '@cite{{book}} のセクション `{section}\'',
524 'see @cite{{book}}' => '@cite{{book}} を参照してください',
525 'see section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '@cite{{book}} のセクション `@asis{}`{section_name}\'@asis{}\' を参照してください',
526 'see section `{section}\' in @cite{{book}}' => '@cite{{book}} のセクション `{section}\' を参照してください',
527 'see section {reference_name}' => 'セクション {reference_name} を参照してください',
528 'see {node_file_href}' => '{node_file_href} を参照してください',
529 'see {node_file_href} @cite{{book}}' => '{node_file_href} @cite{{book}} を参照してください',
530 'see {node_file_href} section `{section}\' in @cite{{book}}' => '@cite{{book}} の {node_file_href} section `{section}\' を参照してください',
531 'see {reference_name}' => '{reference_name} を参照してください',
532 'see {ref}' => '{ref} を参照してくださ',
533 'see {title_ref}' => '{title_ref} を参照してくださ',
534 '{acronym_like} ({explanation})' => '{acronym_like} ({explanation})',
535 '{name} of {class}' => '{class} の {name}',
536 '{name} on {class}' => '{class} の {name}',
537 '{node_file_href}' => '{node_file_href}',
538 '{node_file_href} @cite{{book}}' => '{node_file_href} @cite{{book}}',
539 '{node_file_href} section `{section}\' in @cite{{book}}' => '@cite{{book}} の {node_file_href} セクション `{section}\'',
540 '{reference_name}' => '{reference_name}',
542 '{style} {number}' => '{style} {number}',
543 '{style}: {caption_first_line}' => '{style}: {caption_first_line}',
544 '{style}: {shortcaption_first_line}' => '{style}: {shortcaption_first_line}',
545 '{title_ref}' => '{title_ref}'
548 $LANGUAGES->{'cs'} = {
549 ' The buttons in the navigation panels have the following meaning:' => '',
550 ' where the @strong{ Example } assumes that the current position is at @strong{ Subsubsection One-Two-Three } of a document of the following structure:' => '',
552 '(outside of any element)' => '',
553 '(outside of any node)' => '',
554 '@b{{quotation_arg}:} ' => '',
555 '@cite{{book}}' => '',
556 '@{No value for `{value}\'@}' => '',
558 'About (help)' => '',
559 'About This Document' => '',
563 'Back section in previous file' => '',
564 'Beginning of this chapter or previous chapter' => '',
567 'Cover (top) of document' => '',
569 'Current Position' => '',
570 'Current section' => '',
576 'First section in reading order' => '',
578 'Following node' => '',
581 'Forward section in next file' => '',
582 'From 1.2.3 go to' => '',
591 'Last section in reading order' => '',
597 'Next chapter' => '',
600 'Next section in reading order' => '',
601 'Next section on same level' => '',
603 'Node following in node reading order' => '',
614 'Previous file' => '',
615 'Previous node' => '',
616 'Previous section in reading order' => '',
617 'Previous section on same level' => '',
621 'See @cite{{book}}' => '',
622 'See section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '',
623 'See section `{section}\' in @cite{{book}}' => '',
624 'See section {reference_name}' => '',
625 'See {node_file_href}' => '',
626 'See {node_file_href} @cite{{book}}' => '',
627 'See {node_file_href} section `{section}\' in @cite{{book}}' => '',
628 'See {reference_name}' => '',
630 'See {title_ref}' => '',
632 'Short Table of Contents' => '',
633 'Short table of contents' => '',
634 'Subsection One-Four' => '',
635 'Subsection One-One' => '',
636 'Subsection One-Three' => '',
637 'Subsection One-Two' => '',
638 'Subsubsection One-Two-Four' => '',
639 'Subsubsection One-Two-One' => '',
640 'Subsubsection One-Two-Three' => '',
641 'Subsubsection One-Two-Two' => '',
643 'Table of Contents' => '',
644 'Table of contents' => '',
645 'The node you are looking for is at {href}.' => '',
647 'This document was generated on @i{{date}} using @uref{{program_homepage}, @i{{program}}}.' => '',
648 'This document was generated using @uref{{program_homepage}, @emph{{program}}}.' => '',
650 'Untitled Document' => '',
655 'on @emph{{date}}' => '',
656 'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '',
657 'section `{section}\' in @cite{{book}}' => '',
659 'see @cite{{book}}' => '',
660 'see section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '',
661 'see section `{section}\' in @cite{{book}}' => '',
662 'see section {reference_name}' => '',
663 'see {node_file_href}' => '',
664 'see {node_file_href} @cite{{book}}' => '',
665 'see {node_file_href} section `{section}\' in @cite{{book}}' => '',
666 'see {reference_name}' => '',
668 'see {title_ref}' => '',
669 '{acronym_like} ({explanation})' => '',
670 '{name} of {class}' => '',
671 '{name} on {class}' => '',
672 '{node_file_href}' => '',
673 '{node_file_href} @cite{{book}}' => '',
674 '{node_file_href} section `{section}\' in @cite{{book}}' => '',
675 '{reference_name}' => '',
677 '{style} {number}' => '',
678 '{style}: {caption_first_line}' => '',
679 '{style}: {shortcaption_first_line}' => '',
680 '{title_ref}' => '{title_ref}'
683 $LANGUAGES->{'zh'} = {
684 ' The buttons in the navigation panels have the following meaning:' => ' 在导航面板上按钮有以下含意:',
685 ' 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 }:',
687 '(outside of any element)' => '(任何元素外面)',
688 '(outside of any node)' => '(任何节点外面)',
689 '@b{{quotation_arg}:} ' => '@b{{quotation_arg}:} ',
690 '@cite{{book}}' => '@cite{{book}}',
691 '@{No value for `{value}\'@}' => '@{没有值 `{value}\'@}',
693 'About (help)' => '关于 (帮助)',
694 'About This Document' => '关于本文档',
698 'Back section in previous file' => '返回到前一个文件',
699 'Beginning of this chapter or previous chapter' => '本章开头或前一章',
702 'Cover (top) of document' => '文档的封面(首页)',
704 'Current Position' => '当前的位置',
705 'Current section' => '当前的段',
706 'December' => '12 月',
707 'FastBack' => '快速返回',
708 'FastForward' => '快速向前',
711 'First section in reading order' => '看的第一段',
712 'Following' => '紧接着的',
713 'Following node' => '紧接着的节点',
716 'Forward section in next file' => '向前到下一个文件的段',
717 'From 1.2.3 go to' => '从1.2.3 到',
720 'Index Entry' => '索引条目',
726 'Last section in reading order' => '看的最后一段',
732 'Next chapter' => '下一章',
733 'Next file' => '下一个文件',
734 'Next node' => '下一个节点',
735 'Next section in reading order' => '看的下一段',
736 'Next section on same level' => '同级的下一段',
737 'NextFile' => '下一个文件',
738 'Node following in node reading order' => '看的下一个节点',
739 'Node up' => '向上一个节点',
740 'NodeNext' => '下一个节点',
741 'NodePrev' => '前一个节点',
742 'NodeUp' => '向上一个节点',
743 'November' => '11 月',
747 'PrevFile' => '前一个文件',
749 'Previous file' => '前一个文件',
750 'Previous node' => '前一个节点',
751 'Previous section in reading order' => '看的前一段',
752 'Previous section on same level' => '同级的前一段',
754 'Section One' => '段 1',
756 'See @cite{{book}}' => '见 @cite{{book}}',
757 'See section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '',
758 'See section `{section}\' in @cite{{book}}' => '',
759 'See section {reference_name}' => '见段 {reference_name}',
760 'See {node_file_href}' => '见 {node_file_href}',
761 'See {node_file_href} @cite{{book}}' => '见 {node_file_href} @cite{{book}}',
762 'See {node_file_href} section `{section}\' in @cite{{book}}' => '见在@cite{{book}} 中的 {node_file_href} 段 `{section}\' ',
763 'See {reference_name}' => '见 {reference_name}',
764 'See {ref}' => '见 {ref}',
765 'See {title_ref}' => '见 {title_ref}',
766 'September' => '9 月',
767 'Short Table of Contents' => '短目录',
768 'Short table of contents' => '短目录',
769 'Subsection One-Four' => '分段 1-4',
770 'Subsection One-One' => '分段 1-1',
771 'Subsection One-Three' => '分段 1-3',
772 'Subsection One-Two' => '分段 1-2',
773 'Subsubsection One-Two-Four' => '小分段 1-2-4',
774 'Subsubsection One-Two-One' => '小分段 1-2-1',
775 'Subsubsection One-Two-Three' => '小分段 1-2-3',
776 'Subsubsection One-Two-Two' => '小分段 1-2-2',
778 'Table of Contents' => '目录',
779 'Table of contents' => '目录',
780 'The node you are looking for is at {href}.' => '你查找的节点在{href}。',
782 'This document was generated on @i{{date}} using @uref{{program_homepage}, @i{{program}}}.' => '本文档在 @i{{date}} 上用 @uref{{program_homepage}, @i{{program}}} 生成的。',
783 'This document was generated using @uref{{program_homepage}, @emph{{program}}}.' => '本文档用 @uref{{program_homepage}, @emph{{program}}} 生成的。',
785 'Untitled Document' => '没有标题的文档',
788 'Up section' => '上一段',
790 'on @emph{{date}}' => '@emph{{date}} 上',
791 'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '',
792 'section `{section}\' in @cite{{book}}' => '',
794 'see @cite{{book}}' => '见 @cite{{book}}',
795 'see section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => '见在@cite{{book}}里的段`@asis{}`{section_name}\'@asis{}\'',
796 'see section `{section}\' in @cite{{book}}' => '见在@cite{{book}}里的段`{section}\'',
797 'see section {reference_name}' => '见段 {reference_name}',
798 'see {node_file_href}' => '见 {node_file_href}',
799 'see {node_file_href} @cite{{book}}' => '见 {node_file_href} @cite{{book}}',
800 'see {node_file_href} section `{section}\' in @cite{{book}}' => '见在@cite{{book}}里的{node_file_href} 段`{section}\'',
801 'see {reference_name}' => '见 {reference_name}',
802 'see {ref}' => '见 {ref}',
803 'see {title_ref}' => '见 {title_ref}',
804 '{acronym_like} ({explanation})' => '{acronym_like} ({explanation})',
805 '{name} of {class}' => '{class} 的 {name}',
806 '{name} on {class}' => '在{class} 上的 {name}',
807 '{node_file_href}' => '',
808 '{node_file_href} @cite{{book}}' => '',
809 '{node_file_href} section `{section}\' in @cite{{book}}' => '{node_file_href} 段 `{section}\' 在 @cite{{book}}里',
810 '{reference_name}' => '',
812 '{style} {number}' => '{style} {number}',
813 '{style}: {caption_first_line}' => '{style}: {caption_first_line}',
814 '{style}: {shortcaption_first_line}' => '{style}: {shortcaption_first_line}',
815 '{title_ref}' => '{title_ref}'
819 sub ly_get_string () {
820 my $lang = $Texi2HTML::THISDOC{current_lang};
822 if ($lang and $lang ne "en" and $LY_LANGUAGES->{$lang}->{$string}) {
823 return $LY_LANGUAGES->{$lang}->{$string};
830 #############################################################################
831 ### FUNCTIONALITY FOR MAIN WEB PAGES
832 #############################################################################
836 #############################################################################
837 ### SETTINGS FOR TEXI2HTML
838 #############################################################################
840 # Validation fix for texi2html<=1.82
841 $Texi2HTML::Config::DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
843 @Texi2HTML::Config::CSS_REFS = (
844 {FILENAME => "lilypond-manuals.css", TITLE => "Default style"}
846 @Texi2HTML::Config::ALT_CSS_REFS = (
850 print STDERR "Processing web site: [$Texi2HTML::THISDOC{current_lang}]\n";
851 $Texi2HTML::Config::BODYTEXT = "";
852 @Texi2HTML::Config::CSS_REFS = (
853 {FILENAME => "lilypond-website.css", TITLE => "Default style"}
855 @Texi2HTML::Config::ALT_CSS_REFS = (
859 $Texi2HTML::Config::USE_ACCESSKEY = 1;
860 $Texi2HTML::Config::USE_LINKS = 1;
861 $Texi2HTML::Config::USE_REL_REV = 1;
862 $Texi2HTML::Config::SPLIT_INDEX = 0;
863 $Texi2HTML::Config::SEPARATED_FOOTNOTES = 0; # Print footnotes on same page, not separated
866 my $have_index_entries = 0;
867 if ($Texi2HTML::Config::SPLIT eq 'section' or
868 $Texi2HTML::Config::SPLIT eq 'node') {
869 $Texi2HTML::Config::element_file_name = \&lilypond_element_file_name;
875 $Texi2HTML::Config::anchor = \&lilypond_anchor;
876 $Texi2HTML::Config::element_target_name = \&lilypond_element_target_name;
877 $default_print_element_header = $Texi2HTML::Config::print_element_header;
878 $Texi2HTML::Config::print_element_header = \&lilypond_print_element_header;
879 $Texi2HTML::Config::print_page_foot = \&print_lilypond_page_foot;
880 $Texi2HTML::Config::print_navigation = \&lilypond_print_navigation;
881 $Texi2HTML::Config::external_ref = \&lilypond_external_ref;
882 $default_external_href = $Texi2HTML::Config::external_href;
883 $Texi2HTML::Config::external_href = \&lilypond_external_href;
884 $default_toc_body = $Texi2HTML::Config::toc_body;
885 $Texi2HTML::Config::toc_body = \&lilypond_toc_body;
886 $Texi2HTML::Config::css_lines = \&lilypond_css_lines;
887 $default_unknown = $Texi2HTML::Config::unknown;
888 $Texi2HTML::Config::unknown = \&lilypond_unknown;
889 $default_print_page_head = $Texi2HTML::Config::print_page_head;
890 $Texi2HTML::Config::print_page_head = \&lilypond_print_page_head;
891 # $Texi2HTML::Config::foot_line_and_ref = \&lilypond_foot_line_and_ref;
892 $Texi2HTML::Config::foot_line_and_ref = \&makeinfo_like_foot_line_and_ref;
893 $Texi2HTML::Config::foot_lines = \&makeinfo_like_foot_lines;
894 $Texi2HTML::Config::paragraph = \&makeinfo_like_paragraph;
898 # Examples should be formatted similar to quotes:
899 $Texi2HTML::Config::complex_format_map->{'example'} = {
900 'begin' => q{"<blockquote>"},
901 'end' => q{"</blockquote>\n"},
905 %Texi2HTML::config::misc_pages_targets = (
906 'Overview' => 'Overview',
907 'Contents' => 'Contents',
912 my @section_to_filename;
917 #############################################################################
919 #############################################################################
922 $Data::Dumper::Maxdepth = 2;
924 sub print_element_info($)
927 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
928 print "Element: $element\n";
929 print Dumper($element);
936 #############################################################################
938 #############################################################################
940 # only lc() the last portion of an href
944 my @hrefsplit = split('/', $href);
945 # change the last portion (the filename), if it exists;
946 # if it is a plain filename with no path, change the string as a whole
947 if ($#hrefsplit > 0) {
948 @hrefsplit[$#hrefsplit] = lc( @hrefsplit[$#hrefsplit] );
949 $href = join("/", @hrefsplit);
956 # Convert a given node name to its proper file name (normalization as explained
957 # in the texinfo manual:
958 # http://www.gnu.org/software/texinfo/manual/texinfo/html_node/HTML-Xref-Node-Name-Expansion.html
959 sub texinfo_file_name($)
963 # File name normalization by texinfo:
964 # 1/2: letters and numbers are left unchanged
965 # 3/4: multiple, leading and trailing whitespace is removed
966 $text = main::normalise_space($text);
967 # 5/6: all remaining spaces are converted to '-', all other 7- or 8-bit
968 # chars are replaced by _xxxx (xxxx=ascii character code)
969 while ($text ne '') {
970 if ($text =~ s/^([A-Za-z0-9]+)//o) { # number or letter stay unchanged
972 } elsif ($text =~ s/^ //o) { # space -> '-'
974 } elsif ($text =~ s/^(.)//o) { # Otherwise use _xxxx (ascii char code)
976 if ( $ccode <= 0xFFFF ) {
977 $result .= sprintf("_%04x", $ccode);
979 $result .= sprintf("__%06x", $ccode);
983 # 7: if name does not begin with a letter, prepend 't_g' (so it starts with a letter)
984 if ($result !~ /^[a-zA-Z]/) {
985 $result = 't_g' . $result;
988 return lc_last($result)
991 # Load a file containing a nodename<=>filename map (tab-sepatared, i.e.
992 # NODENAME\tFILENAME\tANCHOR
993 # Returns a ref to a hash "Node title" => ["FilenameWithoutExt", "Anchor"]
994 sub load_map_file ($)
999 # For some unknown reason, Perl on my system (5.10.0 on Fedora 12)
1000 # refuses to open map files of translated documents with
1001 # '<:encoding(utf8)', but decoding from UTF-8 line by line works. -jm
1002 if (open(XREFFILE,'<', $mapfile)) {
1004 # print STDERR "*** PRINTING MAP FILE LINES ***\n";
1005 while ( $line = decode ('UTF-8', <XREFFILE>) ) {
1006 # parse the tab-separated entries and insert them into the map:
1008 my @entries = split(/\t/, $line);
1009 if (scalar (@entries) == 3) {
1010 $node_map->{$entries[0]} = [$entries[1], $entries[2]];
1012 # print STDERR @entries;
1013 # print STDERR "\n";
1015 print STDERR "Invalid entry in the node file $mapfile: $line\n";
1020 print STDERR "WARNING: Unable to load the map file $mapfile\n";
1026 # Split the given path into dir and basename (with .texi removed). Used mainly
1027 # to get the path/basename of the original texi input file
1028 sub split_texi_filename ($)
1031 my ($docu_dir, $docu_name);
1032 if ($docu =~ /(.*\/)/) {
1033 chop($docu_dir = $1);
1035 $docu_name =~ s/.*\///;
1040 $docu_name =~ s/\.te?x(i|info)?$//;
1041 return ($docu_dir, $docu_name);
1048 #############################################################################
1050 #############################################################################
1052 # Include our standard CSS file, not hard-coded CSS code directly in the HTML!
1053 # For IE, conditionally include the lilypond-ie-fixes.css style sheet
1054 sub lilypond_css_lines ($$)
1056 my $import_lines = shift;
1057 my $rule_lines = shift;
1058 return if (defined($Texi2HTML::THISDOC{'CSS_LINES'}));
1059 if (@$rule_lines or @$import_lines)
1061 $Texi2HTML::THISDOC{'CSS_LINES'} = "<style type=\"text/css\">\n<!--\n";
1062 $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$import_lines) . "\n" if (@$import_lines);
1063 $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$rule_lines) . "\n" if (@$rule_lines);
1064 $Texi2HTML::THISDOC{'CSS_LINES'} .= "-->\n</style>\n";
1066 foreach my $ref (@CSS_REFS)
1068 $Texi2HTML::THISDOC{'CSS_LINES'} .=
1069 "<link rel=\"stylesheet\" type=\"text/css\" title=\"$ref->{TITLE}\" href=\"$ref->{FILENAME}\">\n";
1071 foreach my $ref (@Texi2HTML::Config::ALT_CSS_REFS)
1073 $Texi2HTML::THISDOC{'CSS_LINES'} .=
1074 "<link rel=\"alternate stylesheet\" type=\"text/css\" href=\"$ref->{FILENAME}\" title=\"$ref->{TITLE}\">\n";
1077 # The ie-fixes stylesheet is needed for the docs, but not the website.
1078 if (not ($web_manual)) {
1079 $Texi2HTML::THISDOC{'CSS_LINES'} .=
1080 "<!--[if lte IE 7]>\n<link href=\"lilypond-ie-fixes.css\" rel=\"stylesheet\" type=\"text/css\">\n<![endif]-->\n";
1083 if ($ENV{'AJAX_SEARCH'} == 1) {
1084 # Add the JavaScript file only if we have an index.
1085 # Unfortunately, init_out is called after css_lines, so as a workaround
1086 # here we have to check again for the existence of an index...
1087 my $ix = main::get_index ("cp");
1088 $have_index_entries = (scalar $ix > 0);
1090 $reldir = "../" unless $bigpage;
1091 if ($have_index_entries) {
1092 $Texi2HTML::THISDOC{'CSS_LINES'} .= "<script language=\"JavaScript\" src=\"${reldir}lily_search.js\"></script>\n";
1101 #############################################################################
1102 ### SPLITTING BASED ON NUMBERED SECTIONS
1103 #############################################################################
1107 my $node_to_filename_map = ();
1108 $source_to_translationof_map = ();
1111 # This function makes sure that files are only generated for numbered sections,
1112 # but not for unnumbered ones. It is called after texi2html has done its own
1113 # splitting and simply returns the filename for the node given as first argument
1114 # Nodes with the same filename will be printed out to the same filename, so
1115 # this really all we need. Also, make sure that the file names for sections
1116 # are derived from the section title. We also might want to name the anchors
1117 # according to node titles, which works by simply overriding the id element of
1118 # the $element hash.
1119 # If an external nodename<=>filename/anchor map file is found (loaded in
1120 # the command handler, use the externally created values, otherwise use the
1122 sub lilypond_element_file_name($$$)
1124 my $element = shift;
1126 my $docu_name = shift;
1127 my $docu_ext = $Texi2HTML::Config::EXTENSION;
1129 my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
1130 # the snippets page does not use nodes for the snippets, so in this case
1131 # we'll have to use the section name!
1132 if ($node_name eq '') {
1133 $node_name = main::remove_texi($element->{'texi'});
1136 # If we have an entry in the section<=>filename map, use that one, otherwise
1137 # generate the filename/anchor here. In the latter case, external manuals
1138 # will not be able to retrieve the file name for xrefs!!! Still, I already
1139 # had that code, so I'll leave it in in case something goes wrong with the
1140 # extract_texi_filenames.py script in the lilypond build process!
1141 if (exists ($node_to_filename_map->{$node_name})) {
1142 (my $filename, my $anchor) = @{$node_to_filename_map->{$node_name}};
1143 $filename .= ".$docu_ext" if (defined($docu_ext));
1144 # don't do lc_last here, otherwise the colors are messed up!
1145 $filename = lc($filename);
1147 # unnumbered sections (except those at top-level!) always go to the same
1148 # file as the previous numbered section
1149 if (not ($web_manual) and not ($element->{number})
1150 and not ($lastfilename eq '') and ($element->{level} > 1)) {
1151 $filename = $lastfilename;
1153 if (($filename eq $lastfilename)) {
1154 $$element{doc_nr} = $docnr;
1157 $$element{doc_nr} = $docnr;
1158 $lastfilename = $filename;
1160 #print STDERR "Output file name: $filename\n";
1161 $filename = lc_last($filename);
1164 } elsif ($type eq "top" or $type eq "toc" or $type eq "doc" or
1165 $type eq "stoc" or $type eq "foot" or $type eq "about") {
1168 print STDERR "WARNING: Node '$node_name' was NOT found in the map\n"
1169 unless ($node_name eq '') or ($element->{'tag'} eq 'unnumberedsec')
1170 or ($node_name =~ /NOT REALLY USED/);
1172 # Numbered sections will get a filename Node_title, unnumbered sections will use
1173 # the file name of the previous numbered section:
1174 if (($element->{number}) or ($lastfilename eq '') or ($element->{level} == 1)) {
1175 # normalize to the same file name as texinfo
1176 if ($element->{translationof}) {
1177 $node_name = main::remove_texi($element->{translationof});
1179 my $filename = texinfo_file_name($node_name);
1180 $filename .= ".$docu_ext" if (defined($docu_ext));
1181 $filename = lc_last($filename);
1183 $$element{doc_nr} = $docnr;
1184 $lastfilename = $filename;
1185 print STDERR "File name: $filename\n";
1188 $$element{doc_nr} = $docnr;
1189 $filename = lc_last($filename);
1190 print STDERR "File name: $filename\n";
1198 sub lilypond_normalise_node($)
1201 my $norm = main::t2h_default_normalise_node($text);
1202 if (exists ($source_to_translationof_map->{$text})) {
1203 my $original = $source_to_translationof_map->{$text};
1204 $norm = main::t2h_default_normalise_node($original);
1210 # This function produces an anchor.
1213 # $name : anchor name
1214 # $href : anchor href
1215 # text : text displayed
1216 # extra_attribs : added to anchor attributes list
1217 sub lilypond_anchor($;$$$)
1222 my $attributes = shift;
1223 $href = remove_unneeded_anchor($href);
1224 if (!defined($attributes) or ($attributes !~ /\S/))
1230 $attributes = ' ' . $attributes;
1232 $name = '' if (!defined($name) or ($name !~ /\S/));
1233 $href = '' if (!defined($href) or ($href !~ /\S/));
1234 $text = '' if (!defined($text));
1235 return $text if (($name eq '') and ($href eq ''));
1236 $name = "name=\"$name\"" if ($name ne '');
1237 $href = "href=\"$href\"" if ($href ne '');
1238 $href = ' ' . $href if (($name ne '') and ($href ne ''));
1239 return "<a ${name}${href}${attributes}>$text</a>";
1243 sub lilypond_element_target_name($$$)
1245 my $element = shift;
1248 # Target is based on node name (or sec name for secs without node attached)
1249 my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
1250 if ($node_name eq '') {
1251 $node_name = main::remove_texi($element->{'texi'});
1254 # If we have an entry in the section<=>filename map, use that one, otherwise
1255 # generate the anchor here.
1256 if (exists ($node_to_filename_map->{$node_name})) {
1257 (my $filename, $target) = @{$node_to_filename_map->{$node_name}};
1259 my $anchor = $node_name;
1260 if ($element->{translationof}) {
1261 $anchor = main::remove_texi($element->{translationof});
1263 # normalize to the same file name as texinfo
1264 $target = texinfo_file_name($anchor);
1266 # TODO: Once texi2html correctly prints out the target and not the id for
1267 # the sections, change this back to ($id, $target)
1268 # I don't understand this comment, so I'm reluctant to delete it -gp
1269 $target = lc_last($target);
1271 # $id =~ s/-1$//i; # remove any trailing "-1"
1272 return ($target, $id);
1276 ## Load the map file for the corrently processed texi file. We do this
1277 # using a command init handler, since texi2html does not have any
1278 # other hooks that are called after THISDOC is filled but before phase 2
1279 # of the texi2html conversion.
1280 sub lilypond_init_map ()
1282 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1283 my $map_filename = main::locate_include_file ("${docu_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
1284 || main::locate_include_file ("${docu_name}.xref-map");
1285 #print STDERR "Map filename is: $map_filename\nDocu name is $docu_name\n";
1286 if ($docu_name eq 'web') {
1290 $node_to_filename_map = load_map_file ($map_filename);
1292 push @Texi2HTML::Config::command_handler_init, \&lilypond_init_map;
1296 #############################################################################
1297 ### CLEANER LINK TITLE FOR EXTERNAL REFS
1298 #############################################################################
1300 # The default formatting of external refs returns e.g.
1301 # "(lilypond-internals)Timing_translator", so we remove all (...) from the
1302 # file_and_node argument. Also, we want only a very simple format, so we don't
1303 # even call the default handler!
1304 sub lilypond_external_ref($$$$$$)
1307 my $section = shift;
1309 my $file_node = shift;
1312 $href = lc_last($href);
1314 my $cross_ref = shift;
1316 my $displaytext = '';
1318 # 1) if we have a cross ref name, that's the text to be displayed:
1319 # 2) For the top node, use the (printable) name of the manual, unless we
1320 # have an explicit cross ref name
1321 # 3) In all other cases use the section name
1322 if ($cross_ref ne '') {
1323 $displaytext = $cross_ref;
1324 } elsif (($section eq '') or ($section eq 'Top')) {
1325 $displaytext = $book;
1327 $displaytext = $section;
1330 $displaytext = &$anchor('', $href, $displaytext) if ($displaytext ne '');
1331 return &$I('%{node_file_href}', { 'node_file_href' => $displaytext });
1338 #############################################################################
1339 ### HANDLING TRANSLATED SECTIONS: handle @translationof, secname<->filename
1340 ### map stored on disk, xrefs in other manuals load that map
1341 #############################################################################
1344 # Try to make use of @translationof to generate files according to the original
1345 # English section title...
1346 sub lilypond_unknown($$$$$)
1354 # the @translationof macro provides the original English section title,
1355 # which should be used for file/anchor naming, while the title will be
1356 # translated to each language
1357 # It is already used by extract_texi_filenames.py, so this should not be
1358 # necessary here at all. Still, I'll leave the code in just in case the
1359 # python script messed up ;-)
1360 if ($pass == 1 and $macro eq "translationof") {
1361 if (ref($state->{'element'}) eq 'HASH') {
1362 $state->{'element'}->{'translationof'} = main::normalise_space($line);
1363 my $source = main::normalise_space ($line);
1364 if (ref($state->{'node_ref'}) eq 'HASH') {
1365 my $translationof = $state->{'node_ref'}->{'texi'};
1366 our %source_to_translationof_map;
1367 $source_to_translationof_map->{$source} = $translationof;
1370 return ('', 1, undef, undef);
1372 return &$default_unknown($macro, $line, $pass, $stack, $state);
1377 my %translated_books = ();
1378 # Construct a href to an external source of information.
1379 # node is the node with texinfo @-commands
1380 # node_id is the node transliterated and transformed as explained in the
1382 # node_xhtml_id is the node transformed such that it is unique and can
1383 # be used to make an html cross ref as explained in the texinfo manual
1384 # file is the file in '(file)node'
1385 sub lilypond_external_href($$$)
1388 my $node_id = shift;
1389 my $node_xhtml_id = shift;
1392 # 1) Keep a hash of book->section_map
1393 # 2) if not file in keys hash => try to load the map (assign empty map if
1394 # non-existent => will load only once!)
1395 # 3) if node in the section=>(file, anchor) map, replace node_id and
1396 # node_xhtml_id by the map's values
1397 # 4) call the default_external_href with these values (or the old ones if not found)
1399 if (($node_id ne '') and defined($file) and ($node_id ne 'Top')) {
1400 my $map_name = $file;
1401 $map_name =~ s/-big-page//;
1403 # Load the map if we haven't done so already
1404 if (!exists($translated_books{$map_name})) {
1405 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1406 my $map_filename = main::locate_include_file ("${map_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
1407 || main::locate_include_file ("${map_name}.xref-map");
1408 $translated_books{$map_name} = load_map_file ($map_filename);
1411 # look up translation. use these values instead of the old filename/anchor
1412 my $section_name_map = $translated_books{$map_name};
1413 my $node_text = main::remove_texi($node);
1414 if (defined($section_name_map->{$node_text})) {
1415 ($node_id, $node_xhtml_id) = @{$section_name_map->{$node_text}};
1417 print STDERR "WARNING: Unable to find node '$node_text' in book $map_name.\n";
1421 if (defined $file) {
1422 $href = &$default_external_href($node, $node_id, $node_xhtml_id, lc_last($file));
1423 $href = remove_unneeded_anchor($href);
1425 # TODO: very yucky, but will be fixed in issue 1004
1427 my $only_web = $ENV{ONLY_WEB};
1429 $href = "../../doc/v2.13/Documentation/web/".$href;
1435 $href = &$default_external_href($node, $node_id, $node_xhtml_id);
1436 $href = remove_unneeded_anchor($href);
1441 sub remove_unneeded_anchor($)
1444 my @hrefsplit = split("/", $href);
1445 for ($i = 0; $i < @hrefsplit; $i++) {
1446 $item = @hrefsplit[$i];
1448 @splitted = split(".html#", $item);
1449 if (@splitted[0] eq @splitted[1]) {
1450 @hrefsplit[$i] = @splitted[0] . ".html";
1454 $href = join("/", @hrefsplit);
1460 #############################################################################
1461 ### CUSTOM TOC FOR EACH PAGE (in a frame on the left)
1462 #############################################################################
1464 my $page_toc_depth = 2;
1465 my @default_toc = [];
1467 # Initialize the toc_depth to 1 if the command-line option -D=short_toc is given
1468 sub lilypond_init_toc_depth ()
1470 if (exists($main::value{'short_toc'}) and not exists($main::value{'bigpage'})
1471 and not $web_manual) {
1472 $page_toc_depth = 1;
1475 # Set the TOC-depth (depending on a texinfo variable short_toc) in a
1476 # command-handler, so we have them available when creating the pages
1477 push @Texi2HTML::Config::command_handler_process, \&lilypond_init_toc_depth;
1481 # recursively generate the TOC entries for the element and its children (which
1482 # are only shown up to maxlevel. All ancestors of the current element are also
1483 # shown with their immediate children, irrespective of their level.
1484 # Unnumbered entries are only printed out if they are at top-level or 2nd level
1485 # or their parent element is an ancestor of the currently viewed node.
1486 # The conditions to call this method to print the entry for a child node is:
1487 # -) the parent is an ancestor of the current page node
1488 # -) the parent is a numbered element at top-level toplevel (i.e. show numbered
1489 # and unnumbered 2nd-level children of numbered nodes)
1490 # -) the child element is a numbered node below level maxlevel
1491 sub generate_ly_toc_entries($$$$$)
1493 my $element = shift;
1494 my $element_path = shift;
1495 my $maxlevel = shift;
1499 my $child_count = shift;
1500 my $current_element = shift;
1501 # Skip undefined sections, plus all sections generated by index splitting
1502 return() if (not defined($element) or exists($element->{'index_page'}));
1504 my $level = $element->{'toc_level'};
1505 my $is_parent_of_current = $element->{'id'} && $element_path->{$element->{'id'}};
1506 my $ind = ' ' x $level;
1507 my $this_css_class = " class=\"";
1508 # color indices for the second navigation bar on the website
1511 'introduction' => [2, 2, 2, 2, 3, 3, 4, 4],
1512 'download' => [2, 2, 2, 3, 3, 4],
1513 'manuals' => [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4],
1514 'community' => [1, 1, 1, 2, 2, 2, 3, 3],
1516 my $addColor = "colorDefault";
1517 while (($top_section, $color_indices) = each %color_maps) {
1518 if (index ($element->{'sectionup'}->{'file'}, $top_section) >= 0) {
1519 $addColor = "color" . $color_indices->[$child_count];
1522 $this_css_class .= $addColor;
1524 $this_css_class .= $is_parent_of_current ? ' toc_current"' : '"';
1525 my $entry = "$ind<li$this_css_class>" .
1526 &$anchor ($element->{'tocid'},
1527 "$element->{'file'}#$element->{'target'}",
1528 $element->{'text'});
1530 push (@result, $entry);
1531 my $children = $element->{'section_childs'};
1532 if (defined($children) and (ref($children) eq "ARRAY")) {
1533 my $force_children = $is_parent_of_current or ($level == 1 and $element->{'number'});
1534 my @child_result = ();
1535 my $sub_child_count = 0;
1536 foreach my $c (@$children) {
1537 my $is_numbered_child = defined ($c->{'number'});
1538 my $below_maxlevel = $c->{'toc_level'} le $maxlevel;
1539 if ($force_children or ($is_numbered_child and $below_maxlevel)) {
1541 generate_ly_toc_entries($c, $element_path, $maxlevel, $sub_child_count, $current_element);
1542 push (@child_result, @child_res);
1543 $sub_child_count += 1;
1546 # if no child nodes were generated, e.g. for the index, where expanded pages
1547 # are ignored, don't generate a list at all...
1548 if (@child_result) {
1549 push (@result, "\n$ind<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
1551 push (@result, "$ind<li class=\"colorDefault" .
1552 ($element->{'text'} eq $current_element->{'text'} ?
1553 ' toc_current">' : '">') .
1554 &$anchor ($element->{'tocid'},
1555 "$element->{'file'}#$element->{'target'}",
1556 $element->{'text'}) . "</li>\n");
1558 push (@result, @child_result);
1559 push (@result, "$ind</ul>\n");
1562 push (@result, "$ind</li>\n");
1567 # Print a customized TOC, containing only the first two levels plus the whole
1568 # path to the current page
1569 sub lilypond_generate_page_toc_body($)
1571 my $element = shift;
1572 my $current_element = $element;
1574 $parentelements{$element->{'id'}} = 1;
1575 # Find the path to the current element
1576 while ( defined($current_element->{'sectionup'}) and
1577 ($current_element->{'sectionup'} ne $current_element) )
1579 $parentelements{$current_element->{'sectionup'}->{'id'}} = 1
1580 if ($current_element->{'sectionup'}->{'id'} ne '');
1581 $current_element = $current_element->{'sectionup'};
1583 if (exists($main::value{'shallow_toc'})) {
1588 return () if not defined($current_element);
1589 # Create the toc entries recursively
1590 my @toc_entries = "";
1592 @toc_entries = "<ul$NO_BULLET_LIST_ATTRIBUTE>\n";
1593 # FIXME: add link to main page, really hackily.
1594 if ($element->{'sectionup'}) {
1595 # it's not the top element
1596 push (@toc_entries, "<li><a href=\"index.html\">Main</a></li>\n");
1599 "<li class=\"toc_current\"><a href=\"index.html\">Main</a></li>\n");
1602 push (@toc_entries, "<div class=\"contents\">\n");
1603 push (@toc_entries, "<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
1605 my $children = $current_element->{'section_childs'};
1606 foreach ( @$children ) {
1607 push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth, 0, $element));
1610 # I'm assuming that we wouldn't keep the google search box? -gp
1611 if (!($ENV{AJAX_SEARCH} == 1)) {
1613 my $name = "search-box";
1614 $lang = $Texi2HTML::THISDOC{current_lang};
1615 open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$lang/$name.ihtml" or
1616 open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$name.ihtml" or
1617 die "no such file: $name.ihtml: $!";
1618 my $search_string = decode ('UTF-8', <FILE>);
1619 $search_string = "<li>\n" . $search_string . "</li>\n";
1620 push (@toc_entries, $search_string);
1624 push (@toc_entries, "</ul>\n");
1626 push (@toc_entries, "\n");
1628 push (@toc_entries, "</div>\n");
1630 return @toc_entries;
1633 sub lilypond_print_toc_div ($$)
1637 my @lines = @$tocref;
1638 # use default TOC if no custom lines have been generated
1639 @lines = @default_toc if (not @lines);
1642 print $fh "\n\n<div id=\"tocframe\">\n";
1644 # Remove the leading "GNU LilyPond --- " from the manual title
1645 my $topname = $Texi2HTML::NAME{'Top'};
1646 $topname =~ s/^GNU LilyPond(:| &[mn]dash;) //;
1648 # construct the top-level Docs index (relative path and including language!)
1649 my $lang = $Texi2HTML::THISDOC{current_lang};
1650 if ($lang and $lang ne "en") {
1655 my $reldir = $ENV{DEPTH};
1656 # strip one depth level for translations
1657 if ($lang and $lang ne "en" and substr ($reldir, 0, 3) eq '../') {
1658 $reldir = substr ($reldir, 3);
1660 # add a / at the end if there isn't one.
1661 if (substr ($reldir, -1) ne '/') {
1664 my $uplink = $reldir."Documentation/web/manuals.${lang}html";
1666 if (not $web_manual) {
1667 print $fh "<p class=\"toc_uplink\"><a href=\"$uplink\"
1668 title=\"Documentation Index\"><< " .
1669 &ly_get_string ('Back to Documentation Index') .
1672 # AJAX search box, written in JavaScript
1673 if ($ENV{'AJAX_SEARCH'} == 1) {
1674 if ($have_index_entries) {
1675 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
1676 print $fh '<script language="JavaScript">print_search_field ("' .
1677 $Texi2HTML::THISDOC{current_lang} . '", "' .
1678 $docu_name . "\", " . $bigpage . ")</script>\n";
1682 print $fh '<h4 class="toc_header"> ' . &$anchor('',
1683 $Texi2HTML::HREF{'Top'},
1685 'title="Start of the manual"'
1689 foreach my $line (@lines) {
1692 print $fh "</div>\n\n";
1696 # Create the custom TOC for this page (partially folded, current page is
1697 # highlighted) and store it in a global variable. The TOC is written out after
1698 # the html contents (but positioned correctly using CSS), so that browsers with
1699 # css turned off still show the contents first.
1700 our @this_page_toc = ();
1701 sub lilypond_print_element_header
1703 my $first_in_page = shift;
1704 my $previous_is_top = shift;
1705 if ($first_in_page and not @this_page_toc) {
1706 if (defined($Texi2HTML::THIS_ELEMENT)) {
1707 # Create the TOC for this page
1708 @this_page_toc = lilypond_generate_page_toc_body($Texi2HTML::THIS_ELEMENT);
1711 return &$default_print_element_header( $first_in_page, $previous_is_top);
1714 # Generate the HTML output for the TOC
1715 sub lilypond_toc_body($)
1717 my $elements_list = shift;
1718 # Generate a default TOC for pages without THIS_ELEMENT
1719 @default_toc = lilypond_generate_page_toc_body(@$elements_list[0]);
1720 return &$default_toc_body($elements_list);
1723 # Print out the TOC in a <div> at the beginning of the page
1724 sub lilypond_print_page_head($)
1727 &$default_print_page_head($fh);
1728 print $fh "<div id=\"main\">\n";
1731 # Print out the TOC in a <div> at the end of th page, which will be formatted as a
1732 # sidebar mimicking a TOC frame
1733 sub print_lilypond_page_foot($)
1736 my $program_string = &$program_string();
1737 # print $fh "<p><font size='-1'>$program_string</font><br>$PRE_BODY_CLOSE</p>\n";
1738 print $fh "<!-- FOOTER -->\n\n";
1739 print $fh "<!-- end div#main here -->\n</div>\n\n";
1741 # FIXME: This div and p#languages need to be in div#footer.
1742 # Should we move this div to postprocess_html.py ?
1743 print $fh "<div id=\"verifier_texinfo\">\n";
1744 print $fh "<h3>Validation</h3>\n";
1745 # FIXME: inlined text substitution, move to ly_get_string as soon as another case is needed
1746 my $webdev_link = "<a href=\"http://www.webdev.nl/\">webdev.nl</a>";
1747 my $lily_site = "<code>lilypond.org</code>";
1748 my $hosting_thanks = &ly_get_string ('<p>Thanks to ${webdev_link} for hosting ${lily_site}.');
1749 # this does the variable substitution ("quoting" in Perlish) after the localization
1750 $hosting_thanks =~ s/(\$\{\w+\})/$1/eeg;
1751 print $fh $hosting_thanks . "\n";
1752 print $fh "<a href=\"http://validator.w3.org/check?uri=referer\">\n";
1753 print $fh "<img src=\"http://www.w3.org/Icons/valid-html401\"\n";
1754 print $fh " alt=\"Valid HTML 4.01 Transitional\"\n";
1755 print $fh " height=\"31\" width=\"88\"></a></p>\n";
1759 # Print the TOC frame and reset the TOC:
1760 lilypond_print_toc_div ($fh, \@this_page_toc);
1761 @this_page_toc = ();
1764 print $fh "</body>\n</html>\n";
1771 #############################################################################
1772 ### NICER / MORE FLEXIBLE NAVIGATION PANELS
1773 #############################################################################
1775 sub get_navigation_text
1778 my $text = $NAVIGATION_TEXT{$button};
1779 if ( ($button eq 'Back') or ($button eq 'FastBack') ) {
1780 $text = $text . $Texi2HTML::NODE{$button} . " ";
1781 } elsif ( ($button eq 'Forward') or ($button eq 'FastForward') ) {
1782 $text = " " . $Texi2HTML::NODE{$button} . $text;
1783 } elsif ( $button eq 'Up' ) {
1784 $text = " ".$text.": " . $Texi2HTML::NODE{$button} . " ";
1790 # Don't automatically create left-aligned table cells for every link, but
1791 # instead create a <td> only on an appropriate '(left|right|center)-aligned-cell-n'
1792 # button text. It's alignment as well as the colspan will be taken from the
1793 # name of the button. Also, add 'newline' button text to create a new table
1794 # row. The texts of the buttons are generated by get_navigation_text and
1795 # will contain the name of the next/previous section/chapter.
1796 sub lilypond_print_navigation
1798 my $buttons = shift;
1799 my $vertical = shift;
1801 my $result = "<table class=\"nav_table\">\n";
1803 $result .= "<tr>" unless $vertical;
1804 my $beginofline = 1;
1805 foreach my $button (@$buttons)
1807 $result .= qq{<tr valign="top" align="left">\n} if $vertical;
1808 # Allow (left|right|center)-aligned-cell and newline as buttons!
1809 if ( $button =~ /^(.*)-aligned-cell-(.*)$/ )
1811 $result .= qq{</td>} unless $beginofline;
1812 $result .= qq{<td valign="middle" align="$1" colspan="$2">};
1815 elsif ( $button eq 'newline' )
1817 $result .= qq{</td>} unless $beginofline;
1818 $result .= qq{</tr>};
1819 $result .= qq{<tr>};
1823 elsif (ref($button) eq 'CODE')
1825 $result .= &$button($vertical);
1827 elsif (ref($button) eq 'SCALAR')
1829 $result .= "$$button" if defined($$button);
1831 elsif (ref($button) eq 'ARRAY')
1833 my $text = $button->[1];
1834 my $button_href = $button->[0];
1835 # verify that $button_href is simple text and text is a reference
1836 if (defined($button_href) and !ref($button_href)
1837 and defined($text) and (ref($text) eq 'SCALAR') and defined($$text))
1839 if ($Texi2HTML::HREF{$button_href})
1841 my $anchor_attributes = '';
1842 if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button_href})) and
1843 ($BUTTONS_ACCESSKEY{$button_href} ne ''))
1845 $anchor_attributes = "accesskey=\"$BUTTONS_ACCESSKEY{$button_href}\"";
1847 if ($USE_REL_REV and (defined($BUTTONS_REL{$button_href})) and
1848 ($BUTTONS_REL{$button_href} ne ''))
1850 $anchor_attributes .= " rel=\"$BUTTONS_REL{$button_href}\"";
1854 $Texi2HTML::HREF{$button_href},
1855 get_navigation_text($$text),
1861 $result .= get_navigation_text($$text);
1865 elsif ($button eq ' ')
1866 { # handle space button
1868 ($ICONS && $ACTIVE_ICONS{' '}) ?
1869 &$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{' '}) :
1870 $NAVIGATION_TEXT{' '};
1873 elsif ($Texi2HTML::HREF{$button})
1874 { # button is active
1875 my $btitle = $BUTTONS_GOTO{$button} ?
1876 'title="' . $BUTTONS_GOTO{$button} . '"' : '';
1877 if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button})) and
1878 ($BUTTONS_ACCESSKEY{$button} ne ''))
1880 $btitle .= " accesskey=\"$BUTTONS_ACCESSKEY{$button}\"";
1882 if ($USE_REL_REV and (defined($BUTTONS_REL{$button})) and
1883 ($BUTTONS_REL{$button} ne ''))
1885 $btitle .= " rel=\"$BUTTONS_REL{$button}\"";
1887 if ($ICONS && $ACTIVE_ICONS{$button})
1891 $Texi2HTML::HREF{$button},
1892 &$button_icon_img($BUTTONS_NAME{$button},
1893 $ACTIVE_ICONS{$button},
1894 $Texi2HTML::SIMPLE_TEXT{$button}),
1903 $Texi2HTML::HREF{$button},
1904 get_navigation_text($button),
1911 { # button is passive
1913 $ICONS && $PASSIVE_ICONS{$button} ?
1914 &$button_icon_img($BUTTONS_NAME{$button},
1915 $PASSIVE_ICONS{$button},
1916 $Texi2HTML::SIMPLE_TEXT{$button}) :
1918 "[" . get_navigation_text($button) . "]";
1920 $result .= "</td>\n" if $vertical;
1921 $result .= "</tr>\n" if $vertical;
1923 $result .= "</td>" unless $beginofline;
1924 $result .= "</tr>" unless $vertical;
1925 $result .= "</table>\n";
1934 @Texi2HTML::Config::SECTION_BUTTONS =
1935 ('left-aligned-cell-1', 'FastBack',
1936 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1937 'right-aligned-cell-1', 'FastForward',
1939 'left-aligned-cell-2', 'Back',
1940 'center-aligned-cell-1', 'Up',
1941 'right-aligned-cell-2', 'Forward'
1944 # buttons for misc stuff
1945 @Texi2HTML::Config::MISC_BUTTONS = ('center-aligned-cell-3',
1946 'Top', 'Contents', 'Index', 'About');
1948 # buttons for chapter file footers
1949 # (and headers but only if SECTION_NAVIGATION is false)
1950 @Texi2HTML::Config::CHAPTER_BUTTONS =
1951 ('left-aligned-cell-1', 'FastBack',
1952 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1953 'right-aligned-cell-1', 'FastForward',
1956 # buttons for section file footers
1957 @Texi2HTML::Config::SECTION_FOOTER_BUTTONS =
1958 ('left-aligned-cell-1', 'FastBack',
1959 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1960 'right-aligned-cell-1', 'FastForward',
1962 'left-aligned-cell-2', 'Back',
1963 'center-aligned-cell-1', 'Up',
1964 'right-aligned-cell-2', 'Forward'
1967 @Texi2HTML::Config::NODE_FOOTER_BUTTONS =
1968 ('left-aligned-cell-1', 'FastBack',
1969 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1970 'right-aligned-cell-1', 'FastForward',
1972 'left-aligned-cell-2', 'Back',
1973 'center-aligned-cell-1', 'Up',
1974 'right-aligned-cell-2', 'Forward'
1981 #############################################################################
1982 ### FOOTNOTE FORMATTING
1983 #############################################################################
1985 # Format footnotes in a nicer way: Instead of printing the number in a separate
1986 # (nr) heading line, use the standard way of prepending <sup>nr</sup> immediately
1987 # before the fn text.
1990 # The following code is copied from texi2html's examples/makeinfo.init and
1991 # should be updated when texi2html makes some changes there!
1993 my $makekinfo_like_footnote_absolute_number = 0;
1995 sub makeinfo_like_foot_line_and_ref($$$$$$$$)
1997 my $foot_num = shift;
1998 my $relative_num = shift;
2001 my $from_file = shift;
2002 my $footnote_file = shift;
2006 $makekinfo_like_footnote_absolute_number++;
2008 # this is a bit obscure, this allows to add an anchor only if formatted
2009 # as part of the document.
2010 $docid = '' if ($state->{'outside_document'} or $state->{'multiple_pass'});
2012 if ($from_file eq $footnote_file)
2014 $from_file = $footnote_file = '';
2017 my $foot_anchor = "<sup>" .
2018 &$anchor($docid, "$footnote_file#$footid", $relative_num) . "</sup>";
2019 $foot_anchor = &$anchor($docid,
2020 "$footnote_file#$footid",
2021 "($relative_num)") if ($state->{'preformatted'});
2023 # unshift @$lines, "<li>";
2024 # push @$lines, "</li>\n";
2025 return ($lines, $foot_anchor);
2028 sub makeinfo_like_foot_lines($)
2031 unshift @$lines, "<hr>\n<h4>$Texi2HTML::I18n::WORDS->{'Footnotes_Title'}</h4>\n";
2032 #<ol type=\"1\">\n";
2033 # push @$lines, "</ol>";
2037 my %makekinfo_like_paragraph_in_footnote_nr;
2039 sub makeinfo_like_paragraph ($$$$$$$$$$$$$)
2044 my $paragraph_command = shift;
2045 my $paragraph_command_formatted = shift;
2046 my $paragraph_number = shift;
2048 my $item_nr = shift;
2049 my $enumerate_style = shift;
2051 my $command_stack_at_end = shift;
2052 my $command_stack_at_begin = shift;
2054 #print STDERR "format: $format\n" if (defined($format));
2055 #print STDERR "paragraph @$command_stack_at_end; @$command_stack_at_begin\n";
2056 $paragraph_command_formatted = '' if (!defined($paragraph_command_formatted) or
2057 exists($special_list_commands{$format}->{$paragraph_command}));
2058 return '' if ($text =~ /^\s*$/);
2059 foreach my $style(t2h_collect_styles($command_stack_at_begin))
2061 $text = t2h_begin_style($style, $text);
2063 foreach my $style(t2h_collect_styles($command_stack_at_end))
2065 $text = t2h_end_style($style, $text);
2067 if (defined($paragraph_number) and defined($$paragraph_number))
2069 $$paragraph_number++;
2070 return $text if (($format eq 'itemize' or $format eq 'enumerate') and
2071 ($$paragraph_number == 1));
2076 $open .= " align=\"$paragraph_style{$align}\"";
2078 my $footnote_text = '';
2079 if (defined($command_stack_at_begin->[0]) and $command_stack_at_begin->[0] eq 'footnote')
2081 my $state = $Texi2HTML::THISDOC{'state'};
2082 $makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number}++;
2083 if ($makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number} <= 1)
2085 $open.=' class="footnote"';
2086 my $document_file = $state->{'footnote_document_file'};
2087 if ($document_file eq $state->{'footnote_footnote_file'})
2089 $document_file = '';
2091 my $docid = $state->{'footnote_place_id'};
2092 my $doc_state = $state->{'footnote_document_state'};
2093 $docid = '' if ($doc_state->{'outside_document'} or $doc_state->{'multiple_pass'});
2094 my $foot_label = &$anchor($state->{'footnote_footnote_id'},
2095 $document_file . "#$state->{'footnote_place_id'}",
2096 "$state->{'footnote_number_in_page'}");
2097 $footnote_text = "<small>[${foot_label}]</small> ";
2100 return $open.'>'.$footnote_text.$text.'</p>';
2104 #############################################################################
2105 ### WRITING OUT THE INDEX FOR THE AJAX SEARCH FIELD
2106 #############################################################################
2108 $Texi2HTML::Config::IDX_SUMMARY = 1;
2109 $Texi2HTML::Config::init_out = \&lilypond_init_out;
2110 $Texi2HTML::Config::finish_out = \&lilypond_finish_out;
2111 $Texi2HTML::Config::index_summary_file_entry = \&lilypond_index_summary_file_entry;
2115 sub lilypond_init_out ()
2117 t2h_default_init_out ();
2118 # Check whether we have an index at all! If not -> don't print out a search box!
2119 my $ix = main::get_index ("cp");
2120 $have_index_entries = (scalar $ix > 0);
2123 sub lilypond_index_summary_file_entry ($$$$$$$$$)
2125 my $index_name = shift;
2126 my $entry_text = shift;
2127 my $entry_reference = shift;
2128 my $formatted_entry = shift;
2129 my $texi_entry = shift;
2130 my $entry_element_reference = shift;
2131 my $entry_element_header = shift;
2132 my $is_printed = shift;
2133 my $manual_name = shift;
2135 if ($ENV{'AJAX_SEARCH'}==1) {
2136 if ($index_name eq "cp")
2138 # The entries in the index file have the form:
2139 # SearchText \t FormattedText \t EntryURL \t SectionText \t SectionURL
2140 push @index_entries, "$entry_text\t$formatted_entry\t$entry_reference\t$entry_element_header\t$entry_element_reference\n";
2145 sub lilypond_finish_out ()
2147 if ($ENV{'AJAX_SEARCH'}==1) {
2148 if (((scalar @index_entries) > 0) and $have_index_entries) {
2149 my $lang = $Texi2HTML::THISDOC{current_lang};
2151 $big = "-big-page" if $bigpage;
2152 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
2153 my $idx_file = "$docu_dir/$docu_name$big.$lang.idx";
2154 open IDXOUTFILE, ">:utf8", $idx_file;
2155 print IDXOUTFILE @index_entries;
2163 #############################################################################
2165 #############################################################################
2167 # For split pages, use index.html as start page!
2168 if ($Texi2HTML::Config::SPLIT eq 'section' or
2169 $Texi2HTML::Config::SPLIT eq 'node') {
2170 $Texi2HTML::Config::TOP_FILE = 'index.html';