2 # -*- coding: utf-8; -*-
4 ### texi2html customization script for LilyPond
5 ### Author: Reinhold Kainhofer <reinhold@kainhofer.com>, 2008.
6 ### Some code parts copied from texi2html and adapted. These functions
7 ### were written mainly by Patrice Dumas
11 ### Features implemented here:
12 ### -) For split manuals, the main page is index.html.
13 ### -) All @unnumbered* sections are placed into the same file
14 ### (implemented by split_at_numbered_sections)
15 ### -) Use our custom CSS file, with IE-specific fixes in another CSS file,
16 ### impelmented by lilypond_css_lines
17 ### -) TOC (folded, with the current page highlighted) in an overflown <div>
18 ### is added to every page; implemented by:
19 ### lilypond_print_element_header -- building of the TOC
20 ### lilypond_toc_body -- generation of customized TOC output
21 ### lilypond_print_page_head -- start <div id="main">
22 ### print_lilypond_page_foot -- closing id=main, output of footer & TOC
23 ### -) External refs are formatted only as "Text of the node" (not as >>see
24 ### "NODE" section "SECTION" in "BOOK"<< like with default texi2html). Also,
25 ### the leading "(book-name)" is removed.
26 ### Implemented by overriding lilypond_external_ref
27 ### -) Navigation bars on top/bottom of the page and between sections are not
28 ### left-aligned, but use a combination of left/center/right aligned table
29 ### cells; For this, I heavily extend the texi2html code to allow for
30 ### differently aligned cells and for multi-line tables);
31 ### Implemented in lilypond_print_navigation
32 ### -) Different formatting than the default: example uses the same formatting
34 ### -) Allow translated section titles: All section titles can be translated,
35 ### the original (English) title is associated with @translationof. This is
36 ### needed, because the file name / anchor is generated from the original
37 ### English title, since otherwise language-autoselection would break with
39 ### Since it is then no longer possible to obtain the file name from the
40 ### section title, I keep a sectionname<=>filename/anchor around. This way,
41 ### xrefs from other manuals can simply load that map and retrieve the
42 ### correct file name for the link. Implemented in:
43 ### lilypond_unknown (handling of @translationof, in case
44 ### extract_texi_filenames.py messes up...)
45 ### lilypond_element_file_name (correct file name: use the map)
46 ### lilypond_element_target_name (correct anchor: use the map)
47 ### lilypond_init_map (read in the externally created map from disk)
48 ### lilypond_external_href (load the map for xrefs, use the correct
50 ### -) The HTML anchors for all sections are derived from the node name /
51 ### section title (pre-generated in the .xref-map file). Implemented by:
52 ### lilypond_element_target_name (adjust section anchors)
53 ### -) Use the standard footnote format "<sup>nr</sup> text" instead of the
54 ### ugly format of texi2html (<h3>(nr)</h3><p>text</p>). Implemented in
55 ### makeinfo_like_foot_line_and_ref
56 ### makeinfo_like_foot_lines
57 ### makeinfo_like_paragraph
60 ### Useful helper functions:
61 ### -) texinfo_file_name($node_name): returns a texinfo-compatible file name
62 ### for the given string $node_name (whitespace trimmed/replaced by -,
63 ### non-standard chars replaced by _xxxx (ascii char code) and forced to
64 ### start with a letter by prepending t_g if necessary)
67 package Texi2HTML::Config;
70 use Encode qw(decode);
72 #############################################################################
74 #############################################################################
76 my $LY_LANGUAGES = {};
77 $LY_LANGUAGES->{'fr'} = {
78 'Back to Documentation Index' => 'Retour à l\'accueil de la documentation',
79 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '<p>Remerciements à ${webdev_link} pour l\'hébergement de ${lily_site}.',
82 $LY_LANGUAGES->{'es'} = {
83 'Back to Documentation Index' => 'Volver al índice de la documentación',
84 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '<p>Agradecemos a ${webdev_link} el alojamiento de ${lily_site}.',
87 $LY_LANGUAGES->{'de'} = {
88 'Back to Documentation Index' => 'Zur Dokumentationsübersicht',
89 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '',
92 $LY_LANGUAGES->{'ja'} = {
93 'Back to Documentation Index' => 'ドキュメント インデックスに戻る',
94 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '',
97 $LY_LANGUAGES->{'hu'} = {
98 'Back to Documentation Index' => 'Vissza a dokumentációk jegyzékéhez',
99 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '',
102 $LY_LANGUAGES->{'it'} = {
103 'Back to Documentation Index' => 'Torna all\'indice della documentazione',
104 '<p>Thanks to ${webdev_link} for hosting ${lily_site}.' => '',
107 # FIXME: request the translations below then send them to texi2html/texinfo devs
108 $LANGUAGES->{'it'} = {
109 ' The buttons in the navigation panels have the following meaning:' => ' I bottoni nei pannelli di navigazione hanno il seguente significato:',
110 ' 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:',
112 '(outside of any element)' => '(fuori da qualsiasi elemento)',
113 '(outside of any node)' => '(fuori da qualsiasi nodo)',
114 '@b{{quotation_arg}:} ' => '@b{{quotation_arg}:} ',
115 '@cite{{book}}' => '@cite{{book}}',
116 '@{No value for `{value}\'@}' => '@{Nessun valore per `{value}\'@}',
117 'About' => 'Informazioni',
118 'About (help)' => 'Informazioni (aiuto)',
119 'About This Document' => 'Informazioni su questo documento',
121 'August' => 'Agosto',
122 'Back' => 'Indietro',
123 'Back section in previous file' => '',
124 'Beginning of this chapter or previous chapter' => 'Inizio di questo capitolo o capitolo precedente',
125 'Button' => 'Bottone',
126 'Contents' => 'Contenuti',
127 'Cover (top) of document' => 'Copertina (inizio) del documento',
128 'Current' => 'Attuale',
129 'Current Position' => 'Posizione Attuale',
130 'Current section' => 'Sezione attuale',
131 'December' => 'Dicembre',
132 'FastBack' => 'Indietro veloce',
133 'FastForward' => 'Avanti veloce',
134 'February' => 'Febbraio',
136 'First section in reading order' => 'Prima sezione in ordine di lettura',
137 'Following' => 'Seguente',
138 'Following node' => 'Nodo seguente',
139 'Footnotes' => 'Note a piè di pagina',
140 'Forward' => 'Avanti',
141 'Forward section in next file' => 'Sezione successiva nel prossimo file',
142 'From 1.2.3 go to' => 'Da 1.2.3 vai a',
145 'Index Entry' => 'Voce dell\'indice',
146 'January' => 'Gennaio',
148 'Jump to' => 'Salta a',
151 'Last section in reading order' => 'Ultima sezione in ordine di lettura',
156 'Next' => 'Successivo',
157 'Next chapter' => 'Capitolo successivo',
158 'Next file' => 'File successivo',
159 'Next node' => 'Nodo successivo',
160 'Next section in reading order' => 'Sezione successiva in ordine di lettura',
161 'Next section on same level' => 'Sezione successiva sullo stesso livello',
162 'NextFile' => 'File successivo',
163 'Node following in node reading order' => 'Nodo seguente in ordine di lettura',
164 'Node up' => 'Nodo superiore',
165 'NodeNext' => 'Nodo successivo',
166 'NodePrev' => 'Nodo precedente',
167 'NodeUp' => 'Nodo superiore',
168 'November' => 'Novembre',
169 'October' => 'Ottobre',
170 'Overview' => 'Panoramica',
172 'PrevFile' => 'File precedente',
173 'Previous' => 'Precedente',
174 'Previous file' => 'File precedente',
175 'Previous node' => 'Nodo precedente',
176 'Previous section in reading order' => 'Sezione precedente in ordine di lettura',
177 'Previous section on same level' => 'Sezione precedente sullo stesso livello',
178 'Section' => 'Sezione',
179 'Section One' => 'Sezione uno',
181 'See @cite{{book}}' => 'Vedi @cite{{book}}',
182 'See section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'Vedi la sezione `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}',
183 'See section `{section}\' in @cite{{book}}' => 'Vedi la sezione `{section}\' in @cite{{book}}',
184 'See section {reference_name}' => 'Vedi la sezione {reference_name}',
185 'See {node_file_href}' => 'Vedi {node_file_href}',
186 'See {node_file_href} @cite{{book}}' => 'Vedi {node_file_href} @cite{{book}}',
187 'See {node_file_href} section `{section}\' in @cite{{book}}' => 'Vedi {node_file_href} nella sezione `{section}\' in @cite{{book}}',
188 'See {reference_name}' => 'Vedi {reference_name}',
189 'See {ref}' => 'Vedi {ref}',
190 'See {title_ref}' => 'Vedi {title_ref}',
191 'September' => 'Settembre',
192 'Short Table of Contents' => 'Indice breve',
193 'Short table of contents' => 'Indice breve',
194 'Subsection One-Four' => 'Sottosezione Uno-Quattro',
195 'Subsection One-One' => 'Sottosezione Uno-Uno',
196 'Subsection One-Three' => 'Sottosezione Uno-Tre',
197 'Subsection One-Two' => 'Sottosezione Uno-Due',
198 'Subsubsection One-Two-Four' => 'Sottosottosezione Uno-Due-Quattro',
199 'Subsubsection One-Two-One' => 'Sottosottosezione Uno-Due-Uno',
200 'Subsubsection One-Two-Three' => 'Sottosottosezione Uno-Due-Tre',
201 'Subsubsection One-Two-Two' => 'Sottosottosezione Uno-Due-Due',
202 'T2H_today' => '%s, %d %d',
203 'Table of Contents' => 'Indice',
204 'Table of contents' => 'Indice',
205 'The node you are looking for is at {href}.' => 'Il nodo che stai cercando è {href}',
207 '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}}}.',
208 'This document was generated using @uref{{program_homepage}, @emph{{program}}}.' => 'Questo documento è stato generato con @uref{{program_homepage}, @emph{{program}}}.',
210 'Untitled Document' => 'Documento senza titolo',
212 'Up node' => 'Nodo superiore',
213 'Up section' => 'Sezione superiore',
214 'current' => 'attuale',
215 'on @emph{{date}}' => 'il @emph{{date}}',
216 'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'sezione `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}',
217 'section `{section}\' in @cite{{book}}' => 'sezione `{section}\' in @cite{{book}}',
219 'see @cite{{book}}' => 'vedi @cite{{book}}',
220 'see section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'vedi la sezione `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}',
221 'see section `{section}\' in @cite{{book}}' => 'vedi la sezione `{section}\' in @cite{{book}}',
222 'see section {reference_name}' => 'vedi la sezione {reference_name}',
223 'see {node_file_href}' => 'vedi {node_file_href}',
224 'see {node_file_href} @cite{{book}}' => 'vedi {node_file_href} @cite{{book}}',
225 'see {node_file_href} section `{section}\' in @cite{{book}}' => 'vedi {node_file_href} nella sezione `{section}\' in @cite{{book}}',
226 'see {reference_name}' => 'vedi {reference_name}',
227 'see {ref}' => 'vedi {ref}',
228 'see {title_ref}' => 'vedi {title_ref}',
229 '{acronym_like} ({explanation})' => '{acronym_like} ({explanation})',
230 '{name} of {class}' => '{name} di {class}',
231 '{name} on {class}' => '{name} in {class}',
232 '{node_file_href}' => '{node_file_href}',
233 '{node_file_href} @cite{{book}}' => '{node_file_href} @cite{{book}}',
234 '{node_file_href} section `{section}\' in @cite{{book}}' => '{node_file_href} nella sezione `{section}\' in @cite{{book}}',
235 '{reference_name}' => '{reference_name}',
237 '{style} {number}' => '{style} {number}',
238 '{style}: {caption_first_line}' => '{style}: {caption_first_line}',
239 '{style}: {shortcaption_first_line}' => '{style}: {shortcaption_first_line}',
240 '{title_ref}' => '{title_ref}'
243 $LANGUAGES->{'hu'} = {
244 ' The buttons in the navigation panels have the following meaning:' => ' A navigációs panelen levő gombok jelentése a következő:',
245 ' 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ő:',
247 '(outside of any element)' => '(bármelyik elemen kívül)',
248 '(outside of any node)' => '(bármelyik csomóponton kívül)',
249 '@b{{quotation_arg}:} ' => '@b{{quotation_arg}:} ',
250 '@cite{{book}}' => '@cite{{book}}',
251 '@{No value for `{value}\'@}' => '@{Nincs értéke ennek: `{value}\'@}',
253 'About (help)' => 'Segítség a navigációhoz',
254 'About This Document' => 'A navigációs panel használata',
255 'April' => 'április',
256 'August' => 'augusztus',
258 'Back section in previous file' => 'Előző fájl hátsó szakasza',
259 'Beginning of this chapter or previous chapter' => 'Fejezet eleje vagy előző fejezet',
261 'Contents' => 'Tartalom',
262 'Cover (top) of document' => 'Dokumentum címoldala',
263 'Current' => 'Aktuális',
264 'Current Position' => 'Aktuális pozíció',
265 'Current section' => 'Aktuális szakasz',
266 'December' => 'december',
267 'FastBack' => 'Visszaugrás',
268 'FastForward' => 'Előreugrás',
269 'February' => 'február',
271 'First section in reading order' => 'Első szakasz az olvasási sorrendben',
272 'Following' => 'Következő',
273 'Following node' => 'Következő csomópont',
274 'Footnotes' => 'Lábjegyzet',
275 'Forward' => 'Előre',
276 'Forward section in next file' => 'Következő fájl elülső szakasza',
277 'From 1.2.3 go to' => '1.2.3-ból ide jutunk',
279 'Index' => 'Tárgymutató',
280 'Index Entry' => 'Tárgymutató-bejegyzés',
281 'January' => 'január',
283 'Jump to' => 'Ugorj ide',
286 'Last section in reading order' => 'Utolsó szakasz az olvasási sorrendben',
287 'March' => 'március',
291 'Next' => 'Következő',
292 'Next chapter' => 'Következő fejezet',
293 'Next file' => 'Következő fájl',
294 'Next node' => 'Következő csomópont',
295 'Next section in reading order' => 'Következő szakasz az olvasási sorrendben',
296 'Next section on same level' => 'Következő szakasz ugyanazon a szinten',
297 'NextFile' => 'KövetkezőFájl',
298 'Node following in node reading order' => 'Következő csomópont az olvasási sorrendben',
299 'Node up' => 'Szülő csomópont',
300 'NodeNext' => 'KövetkezőCsomópont',
301 'NodePrev' => 'ElőzőCsomópont',
302 'NodeUp' => 'SzülőCsomópont',
303 'November' => 'november',
304 'October' => 'október',
305 'Overview' => 'Áttekintés',
307 'PrevFile' => 'ElőzőFájl',
308 'Previous' => 'Előző',
309 'Previous file' => 'Előző fájl',
310 'Previous node' => 'Előző csomópont',
311 'Previous section in reading order' => 'Előző szakasz az olvasási sorrendben',
312 'Previous section on same level' => 'Előző szakasz ugyanazon a szinten',
313 'Section' => 'Szakasz',
314 'Section One' => 'szakasz',
316 'See @cite{{book}}' => 'Ld. @cite{{book}}',
317 'See section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'Ld. ezt a szakaszt: `@asis{}`{section_name}\'@asis{}\' itt: @cite{{book}}',
318 'See section `{section}\' in @cite{{book}}' => 'Ld. ezt a szakaszt: `{section}\' itt: @cite{{book}}',
319 'See section {reference_name}' => 'Ld. ezt a szakaszt: {reference_name}',
320 'See {node_file_href}' => 'Ld. {node_file_href}',
321 'See {node_file_href} @cite{{book}}' => 'See {node_file_href} @cite{{book}}',
322 'See {node_file_href} section `{section}\' in @cite{{book}}' => 'Ld. {node_file_href} ezt a szakaszt: `{section}\' itt: @cite{{book}}',
323 'See {reference_name}' => 'Ld. {reference_name}',
324 'See {ref}' => 'Ld. {ref}',
325 'See {title_ref}' => 'Ld. {title_ref}',
326 'September' => 'szeptember',
327 'Short Table of Contents' => 'Rövid tartalomjegyzék',
328 'Short table of contents' => 'Rövid tartalomjegyzék',
329 'Subsection One-Four' => 'alszakasz',
330 'Subsection One-One' => 'alszakasz',
331 'Subsection One-Three' => 'alszakasz',
332 'Subsection One-Two' => 'alszakasz',
333 'Subsubsection One-Two-Four' => 'alalszakasz',
334 'Subsubsection One-Two-One' => 'alalszakasz',
335 'Subsubsection One-Two-Three' => 'alalszakasz',
336 'Subsubsection One-Two-Two' => 'alalszakasz',
337 'T2H_today' => '%s, %d %d',
338 'Table of Contents' => 'Tartalomjegyzék',
339 'Table of contents' => 'Tartalomjegyzék',
340 'The node you are looking for is at {href}.' => 'A keresett csomópont itt található: {href}.',
342 '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}}}.',
343 'This document was generated using @uref{{program_homepage}, @emph{{program}}}.' => 'Ezt a dokumentumot a(z) @uref{{program_homepage}, @emph{{program}}} generálta.',
345 'Untitled Document' => 'Névtelen dokumentum',
347 'Up node' => 'Szülő csomópont',
348 'Up section' => 'Szülő szakasz',
349 'current' => 'aktuális',
350 'on @emph{{date}}' => 'ekkor: @emph{{date}}',
351 'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'szakasz: `@asis{}`{section_name}\'@asis{}\' itt: @cite{{book}}',
352 'section `{section}\' in @cite{{book}}' => 'szakasz: `{section}\' itt: @cite{{book}}',
354 'see @cite{{book}}' => 'ld. @cite{{book}}',
355 'see section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'ld. ezt a szakaszt: `@asis{}`{section_name}\'@asis{}\' itt: @cite{{book}}',
356 'see section `{section}\' in @cite{{book}}' => 'ld. ezt a szakaszt: `{section}\' itt: @cite{{book}}',
357 'see section {reference_name}' => 'ld. ezt a szakaszt: {reference_name}',
358 'see {node_file_href}' => 'ld. {node_file_href}',
359 'see {node_file_href} @cite{{book}}' => 'ld. {node_file_href} @cite{{book}}',
360 'see {node_file_href} section `{section}\' in @cite{{book}}' => 'ld. {node_file_href} ezt a szakaszt: `{section}\' itt: @cite{{book}}',
361 'see {reference_name}' => 'ld. {reference_name}',
362 'see {ref}' => 'ld. {ref}',
363 'see {title_ref}' => 'ld. {title_ref}',
364 '{acronym_like} ({explanation})' => '{acronym_like} ({explanation})',
365 '{name} of {class}' => '{name} típusa: {class}',
366 '{name} on {class}' => '{name} ezen: {class}',
367 '{node_file_href}' => '{node_file_href}',
368 '{node_file_href} @cite{{book}}' => '{node_file_href} @cite{{book}}',
369 '{node_file_href} section `{section}\' in @cite{{book}}' => '{node_file_href} szakasz: `{section}\' itt: @cite{{book}}',
370 '{reference_name}' => '{reference_name}',
372 '{style} {number}' => '{style} {number}',
373 '{style}: {caption_first_line}' => '{style}: {caption_first_line}',
374 '{style}: {shortcaption_first_line}' => '{style}: {shortcaption_first_line}',
375 '{title_ref}' => '{title_ref}'
379 sub ly_get_string () {
380 my $lang = $Texi2HTML::THISDOC{current_lang};
382 if ($lang and $lang ne "en" and $LY_LANGUAGES->{$lang}->{$string}) {
383 return $LY_LANGUAGES->{$lang}->{$string};
390 #############################################################################
391 ### FUNCTIONALITY FOR MAIN WEB PAGES
392 #############################################################################
396 #############################################################################
397 ### SETTINGS FOR TEXI2HTML
398 #############################################################################
400 # Validation fix for texi2html<=1.82
401 $Texi2HTML::Config::DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
403 @Texi2HTML::Config::CSS_REFS = (
404 {FILENAME => "lilypond-mccarty.css", TITLE => "Default style"}
406 @Texi2HTML::Config::ALT_CSS_REFS = (
407 {FILENAME => "lilypond.css", TITLE => "Andrew Hawryluk's design" },
408 {FILENAME => "lilypond-blue.css", TITLE => "Kurt Kroon's blue design" },
412 print STDERR "Initializing settings for web site\n";
413 $Texi2HTML::Config::BODYTEXT = "";
414 @Texi2HTML::Config::CSS_REFS = (
415 {FILENAME => "lilypond-web.css", TITLE => "Patrick McCarty's design"}
417 @Texi2HTML::Config::ALT_CSS_REFS = (
418 {FILENAME => "lilypond-web-alt1.css", TITLE => "Alternate style 1"},
419 {FILENAME => "lilypond-web-alt2.css", TITLE => "Alternate style 2"},
423 # web_settings() if (exists($main::value{'web_manual'}));
425 $Texi2HTML::Config::USE_ACCESSKEY = 1;
426 $Texi2HTML::Config::USE_LINKS = 1;
427 $Texi2HTML::Config::USE_REL_REV = 1;
428 $Texi2HTML::Config::SPLIT_INDEX = 0;
429 $Texi2HTML::Config::SEPARATED_FOOTNOTES = 0; # Print footnotes on same page, not separated
431 if ($Texi2HTML::Config::SPLIT eq 'section' or
432 $Texi2HTML::Config::SPLIT eq 'node') {
433 $Texi2HTML::Config::element_file_name = \&lilypond_element_file_name;
436 $Texi2HTML::Config::element_target_name = \&lilypond_element_target_name;
437 $default_print_element_header = $Texi2HTML::Config::print_element_header;
438 $Texi2HTML::Config::print_element_header = \&lilypond_print_element_header;
439 $Texi2HTML::Config::print_page_foot = \&print_lilypond_page_foot;
440 $Texi2HTML::Config::print_navigation = \&lilypond_print_navigation;
441 $Texi2HTML::Config::external_ref = \&lilypond_external_ref;
442 $default_external_href = $Texi2HTML::Config::external_href;
443 $Texi2HTML::Config::external_href = \&lilypond_external_href;
444 $default_toc_body = $Texi2HTML::Config::toc_body;
445 $Texi2HTML::Config::toc_body = \&lilypond_toc_body;
446 $Texi2HTML::Config::css_lines = \&lilypond_css_lines;
447 $default_unknown = $Texi2HTML::Config::unknown;
448 $Texi2HTML::Config::unknown = \&lilypond_unknown;
449 $default_print_page_head = $Texi2HTML::Config::print_page_head;
450 $Texi2HTML::Config::print_page_head = \&lilypond_print_page_head;
451 # $Texi2HTML::Config::foot_line_and_ref = \&lilypond_foot_line_and_ref;
452 $Texi2HTML::Config::foot_line_and_ref = \&makeinfo_like_foot_line_and_ref;
453 $Texi2HTML::Config::foot_lines = \&makeinfo_like_foot_lines;
454 $Texi2HTML::Config::paragraph = \&makeinfo_like_paragraph;
458 # Examples should be formatted similar to quotes:
459 $Texi2HTML::Config::complex_format_map->{'example'} = {
460 'begin' => q{"<blockquote>"},
461 'end' => q{"</blockquote>\n"},
465 %Texi2HTML::config::misc_pages_targets = (
466 'Overview' => 'Overview',
467 'Contents' => 'Contents',
472 my @section_to_filename;
477 #############################################################################
479 #############################################################################
482 $Data::Dumper::Maxdepth = 2;
484 sub print_element_info($)
487 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
488 print "Element: $element\n";
489 print Dumper($element);
496 #############################################################################
498 #############################################################################
500 # Convert a given node name to its proper file name (normalization as explained
501 # in the texinfo manual:
502 # http://www.gnu.org/software/texinfo/manual/texinfo/html_node/HTML-Xref-Node-Name-Expansion.html
503 sub texinfo_file_name($)
507 # File name normalization by texinfo:
508 # 1/2: letters and numbers are left unchanged
509 # 3/4: multiple, leading and trailing whitespace is removed
510 $text = main::normalise_space($text);
511 # 5/6: all remaining spaces are converted to '-', all other 7- or 8-bit
512 # chars are replaced by _xxxx (xxxx=ascii character code)
513 while ($text ne '') {
514 if ($text =~ s/^([A-Za-z0-9]+)//o) { # number or letter stay unchanged
516 } elsif ($text =~ s/^ //o) { # space -> '-'
518 } elsif ($text =~ s/^(.)//o) { # Otherwise use _xxxx (ascii char code)
520 if ( $ccode <= 0xFFFF ) {
521 $result .= sprintf("_%04x", $ccode);
523 $result .= sprintf("__%06x", $ccode);
527 # 7: if name does not begin with a letter, prepend 't_g' (so it starts with a letter)
528 if ($result !~ /^[a-zA-Z]/) {
529 $result = 't_g' . $result;
535 # Load a file containing a nodename<=>filename map (tab-sepatared, i.e.
536 # NODENAME\tFILENAME\tANCHOR
537 # Returns a ref to a hash "Node title" => ["FilenameWithoutExt", "Anchor"]
538 sub load_map_file ($)
543 # For some unknown reason, Perl on my system (5.10.0 on Fedora 12)
544 # refuses to open map files of translated documents with
545 # '<:encoding(utf8)', but decoding from UTF-8 line by line works. -jm
546 if (open(XREFFILE,'<', $mapfile)) {
548 # print STDERR "*** PRINTING MAP FILE LINES ***\n";
549 while ( $line = decode ('UTF-8', <XREFFILE>) ) {
550 # parse the tab-separated entries and insert them into the map:
552 my @entries = split(/\t/, $line);
553 if (scalar (@entries) == 3) {
554 $node_map->{$entries[0]} = [$entries[1], $entries[2]];
556 # print STDERR @entries;
559 print STDERR "Invalid entry in the node file $mapfile: $line\n";
564 print STDERR "WARNING: Unable to load the map file $mapfile\n";
570 # Split the given path into dir and basename (with .texi removed). Used mainly
571 # to get the path/basename of the original texi input file
572 sub split_texi_filename ($)
575 my ($docu_dir, $docu_name);
576 if ($docu =~ /(.*\/)/) {
577 chop($docu_dir = $1);
579 $docu_name =~ s/.*\///;
584 $docu_name =~ s/\.te?x(i|info)?$//;
585 return ($docu_dir, $docu_name);
592 #############################################################################
594 #############################################################################
596 # Include our standard CSS file, not hard-coded CSS code directly in the HTML!
597 # For IE, conditionally include the lilypond-ie-fixes.css style sheet
598 sub lilypond_css_lines ($$)
600 my $import_lines = shift;
601 my $rule_lines = shift;
602 return if (defined($Texi2HTML::THISDOC{'CSS_LINES'}));
603 if (@$rule_lines or @$import_lines)
605 $Texi2HTML::THISDOC{'CSS_LINES'} = "<style type=\"text/css\">\n<!--\n";
606 $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$import_lines) . "\n" if (@$import_lines);
607 $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$rule_lines) . "\n" if (@$rule_lines);
608 $Texi2HTML::THISDOC{'CSS_LINES'} .= "-->\n</style>\n";
610 foreach my $ref (@CSS_REFS)
612 $Texi2HTML::THISDOC{'CSS_LINES'} .= "<link rel=\"stylesheet\" type=\"text/css\" title=\"$ref->{TITLE}\" href=\"$ref->{FILENAME}\">\n";
614 foreach my $ref (@Texi2HTML::Config::ALT_CSS_REFS)
616 $Texi2HTML::THISDOC{'CSS_LINES'} .= "<link rel=\"alternate stylesheet\" type=\"text/css\" href=\"$ref->{FILENAME}\" title=\"$ref->{TITLE}\">\n";
618 # FIXME: the website doesn't use ie7-specific fixes; do the
619 # docs still need this? -gp
620 $Texi2HTML::THISDOC{'CSS_LINES'} .= "<!--[if lte IE 7]>\n<link href=\"lilypond-ie-fixes.css\" rel=\"stylesheet\" type=\"text/css\">\n<![endif]-->\n";
627 #############################################################################
628 ### SPLITTING BASED ON NUMBERED SECTIONS
629 #############################################################################
633 my $node_to_filename_map = ();
636 # This function makes sure that files are only generated for numbered sections,
637 # but not for unnumbered ones. It is called after texi2html has done its own
638 # splitting and simply returns the filename for the node given as first argument
639 # Nodes with the same filename will be printed out to the same filename, so
640 # this really all we need. Also, make sure that the file names for sections
641 # are derived from the section title. We also might want to name the anchors
642 # according to node titles, which works by simply overriding the id element of
644 # If an external nodename<=>filename/anchor map file is found (loaded in
645 # the command handler, use the externally created values, otherwise use the
647 sub lilypond_element_file_name($$$)
651 my $docu_name = shift;
652 my $docu_ext = $Texi2HTML::Config::EXTENSION;
654 my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
655 # the snippets page does not use nodes for the snippets, so in this case
656 # we'll have to use the section name!
657 if ($node_name eq '') {
658 $node_name = main::remove_texi($element->{'texi'});
661 # If we have an entry in the section<=>filename map, use that one, otherwise
662 # generate the filename/anchor here. In the latter case, external manuals
663 # will not be able to retrieve the file name for xrefs!!! Still, I already
664 # had that code, so I'll leave it in in case something goes wrong with the
665 # extract_texi_filenames.py script in the lilypond build process!
666 if (exists ($node_to_filename_map->{$node_name})) {
667 (my $filename, my $anchor) = @{$node_to_filename_map->{$node_name}};
668 $filename .= ".$docu_ext" if (defined($docu_ext));
669 $filename = lc($filename);
671 # unnumbered sections (except those at top-level!) always go to the same
672 # file as the previous numbered section
673 if (not $docu_name == "web" and not ($element->{number})
674 and not ($lastfilename eq '') and ($element->{level} > 1)) {
675 $filename = $lastfilename;
677 if (($filename eq $lastfilename)) {
678 $$element{doc_nr} = $docnr;
681 $$element{doc_nr} = $docnr;
682 $lastfilename = $filename;
684 print STDERR "Output file name: $filename\n";
687 } elsif ($type eq "top" or $type eq "toc" or $type eq "doc" or $type eq "stoc" or $type eq "foot" or $type eq "about") {
690 print STDERR "WARNING: Node '$node_name' was NOT found in the map\n"
691 unless ($node_name eq '') or ($element->{'tag'} eq 'unnumberedsec')
692 or ($node_name =~ /NOT REALLY USED/);
694 # Numbered sections will get a filename Node_title, unnumbered sections will use
695 # the file name of the previous numbered section:
696 if (($element->{number}) or ($lastfilename eq '') or ($element->{level} == 1)) {
697 # normalize to the same file name as texinfo
698 if ($element->{translationof}) {
699 $node_name = main::remove_texi($element->{translationof});
701 my $filename = texinfo_file_name($node_name);
702 $filename .= ".$docu_ext" if (defined($docu_ext));
703 $filename = lc($filename);
705 $$element{doc_nr} = $docnr;
706 $lastfilename = $filename;
707 print STDERR "File name: $filename\n";
710 $$element{doc_nr} = $docnr;
711 $filename = lc ($filename);
712 print STDERR "File name: $filename\n";
720 sub lilypond_element_target_name($$$)
725 # Target is based on node name (or sec name for secs without node attached)
726 my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
727 if ($node_name eq '') {
728 $node_name = main::remove_texi($element->{'texi'});
731 # If we have an entry in the section<=>filename map, use that one, otherwise
732 # generate the anchor here.
733 if (exists ($node_to_filename_map->{$node_name})) {
734 (my $filename, $target) = @{$node_to_filename_map->{$node_name}};
736 my $anchor = $node_name;
737 if ($element->{translationof}) {
738 $anchor = main::remove_texi($element->{translationof});
740 # normalize to the same file name as texinfo
741 $target = texinfo_file_name($anchor);
743 # TODO: Once texi2html correctly prints out the target and not the id for
744 # the sections, change this back to ($id, $target)
745 $target = lc($target);
746 return ($target, $target);
750 ## Load the map file for the corrently processed texi file. We do this
751 # using a command init handler, since texi2html does not have any
752 # other hooks that are called after THISDOC is filled but before phase 2
753 # of the texi2html conversion.
754 sub lilypond_init_map ()
756 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
757 my $map_filename = main::locate_include_file ("${docu_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
758 || main::locate_include_file ("${docu_name}.xref-map");
759 print STDERR "Map filename is: $map_filename\nDocu name is $docu_name\n";
760 if ($docu_name eq 'web') {
764 $node_to_filename_map = load_map_file ($map_filename);
766 push @Texi2HTML::Config::command_handler_init, \&lilypond_init_map;
770 #############################################################################
771 ### CLEANER LINK TITLE FOR EXTERNAL REFS
772 #############################################################################
774 # The default formatting of external refs returns e.g.
775 # "(lilypond-internals)Timing_translator", so we remove all (...) from the
776 # file_and_node argument. Also, we want only a very simple format, so we don't
777 # even call the default handler!
778 sub lilypond_external_ref($$$$$$)
783 my $file_node = shift;
784 my $href = lc(shift);
785 my $cross_ref = shift;
787 my $displaytext = '';
789 # 1) if we have a cross ref name, that's the text to be displayed:
790 # 2) For the top node, use the (printable) name of the manual, unless we
791 # have an explicit cross ref name
792 # 3) In all other cases use the section name
793 if ($cross_ref ne '') {
794 $displaytext = $cross_ref;
795 } elsif (($section eq '') or ($section eq 'Top')) {
796 $displaytext = $book;
798 $displaytext = $section;
801 $displaytext = &$anchor('', $href, $displaytext) if ($displaytext ne '');
802 return &$I('%{node_file_href}', { 'node_file_href' => $displaytext });
809 #############################################################################
810 ### HANDLING TRANSLATED SECTIONS: handle @translationof, secname<->filename
811 ### map stored on disk, xrefs in other manuals load that map
812 #############################################################################
815 # Try to make use of @translationof to generate files according to the original
816 # English section title...
817 sub lilypond_unknown($$$$$)
825 # the @translationof macro provides the original English section title,
826 # which should be used for file/anchor naming, while the title will be
827 # translated to each language
828 # It is already used by extract_texi_filenames.py, so this should not be
829 # necessary here at all. Still, I'll leave the code in just in case the
830 # python script messed up ;-)
831 if ($pass == 1 and $macro eq "translationof") {
832 if (ref($state->{'element'}) eq 'HASH') {
833 $state->{'element'}->{'translationof'} = main::normalise_space($line);
835 return ('', 1, undef, undef);
837 return &$default_unknown($macro, $line, $pass, $stack, $state);
844 my %translated_books = ();
845 # Construct a href to an external source of information.
846 # node is the node with texinfo @-commands
847 # node_id is the node transliterated and transformed as explained in the
849 # node_xhtml_id is the node transformed such that it is unique and can
850 # be used to make an html cross ref as explained in the texinfo manual
851 # file is the file in '(file)node'
852 sub lilypond_external_href($$$)
856 my $node_hxmlt_id = shift;
859 # 1) Keep a hash of book->section_map
860 # 2) if not file in keys hash => try to load the map (assign empty map if
861 # non-existent => will load only once!)
862 # 3) if node in the section=>(file, anchor) map, replace node_id and
863 # node_xhtml_id by the map's values
864 # 4) call the default_external_href with these values (or the old ones if not found)
866 if (($node_id ne '') and defined($file) and ($node_id ne 'Top')) {
867 my $map_name = $file;
868 $map_name =~ s/-big-page//;
870 # Load the map if we haven't done so already
871 if (!exists($translated_books{$map_name})) {
872 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
873 my $map_filename = main::locate_include_file ("${map_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
874 || main::locate_include_file ("${map_name}.xref-map");
875 $translated_books{$map_name} = load_map_file ($map_filename);
878 # look up translation. use these values instead of the old filename/anchor
879 my $section_name_map = $translated_books{$map_name};
880 my $node_text = main::remove_texi($node);
881 if (defined($section_name_map->{$node_text})) {
882 ($node_id, $node_hxmlt_id) = @{$section_name_map->{$node_text}};
884 print STDERR "WARNING: Unable to find node '$node_text' in book $map_name.\n";
889 return &$default_external_href($node, $node_id, $node_hxmlt_id, lc($file));
891 return &$default_external_href($node, $node_id, $node_hxmlt_id);
899 #############################################################################
900 ### CUSTOM TOC FOR EACH PAGE (in a frame on the left)
901 #############################################################################
903 my $page_toc_depth = 2;
904 my @default_toc = [];
906 # Initialize the toc_depth to 1 if the command-line option -D=short_toc is given
907 sub lilypond_init_toc_depth ()
909 if (exists($main::value{'short_toc'}) and not exists($main::value{'bigpage'})
910 and not $web_manual) {
914 # Set the TOC-depth (depending on a texinfo variable short_toc) in a
915 # command-handler, so we have them available when creating the pages
916 push @Texi2HTML::Config::command_handler_process, \&lilypond_init_toc_depth;
920 # recursively generate the TOC entries for the element and its children (which
921 # are only shown up to maxlevel. All ancestors of the current element are also
922 # shown with their immediate children, irrespective of their level.
923 # Unnumbered entries are only printed out if they are at top-level or 2nd level
924 # or their parent element is an ancestor of the currently viewed node.
925 # The conditions to call this method to print the entry for a child node is:
926 # -) the parent is an ancestor of the current page node
927 # -) the parent is a numbered element at top-level toplevel (i.e. show numbered
928 # and unnumbered 2nd-level children of numbered nodes)
929 # -) the child element is a numbered node below level maxlevel
930 sub generate_ly_toc_entries($$$$)
933 my $element_path = shift;
934 my $maxlevel = shift;
938 my $child_count = shift;
939 # Skip undefined sections, plus all sections generated by index splitting
940 return() if (not defined($element) or exists($element->{'index_page'}));
942 my $level = $element->{'toc_level'};
943 my $is_parent_of_current = $element->{'id'} && $element_path->{$element->{'id'}};
944 my $ind = ' ' x $level;
947 $this_css_class = " class=\"";
949 $this_css_class = "";
951 $this_css_class .= $is_parent_of_current ? " toc_current" : "";
953 # color indices for the second navigation bar on the website
955 'introduction' => [2, 2, 2, 2, 3, 3, 4, 4],
956 'download' => [2, 2, 2, 3, 3, 4],
957 'manuals' => [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4],
958 'community' => [1, 1, 1, 2, 2, 2, 3, 3],
960 my $addColor = " colorDefault";
961 while (($top_section, $color_indices) = each %color_maps) {
962 if (index ($element->{'sectionup'}->{'file'}, $top_section) >= 0) {
963 $addColor = " color" . $color_indices->[$child_count];
966 $this_css_class .= $addColor . "\"";
968 my $entry = "$ind<li$this_css_class>" . &$anchor ($element->{'tocid'}, "$element->{'file'}#$element->{'target'}",$element->{'text'});
970 push (@result, $entry);
971 my $children = $element->{'section_childs'};
972 if (defined($children) and (ref($children) eq "ARRAY")) {
973 my $force_children = $is_parent_of_current or ($level == 1 and $element->{'number'});
974 my @child_result = ();
975 my $sub_child_count = 0;
976 foreach my $c (@$children) {
977 my $is_numbered_child = defined ($c->{'number'});
978 my $below_maxlevel = $c->{'toc_level'} le $maxlevel;
979 if ($force_children or ($is_numbered_child and $below_maxlevel)) {
980 my @child_res = generate_ly_toc_entries($c, $element_path, $maxlevel, $sub_child_count);
981 push (@child_result, @child_res);
982 $sub_child_count += 1;
985 # if no child nodes were generated, e.g. for the index, where expanded pages
986 # are ignored, don't generate a list at all...
988 push (@result, "\n$ind<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
990 push (@result, "$ind<li$this_css_class>" . &$anchor ($element->{'tocid'}, "$element->{'file'}#$element->{'target'}", $element->{'text'}));
992 push (@result, @child_result);
993 push (@result, "$ind</ul>\n");
996 push (@result, "$ind</li>\n");
1001 # Print a customized TOC, containing only the first two levels plus the whole
1002 # path to the current page
1003 sub lilypond_generate_page_toc_body($)
1005 my $element = shift;
1006 my $current_element = $element;
1008 $parentelements{$element->{'id'}} = 1;
1009 # Find the path to the current element
1010 while ( defined($current_element->{'sectionup'}) and
1011 ($current_element->{'sectionup'} ne $current_element) )
1013 $parentelements{$current_element->{'sectionup'}->{'id'}} = 1
1014 if ($current_element->{'sectionup'}->{'id'} ne '');
1015 $current_element = $current_element->{'sectionup'};
1017 if (exists($main::value{'shallow_toc'})) {
1022 return () if not defined($current_element);
1023 # Create the toc entries recursively
1024 my @toc_entries = "";
1026 @toc_entries = "<ul$NO_BULLET_LIST_ATTRIBUTE>\n";
1027 # FIXME: add link to main page, really hackily.
1028 if ($element->{'sectionup'}) {
1029 # it's not the top element
1030 push (@toc_entries, "<li><a href=\"index.html\">Main</a></li>\n");
1032 push (@toc_entries, "<li class=\"toc_current\"><a href=\"index.html\">Main</a></li>\n");
1035 push (@toc_entries, "<div class=\"contents\">\n");
1036 push (@toc_entries, "<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
1038 my $children = $current_element->{'section_childs'};
1039 foreach ( @$children ) {
1040 push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth, 0));
1044 my $name = "search-box";
1045 $lang = $Texi2HTML::THISDOC{current_lang};
1046 open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$lang/$name.ihtml" or
1047 open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$name.ihtml" or
1048 die "no such file: $name.ihtml: $!";
1049 my $search_string = <FILE>;
1050 $search_string = "<li>\n" . $search_string . "</li>\n";
1051 push (@toc_entries, $search_string);
1054 push (@toc_entries, "</ul>\n");
1056 push (@toc_entries, "\n");
1058 push (@toc_entries, "</div>\n");
1060 return @toc_entries;
1063 sub lilypond_print_toc_div ($$)
1067 my @lines = @$tocref;
1068 # use default TOC if no custom lines have been generated
1069 @lines = @default_toc if (not @lines);
1072 print $fh "\n\n<div id=\"tocframe\">\n";
1074 # Remove the leading "GNU LilyPond --- " from the manual title
1075 my $topname = $Texi2HTML::NAME{'Top'};
1076 $topname =~ s/^GNU LilyPond(:| &[mn]dash;) //;
1078 # construct the top-level Docs index (relative path and including language!)
1079 my $lang = $Texi2HTML::THISDOC{current_lang};
1080 if ($lang and $lang ne "en") {
1086 $reldir = "../" if ($Texi2HTML::Config::SPLIT eq 'section');
1087 my $uplink = $reldir."web/manuals.${lang}html";
1089 if (not $web_manual) {
1090 print $fh "<p class=\"toc_uplink\"><a href=\"$uplink\"
1091 title=\"Documentation Index\"><< " .
1092 &ly_get_string ('Back to Documentation Index') .
1095 print $fh '<h4 class="toc_header"> ' . &$anchor('',
1096 $Texi2HTML::HREF{'Top'},
1098 'title="Start of the manual"'
1102 foreach my $line (@lines) {
1105 print $fh "</div>\n\n";
1109 # Create the custom TOC for this page (partially folded, current page is
1110 # highlighted) and store it in a global variable. The TOC is written out after
1111 # the html contents (but positioned correctly using CSS), so that browsers with
1112 # css turned off still show the contents first.
1113 our @this_page_toc = ();
1114 sub lilypond_print_element_header
1116 my $first_in_page = shift;
1117 my $previous_is_top = shift;
1118 if ($first_in_page and not @this_page_toc) {
1119 if (defined($Texi2HTML::THIS_ELEMENT)) {
1120 # Create the TOC for this page
1121 @this_page_toc = lilypond_generate_page_toc_body($Texi2HTML::THIS_ELEMENT);
1124 return &$default_print_element_header( $first_in_page, $previous_is_top);
1127 # Generate the HTML output for the TOC
1128 sub lilypond_toc_body($)
1130 my $elements_list = shift;
1131 # Generate a default TOC for pages without THIS_ELEMENT
1132 @default_toc = lilypond_generate_page_toc_body(@$elements_list[0]);
1133 return &$default_toc_body($elements_list);
1136 # Print out the TOC in a <div> at the beginning of the page
1137 sub lilypond_print_page_head($)
1140 &$default_print_page_head($fh);
1141 print $fh "<div id=\"main\">\n";
1144 # Print out the TOC in a <div> at the end of th page, which will be formatted as a
1145 # sidebar mimicking a TOC frame
1146 sub print_lilypond_page_foot($)
1149 my $program_string = &$program_string();
1150 # print $fh "<p><font size='-1'>$program_string</font><br>$PRE_BODY_CLOSE</p>\n";
1151 print $fh "<!-- FOOTER -->\n\n";
1152 print $fh "<!-- end div#main here -->\n</div>\n\n";
1154 # FIXME: This div and p#languages need to be in div#footer.
1155 # Should we move this div to postprocess_html.py ?
1156 print $fh "<div id=\"verifier_texinfo\">\n";
1157 print $fh "<h3>Validation</h3>\n";
1158 # FIXME: inlined text substitution, move to ly_get_string as soon as another case is needed
1159 my $webdev_link = "<a href=\"http://www.webdev.nl/\">webdev.nl</a>";
1160 my $lily_site = "<code>lilypond.org</code>";
1161 my $hosting_thanks = &ly_get_string ('<p>Thanks to ${webdev_link} for hosting ${lily_site}.');
1162 # this does the variable substitution ("quoting" in Perlish) after the localization
1163 $hosting_thanks =~ s/(\$\{\w+\})/$1/eeg;
1164 print $fh $hosting_thanks . "\n";
1165 print $fh "<a href=\"http://validator.w3.org/check?uri=referer\">\n";
1166 print $fh "<img src=\"http://www.w3.org/Icons/valid-html401\"\n";
1167 print $fh " alt=\"Valid HTML 4.01 Transitional\"\n";
1168 print $fh " height=\"31\" width=\"88\"></a></p>\n";
1172 # Print the TOC frame and reset the TOC:
1173 lilypond_print_toc_div ($fh, \@this_page_toc);
1174 @this_page_toc = ();
1177 print $fh "</body>\n</html>\n";
1184 #############################################################################
1185 ### NICER / MORE FLEXIBLE NAVIGATION PANELS
1186 #############################################################################
1188 sub get_navigation_text
1191 my $text = $NAVIGATION_TEXT{$button};
1192 if ( ($button eq 'Back') or ($button eq 'FastBack') ) {
1193 $text = $text . $Texi2HTML::NODE{$button} . " ";
1194 } elsif ( ($button eq 'Forward') or ($button eq 'FastForward') ) {
1195 $text = " " . $Texi2HTML::NODE{$button} . $text;
1196 } elsif ( $button eq 'Up' ) {
1197 $text = " ".$text.": " . $Texi2HTML::NODE{$button} . " ";
1203 # Don't automatically create left-aligned table cells for every link, but
1204 # instead create a <td> only on an appropriate '(left|right|center)-aligned-cell-n'
1205 # button text. It's alignment as well as the colspan will be taken from the
1206 # name of the button. Also, add 'newline' button text to create a new table
1207 # row. The texts of the buttons are generated by get_navigation_text and
1208 # will contain the name of the next/previous section/chapter.
1209 sub lilypond_print_navigation
1211 my $buttons = shift;
1212 my $vertical = shift;
1214 my $result = "<table class=\"nav_table\">\n";
1216 $result .= "<tr>" unless $vertical;
1217 my $beginofline = 1;
1218 foreach my $button (@$buttons)
1220 $result .= qq{<tr valign="top" align="left">\n} if $vertical;
1221 # Allow (left|right|center)-aligned-cell and newline as buttons!
1222 if ( $button =~ /^(.*)-aligned-cell-(.*)$/ )
1224 $result .= qq{</td>} unless $beginofline;
1225 $result .= qq{<td valign="middle" align="$1" colspan="$2">};
1228 elsif ( $button eq 'newline' )
1230 $result .= qq{</td>} unless $beginofline;
1231 $result .= qq{</tr>};
1232 $result .= qq{<tr>};
1236 elsif (ref($button) eq 'CODE')
1238 $result .= &$button($vertical);
1240 elsif (ref($button) eq 'SCALAR')
1242 $result .= "$$button" if defined($$button);
1244 elsif (ref($button) eq 'ARRAY')
1246 my $text = $button->[1];
1247 my $button_href = $button->[0];
1248 # verify that $button_href is simple text and text is a reference
1249 if (defined($button_href) and !ref($button_href)
1250 and defined($text) and (ref($text) eq 'SCALAR') and defined($$text))
1252 if ($Texi2HTML::HREF{$button_href})
1254 my $anchor_attributes = '';
1255 if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button_href})) and ($BUTTONS_ACCESSKEY{$button_href} ne ''))
1257 $anchor_attributes = "accesskey=\"$BUTTONS_ACCESSKEY{$button_href}\"";
1259 if ($USE_REL_REV and (defined($BUTTONS_REL{$button_href})) and ($BUTTONS_REL{$button_href} ne ''))
1261 $anchor_attributes .= " rel=\"$BUTTONS_REL{$button_href}\"";
1265 $Texi2HTML::HREF{$button_href},
1266 get_navigation_text($$text),
1272 $result .= get_navigation_text($$text);
1276 elsif ($button eq ' ')
1277 { # handle space button
1279 ($ICONS && $ACTIVE_ICONS{' '}) ?
1280 &$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{' '}) :
1281 $NAVIGATION_TEXT{' '};
1284 elsif ($Texi2HTML::HREF{$button})
1285 { # button is active
1286 my $btitle = $BUTTONS_GOTO{$button} ?
1287 'title="' . $BUTTONS_GOTO{$button} . '"' : '';
1288 if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button})) and ($BUTTONS_ACCESSKEY{$button} ne ''))
1290 $btitle .= " accesskey=\"$BUTTONS_ACCESSKEY{$button}\"";
1292 if ($USE_REL_REV and (defined($BUTTONS_REL{$button})) and ($BUTTONS_REL{$button} ne ''))
1294 $btitle .= " rel=\"$BUTTONS_REL{$button}\"";
1296 if ($ICONS && $ACTIVE_ICONS{$button})
1300 $Texi2HTML::HREF{$button},
1301 &$button_icon_img($BUTTONS_NAME{$button},
1302 $ACTIVE_ICONS{$button},
1303 $Texi2HTML::SIMPLE_TEXT{$button}),
1312 $Texi2HTML::HREF{$button},
1313 get_navigation_text($button),
1320 { # button is passive
1322 $ICONS && $PASSIVE_ICONS{$button} ?
1323 &$button_icon_img($BUTTONS_NAME{$button},
1324 $PASSIVE_ICONS{$button},
1325 $Texi2HTML::SIMPLE_TEXT{$button}) :
1327 "[" . get_navigation_text($button) . "]";
1329 $result .= "</td>\n" if $vertical;
1330 $result .= "</tr>\n" if $vertical;
1332 $result .= "</td>" unless $beginofline;
1333 $result .= "</tr>" unless $vertical;
1334 $result .= "</table>\n";
1343 @Texi2HTML::Config::SECTION_BUTTONS =
1344 ('left-aligned-cell-1', 'FastBack',
1345 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1346 'right-aligned-cell-1', 'FastForward',
1348 'left-aligned-cell-2', 'Back',
1349 'center-aligned-cell-1', 'Up',
1350 'right-aligned-cell-2', 'Forward'
1353 # buttons for misc stuff
1354 @Texi2HTML::Config::MISC_BUTTONS = ('center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About');
1356 # buttons for chapter file footers
1357 # (and headers but only if SECTION_NAVIGATION is false)
1358 @Texi2HTML::Config::CHAPTER_BUTTONS =
1359 ('left-aligned-cell-1', 'FastBack',
1360 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1361 'right-aligned-cell-1', 'FastForward',
1364 # buttons for section file footers
1365 @Texi2HTML::Config::SECTION_FOOTER_BUTTONS =
1366 ('left-aligned-cell-1', 'FastBack',
1367 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1368 'right-aligned-cell-1', 'FastForward',
1370 'left-aligned-cell-2', 'Back',
1371 'center-aligned-cell-1', 'Up',
1372 'right-aligned-cell-2', 'Forward'
1375 @Texi2HTML::Config::NODE_FOOTER_BUTTONS =
1376 ('left-aligned-cell-1', 'FastBack',
1377 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1378 'right-aligned-cell-1', 'FastForward',
1380 'left-aligned-cell-2', 'Back',
1381 'center-aligned-cell-1', 'Up',
1382 'right-aligned-cell-2', 'Forward'
1389 #############################################################################
1390 ### FOOTNOTE FORMATTING
1391 #############################################################################
1393 # Format footnotes in a nicer way: Instead of printing the number in a separate
1394 # (nr) heading line, use the standard way of prepending <sup>nr</sup> immediately
1395 # before the fn text.
1398 # The following code is copied from texi2html's examples/makeinfo.init and
1399 # should be updated when texi2html makes some changes there!
1401 my $makekinfo_like_footnote_absolute_number = 0;
1403 sub makeinfo_like_foot_line_and_ref($$$$$$$$)
1405 my $foot_num = shift;
1406 my $relative_num = shift;
1409 my $from_file = shift;
1410 my $footnote_file = shift;
1414 $makekinfo_like_footnote_absolute_number++;
1416 # this is a bit obscure, this allows to add an anchor only if formatted
1417 # as part of the document.
1418 $docid = '' if ($state->{'outside_document'} or $state->{'multiple_pass'});
1420 if ($from_file eq $footnote_file)
1422 $from_file = $footnote_file = '';
1425 my $foot_anchor = "<sup>" . &$anchor($docid, "$footnote_file#$footid", $relative_num) . "</sup>";
1426 $foot_anchor = &$anchor($docid, "$footnote_file#$footid", "($relative_num)") if ($state->{'preformatted'});
1428 # unshift @$lines, "<li>";
1429 # push @$lines, "</li>\n";
1430 return ($lines, $foot_anchor);
1433 sub makeinfo_like_foot_lines($)
1436 unshift @$lines, "<hr>\n<h4>$Texi2HTML::I18n::WORDS->{'Footnotes_Title'}</h4>\n";
1437 #<ol type=\"1\">\n";
1438 # push @$lines, "</ol>";
1442 my %makekinfo_like_paragraph_in_footnote_nr;
1444 sub makeinfo_like_paragraph ($$$$$$$$$$$$$)
1449 my $paragraph_command = shift;
1450 my $paragraph_command_formatted = shift;
1451 my $paragraph_number = shift;
1453 my $item_nr = shift;
1454 my $enumerate_style = shift;
1456 my $command_stack_at_end = shift;
1457 my $command_stack_at_begin = shift;
1459 #print STDERR "format: $format\n" if (defined($format));
1460 #print STDERR "paragraph @$command_stack_at_end; @$command_stack_at_begin\n";
1461 $paragraph_command_formatted = '' if (!defined($paragraph_command_formatted) or
1462 exists($special_list_commands{$format}->{$paragraph_command}));
1463 return '' if ($text =~ /^\s*$/);
1464 foreach my $style(t2h_collect_styles($command_stack_at_begin))
1466 $text = t2h_begin_style($style, $text);
1468 foreach my $style(t2h_collect_styles($command_stack_at_end))
1470 $text = t2h_end_style($style, $text);
1472 if (defined($paragraph_number) and defined($$paragraph_number))
1474 $$paragraph_number++;
1475 return $text if (($format eq 'itemize' or $format eq 'enumerate') and
1476 ($$paragraph_number == 1));
1481 $open .= " align=\"$paragraph_style{$align}\"";
1483 my $footnote_text = '';
1484 if (defined($command_stack_at_begin->[0]) and $command_stack_at_begin->[0] eq 'footnote')
1486 my $state = $Texi2HTML::THISDOC{'state'};
1487 $makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number}++;
1488 if ($makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number} <= 1)
1490 $open.=' class="footnote"';
1491 my $document_file = $state->{'footnote_document_file'};
1492 if ($document_file eq $state->{'footnote_footnote_file'})
1494 $document_file = '';
1496 my $docid = $state->{'footnote_place_id'};
1497 my $doc_state = $state->{'footnote_document_state'};
1498 $docid = '' if ($doc_state->{'outside_document'} or $doc_state->{'multiple_pass'});
1499 my $foot_label = &$anchor($state->{'footnote_footnote_id'},
1500 $document_file . "#$state->{'footnote_place_id'}",
1501 "$state->{'footnote_number_in_page'}");
1502 $footnote_text = "<small>[${foot_label}]</small> ";
1505 return $open.'>'.$footnote_text.$text.'</p>';
1509 #############################################################################
1511 #############################################################################
1513 # For split pages, use index.html as start page!
1514 if ($Texi2HTML::Config::SPLIT eq 'section' or
1515 $Texi2HTML::Config::SPLIT eq 'node') {
1516 $Texi2HTML::Config::TOP_FILE = 'index.html';