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',
80 $LY_LANGUAGES->{'es'} = {
81 'Back to Documentation Index' => 'Volver al índice de la documentación',
83 $LY_LANGUAGES->{'de'} = {
84 'Back to Documentation Index' => 'Zur Dokumentationsübersicht',
86 $LY_LANGUAGES->{'ja'} = {
87 'Back to Documentation Index' => 'ドキュメント インデックスに戻る',
90 $LY_LANGUAGES->{'hu'} = {
91 'Back to Documentation Index' => 'Vissza a dokumentációk jegyzékéhez',
94 $LY_LANGUAGES->{'it'} = {
95 'Back to Documentation Index' => 'Torna all\'indice della documentazione',
98 # FIXME: request the translations below then send them to texi2html/texinfo devs
99 $LANGUAGES->{'it'} = {
100 ' The buttons in the navigation panels have the following meaning:' => ' I bottoni nei pannelli di navigazione hanno il seguente significato:',
101 ' 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:',
103 '(outside of any element)' => '(fuori da qualsiasi elemento)',
104 '(outside of any node)' => '(fuori da qualsiasi nodo)',
105 '@b{{quotation_arg}:} ' => '@b{{quotation_arg}:} ',
106 '@cite{{book}}' => '@cite{{book}}',
107 '@{No value for `{value}\'@}' => '@{Nessun valore per `{value}\'@}',
108 'About' => 'Informazioni',
109 'About (help)' => 'Informazioni (aiuto)',
110 'About This Document' => 'Informazioni su questo documento',
112 'August' => 'Agosto',
113 'Back' => 'Indietro',
114 'Back section in previous file' => '',
115 'Beginning of this chapter or previous chapter' => 'Inizio di questo capitolo o capitolo precedente',
116 'Button' => 'Bottone',
117 'Contents' => 'Contenuti',
118 'Cover (top) of document' => 'Copertina (inizio) del documento',
119 'Current' => 'Attuale',
120 'Current Position' => 'Posizione Attuale',
121 'Current section' => 'Sezione attuale',
122 'December' => 'Dicembre',
123 'FastBack' => 'Indietro veloce',
124 'FastForward' => 'Avanti veloce',
125 'February' => 'Febbraio',
127 'First section in reading order' => 'Prima sezione in ordine di lettura',
128 'Following' => 'Seguente',
129 'Following node' => 'Nodo seguente',
130 'Footnotes' => 'Note a piè di pagina',
131 'Forward' => 'Avanti',
132 'Forward section in next file' => 'Sezione successiva nel prossimo file',
133 'From 1.2.3 go to' => 'Da 1.2.3 vai a',
136 'Index Entry' => 'Voce dell\'indice',
137 'January' => 'Gennaio',
139 'Jump to' => 'Salta a',
142 'Last section in reading order' => 'Ultima sezione in ordine di lettura',
147 'Next' => 'Successivo',
148 'Next chapter' => 'Capitolo successivo',
149 'Next file' => 'File successivo',
150 'Next node' => 'Nodo successivo',
151 'Next section in reading order' => 'Sezione successiva in ordine di lettura',
152 'Next section on same level' => 'Sezione successiva sullo stesso livello',
153 'NextFile' => 'File successivo',
154 'Node following in node reading order' => 'Nodo seguente in ordine di lettura',
155 'Node up' => 'Nodo superiore',
156 'NodeNext' => 'Nodo successivo',
157 'NodePrev' => 'Nodo precedente',
158 'NodeUp' => 'Nodo superiore',
159 'November' => 'Novembre',
160 'October' => 'Ottobre',
161 'Overview' => 'Panoramica',
163 'PrevFile' => 'File precedente',
164 'Previous' => 'Precedente',
165 'Previous file' => 'File precedente',
166 'Previous node' => 'Nodo precedente',
167 'Previous section in reading order' => 'Sezione precedente in ordine di lettura',
168 'Previous section on same level' => 'Sezione precedente sullo stesso livello',
169 'Section' => 'Sezione',
170 'Section One' => 'Sezione uno',
172 'See @cite{{book}}' => 'Vedi @cite{{book}}',
173 'See section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'Vedi la sezione `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}',
174 'See section `{section}\' in @cite{{book}}' => 'Vedi la sezione `{section}\' in @cite{{book}}',
175 'See section {reference_name}' => 'Vedi la sezione {reference_name}',
176 'See {node_file_href}' => 'Vedi {node_file_href}',
177 'See {node_file_href} @cite{{book}}' => 'Vedi {node_file_href} @cite{{book}}',
178 'See {node_file_href} section `{section}\' in @cite{{book}}' => 'Vedi {node_file_href} nella sezione `{section}\' in @cite{{book}}',
179 'See {reference_name}' => 'Vedi {reference_name}',
180 'See {ref}' => 'Vedi {ref}',
181 'See {title_ref}' => 'Vedi {title_ref}',
182 'September' => 'Settembre',
183 'Short Table of Contents' => 'Indice breve',
184 'Short table of contents' => 'Indice breve',
185 'Subsection One-Four' => 'Sottosezione Uno-Quattro',
186 'Subsection One-One' => 'Sottosezione Uno-Uno',
187 'Subsection One-Three' => 'Sottosezione Uno-Tre',
188 'Subsection One-Two' => 'Sottosezione Uno-Due',
189 'Subsubsection One-Two-Four' => 'Sottosottosezione Uno-Due-Quattro',
190 'Subsubsection One-Two-One' => 'Sottosottosezione Uno-Due-Uno',
191 'Subsubsection One-Two-Three' => 'Sottosottosezione Uno-Due-Tre',
192 'Subsubsection One-Two-Two' => 'Sottosottosezione Uno-Due-Due',
193 'T2H_today' => '%s, %d %d',
194 'Table of Contents' => 'Indice',
195 'Table of contents' => 'Indice',
196 'The node you are looking for is at {href}.' => 'Il nodo che stai cercando è {href}',
198 '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}}}.',
199 'This document was generated using @uref{{program_homepage}, @emph{{program}}}.' => 'Questo documento è stato generato con @uref{{program_homepage}, @emph{{program}}}.',
201 'Untitled Document' => 'Documento senza titolo',
203 'Up node' => 'Nodo superiore',
204 'Up section' => 'Sezione superiore',
205 'current' => 'attuale',
206 'on @emph{{date}}' => 'il @emph{{date}}',
207 'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'sezione `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}',
208 'section `{section}\' in @cite{{book}}' => 'sezione `{section}\' in @cite{{book}}',
210 'see @cite{{book}}' => 'vedi @cite{{book}}',
211 'see section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'vedi la sezione `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}',
212 'see section `{section}\' in @cite{{book}}' => 'vedi la sezione `{section}\' in @cite{{book}}',
213 'see section {reference_name}' => 'vedi la sezione {reference_name}',
214 'see {node_file_href}' => 'vedi {node_file_href}',
215 'see {node_file_href} @cite{{book}}' => 'vedi {node_file_href} @cite{{book}}',
216 'see {node_file_href} section `{section}\' in @cite{{book}}' => 'vedi {node_file_href} nella sezione `{section}\' in @cite{{book}}',
217 'see {reference_name}' => 'vedi {reference_name}',
218 'see {ref}' => 'vedi {ref}',
219 'see {title_ref}' => 'vedi {title_ref}',
220 '{acronym_like} ({explanation})' => '{acronym_like} ({explanation})',
221 '{name} of {class}' => '{name} di {class}',
222 '{name} on {class}' => '{name} in {class}',
223 '{node_file_href}' => '{node_file_href}',
224 '{node_file_href} @cite{{book}}' => '{node_file_href} @cite{{book}}',
225 '{node_file_href} section `{section}\' in @cite{{book}}' => '{node_file_href} nella sezione `{section}\' in @cite{{book}}',
226 '{reference_name}' => '{reference_name}',
228 '{style} {number}' => '{style} {number}',
229 '{style}: {caption_first_line}' => '{style}: {caption_first_line}',
230 '{style}: {shortcaption_first_line}' => '{style}: {shortcaption_first_line}',
231 '{title_ref}' => '{title_ref}'
234 $LANGUAGES->{'hu'} = {
235 ' The buttons in the navigation panels have the following meaning:' => ' A navigációs panelen levő gombok jelentése a következő:',
236 ' where the @strong{ Example } assumes that the current position is at @strong{ Subsubsection One-Two-Three } of a document of the following structure:' => ' ahol a @strong{ Példa } feltételezi, hogy az aktuális pozíció az @strong{ 1-2-3 alalszakasz } egy olyan dokumentumban, melynek szerkezete a következő:',
238 '(outside of any element)' => '(bármelyik elemen kívül)',
239 '(outside of any node)' => '(bármelyik csomóponton kívül)',
240 '@b{{quotation_arg}:} ' => '@b{{quotation_arg}:} ',
241 '@cite{{book}}' => '@cite{{book}}',
242 '@{No value for `{value}\'@}' => '@{Nincs értéke ennek: `{value}\'@}',
243 'About' => 'Névjegy',
244 'About (help)' => 'Névjegy (súgó)',
245 'About This Document' => 'Erről a dokumentumról',
246 'April' => 'április',
247 'August' => 'augusztus',
249 'Back section in previous file' => 'Előző fájl hátsó szakasza',
250 'Beginning of this chapter or previous chapter' => 'Fejezet eleje vagy előző fejezet',
252 'Contents' => 'Tartalom',
253 'Cover (top) of document' => 'Dokumentum borítója',
254 'Current' => 'Aktuális',
255 'Current Position' => 'Aktuális pozíció',
256 'Current section' => 'Aktuális szakasz',
257 'December' => 'december',
258 'FastBack' => 'Gyorsan vissza',
259 'FastForward' => 'Gyorsan előre',
260 'February' => 'február',
262 'First section in reading order' => 'Első szakasz az olvasási sorrendben',
263 'Following' => 'Következő',
264 'Following node' => 'Következő csomópont',
265 'Footnotes' => 'Lábjegyzet',
266 'Forward' => 'Előre',
267 'Forward section in next file' => 'Következő fájl elülső szakasza',
268 'From 1.2.3 go to' => '1.2.3-ból menj ide:',
269 'Go to' => 'Menj ide:',
270 'Index' => 'Tárgymutató',
271 'Index Entry' => 'Tárgymutató-bejegyzés',
272 'January' => 'január',
274 'Jump to' => 'Ugorj ide:',
277 'Last section in reading order' => 'Utolsó szakasz az olvasási sorrendben',
278 'March' => 'március',
282 'Next' => 'Következő',
283 'Next chapter' => 'Következő fejezet',
284 'Next file' => 'Következő fájl',
285 'Next node' => 'Következő csomópont',
286 'Next section in reading order' => 'Következő szakasz az olvasási sorrendben',
287 'Next section on same level' => 'Következő szakasz ugyanazon a szinten',
288 'NextFile' => 'KövetkezőFájl',
289 'Node following in node reading order' => 'Következő csomópont az olvasási sorrendben',
290 'Node up' => 'Szülő csomópont',
291 'NodeNext' => 'KövetkezőCsomópont',
292 'NodePrev' => 'ElőzőCsomópont',
293 'NodeUp' => 'SzülőCsomópont',
294 'November' => 'november',
295 'October' => 'október',
296 'Overview' => 'Áttekintés',
298 'PrevFile' => 'ElőzőFájl',
299 'Previous' => 'Előző',
300 'Previous file' => 'Előző fájl',
301 'Previous node' => 'Előző csomópont',
302 'Previous section in reading order' => 'Előző szakasz az olvasási sorrendben',
303 'Previous section on same level' => 'Előző szakasz ugyanazon a szinten',
304 'Section' => 'Szakasz',
305 'Section One' => '1. szakasz',
307 'See @cite{{book}}' => 'Ld. @cite{{book}}',
308 'See section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'Ld. ezt a szakaszt: `@asis{}`{section_name}\'@asis{}\' itt: @cite{{book}}',
309 'See section `{section}\' in @cite{{book}}' => 'Ld. ezt a szakaszt: `{section}\' itt: @cite{{book}}',
310 'See section {reference_name}' => 'Ld. ezt a szakaszt: {reference_name}',
311 'See {node_file_href}' => 'Ld. {node_file_href}',
312 'See {node_file_href} @cite{{book}}' => 'See {node_file_href} @cite{{book}}',
313 'See {node_file_href} section `{section}\' in @cite{{book}}' => 'Ld. {node_file_href} ezt a szakaszt: `{section}\' itt: @cite{{book}}',
314 'See {reference_name}' => 'Ld. {reference_name}',
315 'See {ref}' => 'Ld. {ref}',
316 'See {title_ref}' => 'Ld. {title_ref}',
317 'September' => 'szeptember',
318 'Short Table of Contents' => 'Rövid tartalomjegyzék',
319 'Short table of contents' => 'Rövid tartalomjegyzék',
320 'Subsection One-Four' => '1-4 alszakasz',
321 'Subsection One-One' => '1-1 alszakasz',
322 'Subsection One-Three' => '1-3 alszakasz',
323 'Subsection One-Two' => '1-2 alszakasz',
324 'Subsubsection One-Two-Four' => '1-2-4 alalszakasz',
325 'Subsubsection One-Two-One' => '1-2-1 alalszakasz',
326 'Subsubsection One-Two-Three' => '1-2-3 alalszakasz',
327 'Subsubsection One-Two-Two' => '1-2-2 alalszakasz',
328 'T2H_today' => '%s, %d %d',
329 'Table of Contents' => 'Tartalomjegyzék',
330 'Table of contents' => 'Tartalomjegyzék',
331 'The node you are looking for is at {href}.' => 'A keresett csomópont itt található: {href}.',
333 '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}}}.',
334 'This document was generated using @uref{{program_homepage}, @emph{{program}}}.' => 'Ezt a dokumentumot a(z) @uref{{program_homepage}, @emph{{program}}} generálta.',
336 'Untitled Document' => 'Névtelen dokumentum',
338 'Up node' => 'Szülő csomópont',
339 'Up section' => 'Szülő szakasz',
340 'current' => 'aktuális',
341 'on @emph{{date}}' => 'ekkor: @emph{{date}}',
342 'section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'szakasz: `@asis{}`{section_name}\'@asis{}\' itt: @cite{{book}}',
343 'section `{section}\' in @cite{{book}}' => 'szakasz: `{section}\' itt: @cite{{book}}',
345 'see @cite{{book}}' => 'ld. @cite{{book}}',
346 'see section `@asis{}`{section_name}\'@asis{}\' in @cite{{book}}' => 'ld. ezt a szakaszt: `@asis{}`{section_name}\'@asis{}\' itt: @cite{{book}}',
347 'see section `{section}\' in @cite{{book}}' => 'ld. ezt a szakaszt: `{section}\' itt: @cite{{book}}',
348 'see section {reference_name}' => 'ld. ezt a szakaszt: {reference_name}',
349 'see {node_file_href}' => 'ld. {node_file_href}',
350 'see {node_file_href} @cite{{book}}' => 'ld. {node_file_href} @cite{{book}}',
351 'see {node_file_href} section `{section}\' in @cite{{book}}' => 'ld. {node_file_href} ezt a szakaszt: `{section}\' itt: @cite{{book}}',
352 'see {reference_name}' => 'ld. {reference_name}',
353 'see {ref}' => 'ld. {ref}',
354 'see {title_ref}' => 'ld. {title_ref}',
355 '{acronym_like} ({explanation})' => '{acronym_like} ({explanation})',
356 '{name} of {class}' => '{name} típusa: {class}',
357 '{name} on {class}' => '{name} ezen: {class}',
358 '{node_file_href}' => '{node_file_href}',
359 '{node_file_href} @cite{{book}}' => '{node_file_href} @cite{{book}}',
360 '{node_file_href} section `{section}\' in @cite{{book}}' => '{node_file_href} szakasz: `{section}\' itt: @cite{{book}}',
361 '{reference_name}' => '{reference_name}',
363 '{style} {number}' => '{style} {number}',
364 '{style}: {caption_first_line}' => '{style}: {caption_first_line}',
365 '{style}: {shortcaption_first_line}' => '{style}: {shortcaption_first_line}',
366 '{title_ref}' => '{title_ref}'
369 sub ly_get_string () {
370 my $lang = $Texi2HTML::THISDOC{current_lang};
372 if ($lang and $lang ne "en" and $LY_LANGUAGES->{$lang}->{$string}) {
373 return $LY_LANGUAGES->{$lang}->{$string};
380 #############################################################################
381 ### FUNCTIONALITY FOR MAIN WEB PAGES
382 #############################################################################
385 sub lilypond_init_web_manual ()
387 if (exists($main::value{'web_manual'}))
389 print STDERR "Initializing settings for web site\n";
394 push @Texi2HTML::Config::command_handler_process, \&lilypond_init_web_manual;
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">';
405 @Texi2HTML::Config::CSS_REFS = (
406 {FILENAME => "lilypond-web.css", TITLE => "Default style"}
409 @Texi2HTML::Config::CSS_REFS = (
410 {FILENAME => "lilypond-mccarty.css", TITLE => "Patrick McCarty's design"}
414 @Texi2HTML::Config::ALT_CSS_REFS = (
415 {FILENAME => "lilypond.css", TITLE => "Andrew Hawryluk's design" },
416 {FILENAME => "lilypond-blue.css", TITLE => "Kurt Kroon's blue design" },
418 $Texi2HTML::Config::USE_ACCESSKEY = 1;
419 $Texi2HTML::Config::USE_LINKS = 1;
420 $Texi2HTML::Config::USE_REL_REV = 1;
421 $Texi2HTML::Config::SPLIT_INDEX = 0;
422 $Texi2HTML::Config::SEPARATED_FOOTNOTES = 0; # Print footnotes on same page, not separated
424 if ($Texi2HTML::Config::SPLIT eq 'section' or
425 $Texi2HTML::Config::SPLIT eq 'subsubsection') {
426 $Texi2HTML::Config::element_file_name = \&lilypond_element_file_name;
429 $Texi2HTML::Config::element_target_name = \&lilypond_element_target_name;
430 $default_print_element_header = $Texi2HTML::Config::print_element_header;
431 $Texi2HTML::Config::print_element_header = \&lilypond_print_element_header;
432 $Texi2HTML::Config::print_page_foot = \&print_lilypond_page_foot;
433 $Texi2HTML::Config::print_navigation = \&lilypond_print_navigation;
434 $Texi2HTML::Config::external_ref = \&lilypond_external_ref;
435 $default_external_href = $Texi2HTML::Config::external_href;
436 $Texi2HTML::Config::external_href = \&lilypond_external_href;
437 $default_toc_body = $Texi2HTML::Config::toc_body;
438 $Texi2HTML::Config::toc_body = \&lilypond_toc_body;
439 $Texi2HTML::Config::css_lines = \&lilypond_css_lines;
440 $default_unknown = $Texi2HTML::Config::unknown;
441 $Texi2HTML::Config::unknown = \&lilypond_unknown;
442 $default_print_page_head = $Texi2HTML::Config::print_page_head;
443 $Texi2HTML::Config::print_page_head = \&lilypond_print_page_head;
444 # $Texi2HTML::Config::foot_line_and_ref = \&lilypond_foot_line_and_ref;
445 $Texi2HTML::Config::foot_line_and_ref = \&makeinfo_like_foot_line_and_ref;
446 $Texi2HTML::Config::foot_lines = \&makeinfo_like_foot_lines;
447 $Texi2HTML::Config::paragraph = \&makeinfo_like_paragraph;
451 # Examples should be formatted similar to quotes:
452 $Texi2HTML::Config::complex_format_map->{'example'} = {
453 'begin' => q{"<blockquote>"},
454 'end' => q{"</blockquote>\n"},
458 %Texi2HTML::config::misc_pages_targets = (
459 'Overview' => 'Overview',
460 'Contents' => 'Contents',
465 my @section_to_filename;
470 #############################################################################
472 #############################################################################
475 $Data::Dumper::Maxdepth = 2;
477 sub print_element_info($)
480 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
481 print "Element: $element\n";
482 print Dumper($element);
489 #############################################################################
491 #############################################################################
493 # Convert a given node name to its proper file name (normalization as explained
494 # in the texinfo manual:
495 # http://www.gnu.org/software/texinfo/manual/texinfo/html_node/HTML-Xref-Node-Name-Expansion.html
496 sub texinfo_file_name($)
500 # File name normalization by texinfo:
501 # 1/2: letters and numbers are left unchanged
502 # 3/4: multiple, leading and trailing whitespace is removed
503 $text = main::normalise_space($text);
504 # 5/6: all remaining spaces are converted to '-', all other 7- or 8-bit
505 # chars are replaced by _xxxx (xxxx=ascii character code)
506 while ($text ne '') {
507 if ($text =~ s/^([A-Za-z0-9]+)//o) { # number or letter stay unchanged
509 } elsif ($text =~ s/^ //o) { # space -> '-'
511 } elsif ($text =~ s/^(.)//o) { # Otherwise use _xxxx (ascii char code)
513 if ( $ccode <= 0xFFFF ) {
514 $result .= sprintf("_%04x", $ccode);
516 $result .= sprintf("__%06x", $ccode);
520 # 7: if name does not begin with a letter, prepend 't_g' (so it starts with a letter)
521 if ($result !~ /^[a-zA-Z]/) {
522 $result = 't_g' . $result;
528 # Load a file containing a nodename<=>filename map (tab-sepatared, i.e.
529 # NODENAME\tFILENAME\tANCHOR
530 # Returns a ref to a hash "Node title" => ["FilenameWithoutExt", "Anchor"]
531 sub load_map_file ($)
536 # For some unknown reason, Perl on my system (5.10.0 on Fedora 12)
537 # refuses to open map files of translated documents with
538 # '<:encoding(utf8)', but decoding from UTF-8 line by line works. -jm
539 if (open(XREFFILE,'<', $mapfile)) {
541 while ( $line = decode ('UTF-8', <XREFFILE>) ) {
542 # parse the tab-separated entries and insert them into the map:
544 my @entries = split(/\t/, $line);
545 if (scalar (@entries) == 3) {
546 $node_map->{$entries[0]} = [$entries[1], $entries[2]];
548 print STDERR "Invalid entry in the node file $mapfile: $line\n";
551 # print STDERR %{$node_map};
554 print STDERR "WARNING: Unable to load the map file $mapfile\n";
560 # Split the given path into dir and basename (with .texi removed). Used mainly
561 # to get the path/basename of the original texi input file
562 sub split_texi_filename ($)
565 my ($docu_dir, $docu_name);
566 if ($docu =~ /(.*\/)/) {
567 chop($docu_dir = $1);
569 $docu_name =~ s/.*\///;
574 $docu_name =~ s/\.te?x(i|info)?$//;
575 return ($docu_dir, $docu_name);
582 #############################################################################
584 #############################################################################
586 # Include our standard CSS file, not hard-coded CSS code directly in the HTML!
587 # For IE, conditionally include the lilypond-ie-fixes.css style sheet
588 sub lilypond_css_lines ($$)
590 my $import_lines = shift;
591 my $rule_lines = shift;
592 return if (defined($Texi2HTML::THISDOC{'CSS_LINES'}));
593 if (@$rule_lines or @$import_lines)
595 $Texi2HTML::THISDOC{'CSS_LINES'} = "<style type=\"text/css\">\n<!--\n";
596 $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$import_lines) . "\n" if (@$import_lines);
597 $Texi2HTML::THISDOC{'CSS_LINES'} .= join('',@$rule_lines) . "\n" if (@$rule_lines);
598 $Texi2HTML::THISDOC{'CSS_LINES'} .= "-->\n</style>\n";
600 foreach my $ref (@CSS_REFS)
602 $Texi2HTML::THISDOC{'CSS_LINES'} .= "<link rel=\"stylesheet\" type=\"text/css\" title=\"$ref->{TITLE}\" href=\"$ref->{FILENAME}\">\n";
604 foreach my $ref (@Texi2HTML::Config::ALT_CSS_REFS)
606 $Texi2HTML::THISDOC{'CSS_LINES'} .= "<link rel=\"alternate stylesheet\" type=\"text/css\" href=\"$ref->{FILENAME}\" title=\"$ref->{TITLE}\">\n";
608 # FIXME: the website doesn't use ie7-specific fixes; do the
609 # docs still need this? -gp
610 $Texi2HTML::THISDOC{'CSS_LINES'} .= "<!--[if lte IE 7]>\n<link href=\"lilypond-ie-fixes.css\" rel=\"stylesheet\" type=\"text/css\">\n<![endif]-->\n";
617 #############################################################################
618 ### SPLITTING BASED ON NUMBERED SECTIONS
619 #############################################################################
623 my $node_to_filename_map = ();
626 # This function makes sure that files are only generated for numbered sections,
627 # but not for unnumbered ones. It is called after texi2html has done its own
628 # splitting and simply returns the filename for the node given as first argument
629 # Nodes with the same filename will be printed out to the same filename, so
630 # this really all we need. Also, make sure that the file names for sections
631 # are derived from the section title. We also might want to name the anchors
632 # according to node titles, which works by simply overriding the id element of
634 # If an external nodename<=>filename/anchor map file is found (loaded in
635 # the command handler, use the externally created values, otherwise use the
637 sub lilypond_element_file_name($$$)
641 my $docu_name = shift;
642 my $docu_ext = $Texi2HTML::Config::EXTENSION;
644 my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
645 # the snippets page does not use nodes for the snippets, so in this case
646 # we'll have to use the section name!
647 if ($node_name eq '') {
648 $node_name = main::remove_texi($element->{'texi'});
651 # If we have an entry in the section<=>filename map, use that one, otherwise
652 # generate the filename/anchor here. In the latter case, external manuals
653 # will not be able to retrieve the file name for xrefs!!! Still, I already
654 # had that code, so I'll leave it in in case something goes wrong with the
655 # extract_texi_filenames.py script in the lilypond build process!
656 if (exists ($node_to_filename_map->{$node_name})) {
657 (my $filename, my $anchor) = @{$node_to_filename_map->{$node_name}};
658 $filename .= ".$docu_ext" if (defined($docu_ext));
660 # unnumbered sections (except those at top-level!) always go to the same
661 # file as the previous numbered section
662 if (not ($element->{number}) and not ($lastfilename eq '') and ($element->{level} > 1)) {
663 $filename = $lastfilename;
665 if (($filename eq $lastfilename)) {
666 $$element{doc_nr} = $docnr;
669 $$element{doc_nr} = $docnr;
670 $lastfilename = $filename;
672 # print STDERR "File name: $filename\n";
673 return lc($filename);
675 } elsif ($type eq "top" or $type eq "toc" or $type eq "doc" or $type eq "stoc" or $type eq "foot" or $type eq "about") {
678 print STDERR "WARNING: Node '$node_name' was NOT found in the map\n"
679 unless ($node_name eq '') or ($element->{'tag'} eq 'unnumberedsec')
680 or ($node_name =~ /NOT REALLY USED/);
682 # Numbered sections will get a filename Node_title, unnumbered sections will use
683 # the file name of the previous numbered section:
684 if (($element->{number}) or ($lastfilename eq '') or ($element->{level} == 1)) {
685 # normalize to the same file name as texinfo
686 if ($element->{translationof}) {
687 $node_name = main::remove_texi($element->{translationof});
689 my $filename = texinfo_file_name($node_name);
690 $filename .= ".$docu_ext" if (defined($docu_ext));
692 $$element{doc_nr} = $docnr;
693 $lastfilename = $filename;
694 print STDERR "File name: $filename\n";
695 return lc($filename);
697 $$element{doc_nr} = $docnr;
698 print STDERR "File name: $filename\n";
699 return lc($filename);
706 sub lilypond_element_target_name($$$)
711 # Target is based on node name (or sec name for secs without node attached)
712 my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
713 if ($node_name eq '') {
714 $node_name = main::remove_texi($element->{'texi'});
717 # If we have an entry in the section<=>filename map, use that one, otherwise
718 # generate the anchor here.
719 if (exists ($node_to_filename_map->{$node_name})) {
720 (my $filename, $target) = @{$node_to_filename_map->{$node_name}};
722 my $anchor = $node_name;
723 if ($element->{translationof}) {
724 $anchor = main::remove_texi($element->{translationof});
726 # normalize to the same file name as texinfo
727 $target = texinfo_file_name($anchor);
729 # TODO: Once texi2html correctly prints out the target and not the id for
730 # the sections, change this back to ($id, $target)
731 $target = lc($target);
732 return ($target, $target);
736 ## Load the map file for the corrently processed texi file. We do this
737 # using a command init handler, since texi2html does not have any
738 # other hooks that are called after THISDOC is filled but before phase 2
739 # of the texi2html conversion.
740 sub lilypond_init_map ()
742 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
743 my $map_filename = main::locate_include_file ("${docu_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
744 || main::locate_include_file ("${docu_name}.xref-map");
745 print STDERR "Map filename is: $map_filename\nDocu name is $docu_name\n";
746 $node_to_filename_map = load_map_file ($map_filename);
748 push @Texi2HTML::Config::command_handler_init, \&lilypond_init_map;
752 #############################################################################
753 ### CLEANER LINK TITLE FOR EXTERNAL REFS
754 #############################################################################
756 # The default formatting of external refs returns e.g.
757 # "(lilypond-internals)Timing_translator", so we remove all (...) from the
758 # file_and_node argument. Also, we want only a very simple format, so we don't
759 # even call the default handler!
760 sub lilypond_external_ref($$$$$$)
765 my $file_node = shift;
766 my $href = lc(shift);
767 my $cross_ref = shift;
769 my $displaytext = '';
771 # 1) if we have a cross ref name, that's the text to be displayed:
772 # 2) For the top node, use the (printable) name of the manual, unless we
773 # have an explicit cross ref name
774 # 3) In all other cases use the section name
775 if ($cross_ref ne '') {
776 $displaytext = $cross_ref;
777 } elsif (($section eq '') or ($section eq 'Top')) {
778 $displaytext = $book;
780 $displaytext = $section;
783 $displaytext = &$anchor('', $href, $displaytext) if ($displaytext ne '');
784 return &$I('%{node_file_href}', { 'node_file_href' => $displaytext });
791 #############################################################################
792 ### HANDLING TRANSLATED SECTIONS: handle @translationof, secname<->filename
793 ### map stored on disk, xrefs in other manuals load that map
794 #############################################################################
797 # Try to make use of @translationof to generate files according to the original
798 # English section title...
799 sub lilypond_unknown($$$$$)
807 # the @translationof macro provides the original English section title,
808 # which should be used for file/anchor naming, while the title will be
809 # translated to each language
810 # It is already used by extract_texi_filenames.py, so this should not be
811 # necessary here at all. Still, I'll leave the code in just in case the
812 # python script messed up ;-)
813 if ($pass == 1 and $macro eq "translationof") {
814 if (ref($state->{'element'}) eq 'HASH') {
815 $state->{'element'}->{'translationof'} = main::normalise_space($line);
817 return ('', 1, undef, undef);
819 return &$default_unknown($macro, $line, $pass, $stack, $state);
826 my %translated_books = ();
827 # Construct a href to an external source of information.
828 # node is the node with texinfo @-commands
829 # node_id is the node transliterated and transformed as explained in the
831 # node_xhtml_id is the node transformed such that it is unique and can
832 # be used to make an html cross ref as explained in the texinfo manual
833 # file is the file in '(file)node'
834 sub lilypond_external_href($$$)
838 my $node_hxmlt_id = shift;
841 # 1) Keep a hash of book->section_map
842 # 2) if not file in keys hash => try to load the map (assign empty map if
843 # non-existent => will load only once!)
844 # 3) if node in the section=>(file, anchor) map, replace node_id and
845 # node_xhtml_id by the map's values
846 # 4) call the default_external_href with these values (or the old ones if not found)
848 if (($node_id ne '') and defined($file) and ($node_id ne 'Top')) {
849 my $map_name = $file;
850 $map_name =~ s/-big-page//;
852 # Load the map if we haven't done so already
853 if (!exists($translated_books{$map_name})) {
854 my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
855 my $map_filename = main::locate_include_file ("${map_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
856 || main::locate_include_file ("${map_name}.xref-map");
857 $translated_books{$map_name} = load_map_file ($map_filename);
860 # look up translation. use these values instead of the old filename/anchor
861 my $section_name_map = $translated_books{$map_name};
862 my $node_text = main::remove_texi($node);
863 if (defined($section_name_map->{$node_text})) {
864 ($node_id, $node_hxmlt_id) = @{$section_name_map->{$node_text}};
866 print STDERR "WARNING: Unable to find node '$node_text' in book $map_name.\n";
871 return &$default_external_href($node, $node_id, $node_hxmlt_id, lc($file));
873 return &$default_external_href($node, $node_id, $node_hxmlt_id);
881 #############################################################################
882 ### CUSTOM TOC FOR EACH PAGE (in a frame on the left)
883 #############################################################################
885 my $page_toc_depth = 2;
886 my @default_toc = [];
888 # Initialize the toc_depth to 1 if the command-line option -D=short_toc is given
889 sub lilypond_init_toc_depth ()
891 if (exists($main::value{'short_toc'}) and not exists($main::value{'bigpage'})) {
895 # Set the TOC-depth (depending on a texinfo variable short_toc) in a
896 # command-handler, so we have them available when creating the pages
897 push @Texi2HTML::Config::command_handler_process, \&lilypond_init_toc_depth;
900 # recursively generate the TOC entries for the element and its children (which
901 # are only shown up to maxlevel. All ancestors of the current element are also
902 # shown with their immediate children, irrespective of their level.
903 # Unnumbered entries are only printed out if they are at top-level or 2nd level
904 # or their parent element is an ancestor of the currently viewed node.
905 # The conditions to call this method to print the entry for a child node is:
906 # -) the parent is an ancestor of the current page node
907 # -) the parent is a numbered element at top-level toplevel (i.e. show numbered
908 # and unnumbered 2nd-level children of numbered nodes)
909 # -) the child element is a numbered node below level maxlevel
910 sub generate_ly_toc_entries($$$)
913 my $element_path = shift;
917 my $maxlevel = shift;
919 # Skip undefined sections, plus all sections generated by index splitting
920 return() if (not defined($element) or exists($element->{'index_page'}));
922 my $level = $element->{'toc_level'};
923 my $is_parent_of_current = $element->{'id'} && $element_path->{$element->{'id'}};
924 my $ind = ' ' x $level;
927 $this_css_class = " class=\"";
929 $this_css_class = "";
931 $this_css_class .= $is_parent_of_current ? " toc_current" : "";
934 "Learning", "Glossary", "Essay",
935 "Contact", "Tiny examples", "Bug reports"
938 "Features", "Examples", "Freedom", "Background",
939 "Unix", "MacOS X", "Windows",
940 "Notation", "Usage", "Snippets",
941 "Help us", "Development", "Authors"
944 "Productions", "Testimonials",
945 "Source", "Old downloads",
946 "FAQ", "Changes", "Extend", "Internals",
947 "Publications", "Old news"
950 "Text input", "Alternate input",
952 "Translated", "All", "FDL"
955 my $addColor = " colorDefault";
956 foreach $color (@color_1) {
957 if ($element->{'text'} eq $color) {
958 $addColor = " color1";
961 foreach $color (@color_2) {
962 if ($element->{'text'} eq $color) {
963 $addColor = " color2";
966 foreach $color (@color_3) {
967 if ($element->{'text'} eq $color) {
968 $addColor = " color3";
971 foreach $color (@color_4) {
972 if ($element->{'text'} eq $color) {
973 $addColor = " color4";
977 $this_css_class .= $addColor . "\"";
980 my $entry = "$ind<li$this_css_class>" . &$anchor ($element->{'tocid'}, "$element->{'file'}#$element->{'target'}",$element->{'text'});
982 push (@result, $entry);
983 my $children = $element->{'section_childs'};
984 if (defined($children) and (ref($children) eq "ARRAY")) {
985 my $force_children = $is_parent_of_current or ($level == 1 and $element->{'number'});
986 my @child_result = ();
987 foreach my $c (@$children) {
988 my $is_numbered_child = defined ($c->{'number'});
989 my $below_maxlevel = $c->{'toc_level'} le $maxlevel;
990 if ($force_children or ($is_numbered_child and $below_maxlevel)) {
991 my @child_res = generate_ly_toc_entries($c, $element_path, $maxlevel);
992 push (@child_result, @child_res);
995 # if no child nodes were generated, e.g. for the index, where expanded pages
996 # are ignored, don't generate a list at all...
998 push (@result, "\n$ind<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
1000 push (@result, "$ind<li$this_css_class>" . &$anchor ($element->{'tocid'}, "$element->{'file'}#$element->{'target'}","(main)"));
1002 push (@result, @child_result);
1004 push (@result, "$ind</ul>\n");
1007 push (@result, "$ind</li>\n");
1012 # Print a customized TOC, containing only the first two levels plus the whole
1013 # path to the current page
1014 sub lilypond_generate_page_toc_body($)
1016 my $element = shift;
1017 my $current_element = $element;
1019 $parentelements{$element->{'id'}} = 1;
1020 # Find the path to the current element
1021 while ( defined($current_element->{'sectionup'}) and
1022 ($current_element->{'sectionup'} ne $current_element) )
1024 $parentelements{$current_element->{'sectionup'}->{'id'}} = 1
1025 if ($current_element->{'sectionup'}->{'id'} ne '');
1026 $current_element = $current_element->{'sectionup'};
1028 if (exists($main::value{'shallow_toc'})) {
1033 return () if not defined($current_element);
1034 # Create the toc entries recursively
1035 my @toc_entries = "";
1037 push (@toc_entries, "<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
1038 # FIXME: add link to main page, really hackily.
1039 if ($element->{'sectionup'}) {
1040 # it's not the top element
1041 push (@toc_entries, "<li><a href=\"index.html\">Main</a></li>\n");
1043 push (@toc_entries, "<li class=\"toc_current\"><a href=\"index.html\">Main</a></li>\n");
1046 push (@toc_entries, "<div class=\"contents\">\n");
1047 push (@toc_entries, "<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
1049 my $children = $current_element->{'section_childs'};
1050 foreach ( @$children ) {
1051 push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth));
1055 # WTF, perl needs 6 lines of magic to do: ' ' + open ('file-name').read ()?
1057 my $name = "search-box.html";
1058 open FILE, "$ENV{SRC_DIR}/$name" or open FILE, "$ENV{SRC_DIR}/../$name" or die die "no such file: $name: $!";
1060 my $string = <FILE>;
1061 $string = "<li>\n" . $string . "</li>\n";
1062 push (@toc_entries, $string);
1065 push (@toc_entries, "</ul>\n");
1066 push (@toc_entries, "</div>\n");
1067 return @toc_entries;
1070 sub lilypond_print_toc_div ($$)
1074 my @lines = @$tocref;
1075 # use default TOC if no custom lines have been generated
1076 @lines = @default_toc if (not @lines);
1079 print $fh "\n\n<div id=\"tocframe\">\n";
1081 # Remove the leading "GNU LilyPond --- " from the manual title
1082 my $topname = $Texi2HTML::NAME{'Top'};
1083 $topname =~ s/^GNU LilyPond(:| &[mn]dash;) //;
1085 # construct the top-level Docs index (relative path and including language!)
1086 my $lang = $Texi2HTML::THISDOC{current_lang};
1087 if ($lang and $lang ne "en") {
1093 $reldir = "../" if ($Texi2HTML::Config::SPLIT eq 'section');
1094 my $uplink = $reldir."web/manuals.${lang}html";
1098 print $fh "<p class=\"toc_uplink\"><a href=\"$uplink\"
1099 title=\"Documentation Index\"><< " .
1100 &ly_get_string ('Back to Documentation Index') .
1103 print $fh '<h4 class="toc_header"> ' . &$anchor('',
1104 $Texi2HTML::HREF{'Top'},
1106 'title="Start of the manual"'
1110 foreach my $line (@lines) {
1113 print $fh "</div>\n\n";
1117 # Create the custom TOC for this page (partially folded, current page is
1118 # highlighted) and store it in a global variable. The TOC is written out after
1119 # the html contents (but positioned correctly using CSS), so that browsers with
1120 # css turned off still show the contents first.
1121 our @this_page_toc = ();
1122 sub lilypond_print_element_header
1124 my $first_in_page = shift;
1125 my $previous_is_top = shift;
1126 if ($first_in_page and not @this_page_toc) {
1127 if (defined($Texi2HTML::THIS_ELEMENT)) {
1128 # Create the TOC for this page
1129 @this_page_toc = lilypond_generate_page_toc_body($Texi2HTML::THIS_ELEMENT);
1132 return &$default_print_element_header( $first_in_page, $previous_is_top);
1135 # Generate the HTML output for the TOC
1136 sub lilypond_toc_body($)
1138 my $elements_list = shift;
1139 # Generate a default TOC for pages without THIS_ELEMENT
1140 @default_toc = lilypond_generate_page_toc_body(@$elements_list[0]);
1141 return &$default_toc_body($elements_list);
1144 # Print out the TOC in a <div> at the beginning of the page
1145 sub lilypond_print_page_head($)
1148 &$default_print_page_head($fh);
1149 print $fh "<div id=\"main\">\n";
1152 # Print out the TOC in a <div> at the end of th page, which will be formatted as a
1153 # sidebar mimicking a TOC frame
1154 sub print_lilypond_page_foot($)
1157 my $program_string = &$program_string();
1158 # print $fh "<p><font size='-1'>$program_string</font><br>$PRE_BODY_CLOSE</p>\n";
1159 print $fh "<!-- FOOTER -->\n\n";
1160 print $fh "<!-- end div#main here -->\n</div>\n\n";
1163 # FIXME: This div and p#languages need to be in div#footer.
1164 # Should we move this div to postprocess_html.py ?
1165 print $fh "<div id=\"verifier_texinfo\">\n";
1166 print $fh "<h3>Validation</h3>\n";
1167 print $fh "<p>Thanks to <a href=\"http://www.webdev.nl/\">webdev.nl</a>";
1168 print $fh " for hosting <code>lilypond.org</code>.\n";
1169 print $fh "<a href=\"http://validator.w3.org/check?uri=referer\">\n";
1170 print $fh "<img src=\"http://www.w3.org/Icons/valid-html401\"\n";
1171 print $fh " alt=\"Valid HTML 4.01 Transitional\"\n";
1172 print $fh " height=\"31\" width=\"88\"></a></p>\n";
1176 # Print the TOC frame and reset the TOC:
1177 lilypond_print_toc_div ($fh, \@this_page_toc);
1178 @this_page_toc = ();
1181 print $fh "</body>\n</html>\n";
1188 #############################################################################
1189 ### NICER / MORE FLEXIBLE NAVIGATION PANELS
1190 #############################################################################
1192 sub get_navigation_text
1195 my $text = $NAVIGATION_TEXT{$button};
1196 if ( ($button eq 'Back') or ($button eq 'FastBack') ) {
1197 $text = $text . $Texi2HTML::NODE{$button} . " ";
1198 } elsif ( ($button eq 'Forward') or ($button eq 'FastForward') ) {
1199 $text = " " . $Texi2HTML::NODE{$button} . $text;
1200 } elsif ( $button eq 'Up' ) {
1201 $text = " ".$text.": " . $Texi2HTML::NODE{$button} . " ";
1207 # Don't automatically create left-aligned table cells for every link, but
1208 # instead create a <td> only on an appropriate '(left|right|center)-aligned-cell-n'
1209 # button text. It's alignment as well as the colspan will be taken from the
1210 # name of the button. Also, add 'newline' button text to create a new table
1211 # row. The texts of the buttons are generated by get_navigation_text and
1212 # will contain the name of the next/previous section/chapter.
1213 sub lilypond_print_navigation
1215 my $buttons = shift;
1216 my $vertical = shift;
1218 my $result = "<table class=\"nav_table\">\n";
1220 $result .= "<tr>" unless $vertical;
1221 my $beginofline = 1;
1222 foreach my $button (@$buttons)
1224 $result .= qq{<tr valign="top" align="left">\n} if $vertical;
1225 # Allow (left|right|center)-aligned-cell and newline as buttons!
1226 if ( $button =~ /^(.*)-aligned-cell-(.*)$/ )
1228 $result .= qq{</td>} unless $beginofline;
1229 $result .= qq{<td valign="middle" align="$1" colspan="$2">};
1232 elsif ( $button eq 'newline' )
1234 $result .= qq{</td>} unless $beginofline;
1235 $result .= qq{</tr>};
1236 $result .= qq{<tr>};
1240 elsif (ref($button) eq 'CODE')
1242 $result .= &$button($vertical);
1244 elsif (ref($button) eq 'SCALAR')
1246 $result .= "$$button" if defined($$button);
1248 elsif (ref($button) eq 'ARRAY')
1250 my $text = $button->[1];
1251 my $button_href = $button->[0];
1252 # verify that $button_href is simple text and text is a reference
1253 if (defined($button_href) and !ref($button_href)
1254 and defined($text) and (ref($text) eq 'SCALAR') and defined($$text))
1256 if ($Texi2HTML::HREF{$button_href})
1258 my $anchor_attributes = '';
1259 if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button_href})) and ($BUTTONS_ACCESSKEY{$button_href} ne ''))
1261 $anchor_attributes = "accesskey=\"$BUTTONS_ACCESSKEY{$button_href}\"";
1263 if ($USE_REL_REV and (defined($BUTTONS_REL{$button_href})) and ($BUTTONS_REL{$button_href} ne ''))
1265 $anchor_attributes .= " rel=\"$BUTTONS_REL{$button_href}\"";
1269 $Texi2HTML::HREF{$button_href},
1270 get_navigation_text($$text),
1276 $result .= get_navigation_text($$text);
1280 elsif ($button eq ' ')
1281 { # handle space button
1283 ($ICONS && $ACTIVE_ICONS{' '}) ?
1284 &$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{' '}) :
1285 $NAVIGATION_TEXT{' '};
1288 elsif ($Texi2HTML::HREF{$button})
1289 { # button is active
1290 my $btitle = $BUTTONS_GOTO{$button} ?
1291 'title="' . $BUTTONS_GOTO{$button} . '"' : '';
1292 if ($USE_ACCESSKEY and (defined($BUTTONS_ACCESSKEY{$button})) and ($BUTTONS_ACCESSKEY{$button} ne ''))
1294 $btitle .= " accesskey=\"$BUTTONS_ACCESSKEY{$button}\"";
1296 if ($USE_REL_REV and (defined($BUTTONS_REL{$button})) and ($BUTTONS_REL{$button} ne ''))
1298 $btitle .= " rel=\"$BUTTONS_REL{$button}\"";
1300 if ($ICONS && $ACTIVE_ICONS{$button})
1304 $Texi2HTML::HREF{$button},
1305 &$button_icon_img($BUTTONS_NAME{$button},
1306 $ACTIVE_ICONS{$button},
1307 $Texi2HTML::SIMPLE_TEXT{$button}),
1316 $Texi2HTML::HREF{$button},
1317 get_navigation_text($button),
1324 { # button is passive
1326 $ICONS && $PASSIVE_ICONS{$button} ?
1327 &$button_icon_img($BUTTONS_NAME{$button},
1328 $PASSIVE_ICONS{$button},
1329 $Texi2HTML::SIMPLE_TEXT{$button}) :
1331 "[" . get_navigation_text($button) . "]";
1333 $result .= "</td>\n" if $vertical;
1334 $result .= "</tr>\n" if $vertical;
1336 $result .= "</td>" unless $beginofline;
1337 $result .= "</tr>" unless $vertical;
1338 $result .= "</table>\n";
1347 @Texi2HTML::Config::SECTION_BUTTONS =
1348 ('left-aligned-cell-1', 'FastBack',
1349 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1350 'right-aligned-cell-1', 'FastForward',
1352 'left-aligned-cell-2', 'Back',
1353 'center-aligned-cell-1', 'Up',
1354 'right-aligned-cell-2', 'Forward'
1357 # buttons for misc stuff
1358 @Texi2HTML::Config::MISC_BUTTONS = ('center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About');
1360 # buttons for chapter file footers
1361 # (and headers but only if SECTION_NAVIGATION is false)
1362 @Texi2HTML::Config::CHAPTER_BUTTONS =
1363 ('left-aligned-cell-1', 'FastBack',
1364 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1365 'right-aligned-cell-1', 'FastForward',
1368 # buttons for section file footers
1369 @Texi2HTML::Config::SECTION_FOOTER_BUTTONS =
1370 ('left-aligned-cell-1', 'FastBack',
1371 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1372 'right-aligned-cell-1', 'FastForward',
1374 'left-aligned-cell-2', 'Back',
1375 'center-aligned-cell-1', 'Up',
1376 'right-aligned-cell-2', 'Forward'
1379 @Texi2HTML::Config::NODE_FOOTER_BUTTONS =
1380 ('left-aligned-cell-1', 'FastBack',
1381 'center-aligned-cell-3', 'Top', 'Contents', 'Index', 'About',
1382 'right-aligned-cell-1', 'FastForward',
1384 'left-aligned-cell-2', 'Back',
1385 'center-aligned-cell-1', 'Up',
1386 'right-aligned-cell-2', 'Forward'
1393 #############################################################################
1394 ### FOOTNOTE FORMATTING
1395 #############################################################################
1397 # Format footnotes in a nicer way: Instead of printing the number in a separate
1398 # (nr) heading line, use the standard way of prepending <sup>nr</sup> immediately
1399 # before the fn text.
1402 # The following code is copied from texi2html's examples/makeinfo.init and
1403 # should be updated when texi2html makes some changes there!
1405 my $makekinfo_like_footnote_absolute_number = 0;
1407 sub makeinfo_like_foot_line_and_ref($$$$$$$$)
1409 my $foot_num = shift;
1410 my $relative_num = shift;
1413 my $from_file = shift;
1414 my $footnote_file = shift;
1418 $makekinfo_like_footnote_absolute_number++;
1420 # this is a bit obscure, this allows to add an anchor only if formatted
1421 # as part of the document.
1422 $docid = '' if ($state->{'outside_document'} or $state->{'multiple_pass'});
1424 if ($from_file eq $footnote_file)
1426 $from_file = $footnote_file = '';
1429 my $foot_anchor = "<sup>" . &$anchor($docid, "$footnote_file#$footid", $relative_num) . "</sup>";
1430 $foot_anchor = &$anchor($docid, "$footnote_file#$footid", "($relative_num)") if ($state->{'preformatted'});
1432 # unshift @$lines, "<li>";
1433 # push @$lines, "</li>\n";
1434 return ($lines, $foot_anchor);
1437 sub makeinfo_like_foot_lines($)
1440 unshift @$lines, "<hr>\n<h4>$Texi2HTML::I18n::WORDS->{'Footnotes_Title'}</h4>\n";
1441 #<ol type=\"1\">\n";
1442 # push @$lines, "</ol>";
1446 my %makekinfo_like_paragraph_in_footnote_nr;
1448 sub makeinfo_like_paragraph ($$$$$$$$$$$$$)
1453 my $paragraph_command = shift;
1454 my $paragraph_command_formatted = shift;
1455 my $paragraph_number = shift;
1457 my $item_nr = shift;
1458 my $enumerate_style = shift;
1460 my $command_stack_at_end = shift;
1461 my $command_stack_at_begin = shift;
1463 #print STDERR "format: $format\n" if (defined($format));
1464 #print STDERR "paragraph @$command_stack_at_end; @$command_stack_at_begin\n";
1465 $paragraph_command_formatted = '' if (!defined($paragraph_command_formatted) or
1466 exists($special_list_commands{$format}->{$paragraph_command}));
1467 return '' if ($text =~ /^\s*$/);
1468 foreach my $style(t2h_collect_styles($command_stack_at_begin))
1470 $text = t2h_begin_style($style, $text);
1472 foreach my $style(t2h_collect_styles($command_stack_at_end))
1474 $text = t2h_end_style($style, $text);
1476 if (defined($paragraph_number) and defined($$paragraph_number))
1478 $$paragraph_number++;
1479 return $text if (($format eq 'itemize' or $format eq 'enumerate') and
1480 ($$paragraph_number == 1));
1485 $open .= " align=\"$paragraph_style{$align}\"";
1487 my $footnote_text = '';
1488 if (defined($command_stack_at_begin->[0]) and $command_stack_at_begin->[0] eq 'footnote')
1490 my $state = $Texi2HTML::THISDOC{'state'};
1491 $makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number}++;
1492 if ($makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number} <= 1)
1494 $open.=' class="footnote"';
1495 my $document_file = $state->{'footnote_document_file'};
1496 if ($document_file eq $state->{'footnote_footnote_file'})
1498 $document_file = '';
1500 my $docid = $state->{'footnote_place_id'};
1501 my $doc_state = $state->{'footnote_document_state'};
1502 $docid = '' if ($doc_state->{'outside_document'} or $doc_state->{'multiple_pass'});
1503 my $foot_label = &$anchor($state->{'footnote_footnote_id'},
1504 $document_file . "#$state->{'footnote_place_id'}",
1505 "$state->{'footnote_number_in_page'}");
1506 $footnote_text = "<small>[${foot_label}]</small> ";
1509 return $open.'>'.$footnote_text.$text.'</p>';
1513 #############################################################################
1515 #############################################################################
1517 # For split pages, use index.html as start page!
1518 if ($Texi2HTML::Config::SPLIT eq 'section') {
1519 $Texi2HTML::Config::TOP_FILE = 'index.html';
1523 push @Texi2HTML::Config::command_handler_process, \&lilypond_init_toc_depth;