4 #+##############################################################################
6 # texi2html: Program to transform Texinfo documents to HTML
8 # Copyright (C) 1999, 2000 Free Software Foundation, Inc.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #-##############################################################################
26 # This requires perl version 5 or higher
29 #++##############################################################################
31 # NOTE FOR DEBUGGING THIS SCRIPT:
32 # You can run 'perl texi2html.pl' directly, provided you have
33 # the environment variable T2H_HOME set to the directory containing
34 # the texi2html.init file
36 #--##############################################################################
42 $T2H_HOMEPAGE = <<EOT;
43 http://www.mathematik.uni-kl.de/~obachman/Texi2html
48 Written by: Lionel Cons <Lionel.Cons\@cern.ch> (original author)
49 Karl Berry <karl\@freefriends.org>
50 Olaf Bachmann <obachman\@mathematik.uni-kl.de>
52 Maintained by: Olaf Bachmann <obachman\@mathematik.uni-kl.de>
53 Send bugs and suggestions to <texi2html\@mathematik.uni-kl.de>
56 # Version: set in configure.in
57 $THISVERSION = '1.64';
58 $THISPROG = "texi2html $THISVERSION"; # program name and version
60 # The man page for this program is included at the end of this file and can be
61 # viewed using the command 'nroff -man texi2html'.
65 $T2H_TODAY = &pretty_date
; # like "20 September 1993"
66 # the eval prevents this from breaking on system which do not have
67 # a proper getpwuid implemented
68 eval { ($T2H_USER = (getpwuid ($<))[6]) =~ s/,.*//;}; # Who am i
70 #+++############################################################################
73 # Pasted content of File $(srcdir)/texi2html.init: Default initializations #
75 #---############################################################################
77 # leave this within comments, and keep the require statement
78 # This way, you can directly run texi2html.pl, if $ENV{T2H_HOME}/texi2html.init
83 ######################################################################
84 # File: texi2html.init
86 # Sets default values for command-line arguments and for various customizable
89 # A copy of this file is pasted into the beginning of texi2html by
92 # Copy this file and make changes to it, if you like.
93 # Afterwards, either, load it with command-line option -init_file <your_init_file>
97 ######################################################################
98 # stuff which can also be set by command-line options
101 # Note: values set here, overwrite values set by the command-line
102 # options before -init_file and might still be overwritten by
103 # command-line arguments following the -init_file option
106 # T2H_OPTIONS is a hash whose keys are the (long) names of valid
107 # command-line options and whose values are a hash with the following keys:
108 # type ==> one of !|=i|:i|=s|:s (see GetOpt::Long for more info)
109 # linkage ==> ref to scalar, array, or subroutine (see GetOpt::Long for more info)
110 # verbose ==> short description of option (displayed by -h)
111 # noHelp ==> if 1 -> for "not so important options": only print description on -h 1
112 # 2 -> for obsolete options: only print description on -h 2
115 $T2H_OPTIONS -> {debug
} =
118 linkage
=> \
$main::T2H_DEBUG
,
119 verbose
=> 'output HTML with debuging information',
122 $T2H_DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
123 $T2H_OPTIONS -> {doctype
} =
126 linkage
=> \
$main::T2H_DOCTYPE
,
127 verbose
=> 'document type which is output in header of HTML files',
132 $T2H_OPTIONS -> {check
} =
135 linkage
=> \
$main::T2H_CHECK
,
136 verbose
=> 'if set, only check files and output all things that may be Texinfo commands',
141 # if set to "tex" (or, "info") expand @iftex and @tex (or, @ifinfo) sections
142 # else, neither expand @iftex, @tex, nor @ifinfo sections
143 $T2H_EXPAND = "info";
144 $T2H_OPTIONS -> {expand
} =
147 linkage
=> \
$T2H_EXPAND,
148 verbose
=> 'Expand info|tex|none section of texinfo source',
152 #if set, uses section named `Footnotes' for glossary
153 $T2H_USE_GLOSSARY = 0;
154 T2H_OPTIONS
-> {glossary
} =
157 linkage
=> \
$T2H_USE_GLOSSARY,
158 verbose
=> "if set, uses section named `Footnotes' for glossary",
164 # $T2H_INVISIBLE_MARK is the text used to create invisible destination
165 # anchors for index links (you can for instance use the invisible.xbm
166 # file shipped with this program). This is a workaround for a known
167 # bug of many WWW browsers, including netscape.
168 # For me, it works fine without it -- on the contrary: if there, it
169 # inserts space between headers and start of text (obachman 3/99)
170 $T2H_INVISIBLE_MARK = '';
171 # $T2H_INVISIBLE_MARK = ' ';
172 $T2H_OPTIONS -> {invisible
} =
175 linkage
=> \
$T2H_INVISIBLE_MARK,
176 verbose
=> 'use text in invisble anchot',
181 # if set, ISO8879 characters are used for special symbols (like copyright, etc)
183 $T2H_OPTIONS -> {iso
} =
186 linkage
=> \
$T2H_USE_ISO,
187 verbose
=> 'if set, ISO8879 characters are used for special symbols (like copyright, etc)',
192 # list directories where @include files are searched for (besides the
193 # directory of the doc file) additional '-I' args add to this list
194 @T2H_INCLUDE_DIRS = (".");
195 $T2H_OPTIONS -> {I
} =
198 linkage
=> \
@T2H_INCLUDE_DIRS,
199 verbose
=> 'append $s to the @include search path',
203 # uses file of this name for top-level file
204 # extension is manipulated appropriately, if necessary.
205 # If empty, <basename of document>.html is used
206 # Typically, you would set this to "index.html".
208 $T2H_OPTIONS -> {top_file
} =
211 linkage
=> \
$T2H_TOP_FILE,
212 verbose
=> 'use $s as top file, instead of <docname>.html',
217 # uses file of this name for table of contents file
218 # extension is manipulated appropriately, if necessary.
219 # If empty, <basename of document>_toc.html is used
221 $T2H_OPTIONS -> {toc_file
} =
224 linkage
=> \
$T2H_TOC_FILE,
225 verbose
=> 'use $s as ToC file, instead of <docname>_toc.html',
229 # if set, output two additional files which use HTML 4.0 "frames".
231 $T2H_OPTIONS -> {frames
} =
234 linkage
=> \
$T2H_FRAMES,
235 verbose
=> 'output files which use HTML 4.0 frames (experimental)',
241 # if set, show the Texinfo menus
243 $T2H_OPTIONS -> {menu
} =
246 linkage
=> \
$T2H_SHOW_MENU,
247 verbose
=> 'ouput Texinfo menus',
250 # -number | -nonumber
251 # if set, number sections and show section names and numbers in references
253 $T2H_NUMBER_SECTIONS = 1;
254 $T2H_OPTIONS -> {number
} =
257 linkage
=> \
$T2H_NUMBER_SECTIONS,
258 verbose
=> 'use numbered sections'
261 # if set, and T2H_NUMBER_SECTIONS is set, then use node names in menu
262 # entries, instead of section names
263 $T2H_NODE_NAME_IN_MENU = 0;
265 # if set and menu entry equals menu descr, then do not print menu descr.
266 # Likewise, if node name equals entry name, do not print entry name.
267 $T2H_AVOID_MENU_REDUNDANCY = 1;
269 # -split section|chapter|none
270 # if set to 'section' (resp. 'chapter') create one html file per (sub)section
271 # (resp. chapter) and separate pages for Top, ToC, Overview, Index,
273 # otherwise, create monolithic html file which contains whole document
274 #$T2H_SPLIT = 'section';
276 $T2H_OPTIONS -> {split} =
279 linkage
=> \
$T2H_SPLIT,
280 verbose
=> 'split document on section|chapter else no splitting',
283 # -section_navigation|-no-section_navigation
284 # if set, then navigation panels are printed at the beginning of each section
285 # and, possibly at the end (depending on whether or not there were more than
286 # $T2H_WORDS_IN_PAGE words on page
287 # This is most useful if you do not want to have section navigation
289 $T2H_SECTION_NAVIGATION = 1;
290 $T2H_OPTIONS -> {sec_nav
} =
293 linkage
=> \
$T2H_SECTION_NAVIGATION,
294 verbose
=> 'output navigation panels for each section',
298 # if set put result files in this directory
299 # if not set result files are put into current directory
300 #$T2H_SUBDIR = 'html';
302 $T2H_OPTIONS -> {subdir
} =
305 linkage
=> \
$T2H_SUBDIR,
306 verbose
=> 'put HTML files in directory $s, instead of $cwd',
310 # If this is set all HTML file will have extension ".htm" instead of
311 # ".html". This is helpful when shipping the document to PC systems.
313 $T2H_OPTIONS -> {short_ext
} =
316 linkage
=> \
$T2H_SHORTEXTN,
317 verbose
=> 'use "htm" extension for output HTML files',
322 # Set the output file prefix, prepended to all .html, .gif and .pl files.
323 # By default, this is the basename of the document
325 $T2H_OPTIONS -> {prefix
} =
328 linkage
=> \
$T2H_PREFIX,
329 verbose
=> 'use as prefix for output files, instead of <docname>',
333 # If set, generate monolithic document output html into $filename
335 $T2H_OPTIONS -> {out_file
} =
338 linkage
=> sub {$main::T2H_OUT
= @_[1]; $T2H_SPLIT = '';},
339 verbose
=> 'if set, all HTML output goes into file $s',
343 #if set cross-references are given without section numbers
345 $T2H_OPTIONS -> {short_ref
} =
348 linkage
=> \
$T2H_SHORT_REF,
349 verbose
=> 'if set, references are without section numbers',
353 # if value is set, then for each @prinindex $what
354 # $docu_name_$what.idx is created which contains lines of the form
355 # $key\t$ref sorted alphabetically (case matters)
356 $T2H_IDX_SUMMARY = 0;
357 $T2H_OPTIONS -> {idx_sum
} =
360 linkage
=> \
$T2H_IDX_SUMMARY,
361 verbose
=> 'if set, also output index summary',
366 # if set, chatter about what we are doing
368 $T2H_OPTIONS -> {Verbose
} =
371 linkage
=> \
$T2H_VERBOSE,
372 verbose
=> 'print progress info to stdout',
376 # For page titles use $T2H_WORDS->{$T2H_LANG}->{...} as title.
377 # To add a new language, supply list of titles (see $T2H_WORDS below).
378 # and use ISO 639 language codes (see e.g. perl module Locale-Codes-1.02
380 # Default's to 'en' if not set or no @documentlanguage is specified
382 $T2H_OPTIONS -> {lang
} =
385 linkage
=> sub {SetDocumentLanguage
($_[1])},
386 verbose
=> 'use $s as document language (ISO 639 encoding)',
390 # if set, uses latex2html for generation of math content
392 $T2H_OPTIONS -> {l2h
} =
395 linkage
=> \
$T2H_L2H,
396 verbose
=> 'if set, uses latex2html for @math and @tex',
399 ######################
400 # The following options are only relevant if $T2H_L2H is set
403 # name/location of latex2html progam
404 $T2H_L2H_L2H = "latex2html";
405 $T2H_OPTIONS -> {l2h_l2h
} =
408 linkage
=> \
$T2H_L2H_L2H,
409 verbose
=> 'program to use for latex2html translation',
414 # if set, skips actual call to latex2html tries to reuse previously generated
417 $T2H_OPTIONS -> {l2h_skip
} =
420 linkage
=> \
$T2H_L2H_SKIP,
421 verbose
=> 'if set, tries to reuse previously latex2html output',
426 # if set, l2h uses this directory for temporarary files. The path
427 # leading to this directory may not contain a dot (i.e., a "."),
428 # otherwise, l2h will fail
430 $T2H_OPTIONS -> {l2h_tmp
} =
433 linkage
=> \
$T2H_L2H_TMP,
434 verbose
=> 'if set, uses $s as temporary latex2html directory',
438 # if set, cleans intermediate files (they all have the prefix $doc_l2h_)
441 $T2H_OPTIONS -> {l2h_clean
} =
444 linkage
=> \
$T2H_L2H_CLEAN,
445 verbose
=> 'if set, do not keep intermediate latex2html files for later reuse',
449 $T2H_OPTIONS -> {D
} =
452 linkage
=> sub {$main::value
{@_[1]} = 1;},
453 verbose
=> 'equivalent to Texinfo "@set $s 1"',
457 $T2H_OPTIONS -> {init_file
} =
460 linkage
=> \
&LoadInitFile
,
461 verbose
=> 'load init file $s'
465 ##############################################################################
467 # The following can only be set in the init file
469 ##############################################################################
471 # if set, center @image by default
472 # otherwise, do not center by default
473 $T2H_CENTER_IMAGE = 1;
475 # used as identation for block enclosing command @example, etc
476 # If not empty, must be enclosed in <td></td>
477 $T2H_EXAMPLE_INDENT_CELL = '<td> </td>';
478 # same as above, only for @small
479 $T2H_SMALL_EXAMPLE_INDENT_CELL = '<td> </td>';
480 # font size for @small
481 $T2H_SMALL_FONT_SIZE = '-1';
483 # if non-empty, and no @..heading appeared in Top node, then
484 # use this as header for top node/section, otherwise use value of
485 # @settitle or @shorttitle (in that order)
486 $T2H_TOP_HEADING = '';
488 # if set, use this chapter for 'Index' button, else
489 # use first chapter whose name matches 'index' (case insensitive)
490 $T2H_INDEX_CHAPTER = '';
492 # if set and $T2H_SPLIT is set, then split index pages at the next letter
493 # after they have more than that many entries
494 $T2H_SPLIT_INDEX = 100;
496 # if set (e.g., to index.html) replace hrefs to this file
497 # (i.e., to index.html) by ./
498 $T2H_HREF_DIR_INSTEAD_FILE = '';
500 ########################################################################
501 # Language dependencies:
502 # To add a new language extend T2H_WORDS hash and create $T2H_<...>_WORDS hash
503 # To redefine one word, simply do:
504 # $T2H_WORDS->{<language>}->{<word>} = 'whatever' in your personal init file.
509 'ToC_Title' => 'Table of Contents',
510 'Overview_Title' => 'Short Table of Contents',
511 'Index_Title' => 'Index',
512 'About_Title' => 'About this document',
513 'Footnotes_Title' => 'Footnotes',
516 'section' => 'section',
517 # If necessary, we could extend this as follows:
519 # 'Top_Button' => 'Top',
520 # 'ToC_Button' => 'Contents',
521 # 'Overview_Button' => 'Overview',
522 # 'Index_button' => 'Index',
523 # 'Back_Button' => 'Back',
524 # 'FastBack_Button' => 'FastBack',
525 # 'Prev_Button' => 'Prev',
526 # 'Up_Button' => 'Up',
527 # 'Next_Button' => 'Next',
528 # 'Forward_Button' =>'Forward',
529 # 'FastWorward_Button' => 'FastForward',
530 # 'First_Button' => 'First',
531 # 'Last_Button' => 'Last',
532 # 'About_Button' => 'About'
537 'ToC_Title' => 'Inhaltsverzeichniss',
538 'Overview_Title' => 'Kurzes Inhaltsverzeichniss',
539 'Index_Title' => 'Index',
540 'About_Title' => 'Über dieses Dokument',
541 'Footnotes_Title' => 'Fußnoten',
544 'section' => 'Abschnitt',
549 'ToC_Title' => 'Inhoudsopgave',
550 'Overview_Title' => 'Korte inhoudsopgave',
551 'Index_Title' => 'Index', #Not sure ;-)
552 'About_Title' => 'No translation available!', #No translation available!
553 'Footnotes_Title' => 'No translation available!', #No translation available!
556 'section' => 'sectie',
561 'ToC_Title' => 'índice General',
562 'Overview_Title' => 'Resumen del Contenido',
563 'Index_Title' => 'Index', #Not sure ;-)
564 'About_Title' => 'No translation available!', #No translation available!
565 'Footnotes_Title' => 'Fußnoten',
566 'See' => 'Véase',
567 'see' => 'véase',
568 'section' => 'sección',
573 'ToC_Title' => 'Innholdsfortegnelse',
574 'Overview_Title' => 'Kort innholdsfortegnelse',
575 'Index_Title' => 'Indeks', #Not sure ;-)
576 'About_Title' => 'No translation available!', #No translation available!
577 'Footnotes_Title' => 'No translation available!',
580 'section' => 'avsnitt',
585 'ToC_Title' => 'Sumário',
586 'Overview_Title' => 'Breve Sumário',
587 'Index_Title' => 'Índice', #Not sure ;-)
588 'About_Title' => 'No translation available!', #No translation available!
589 'Footnotes_Title' => 'No translation available!',
592 'section' => 'Seção',
597 'en' => $T2H_WORDS_EN,
598 'de' => $T2H_WORDS_DE,
599 'nl' => $T2H_WORDS_NL,
600 'es' => $T2H_WORDS_ES,
601 'no' => $T2H_WORDS_NO,
602 'pt' => $T2H_WORDS_PT
607 'January', 'February', 'March', 'April', 'May',
608 'June', 'July', 'August', 'September', 'October',
609 'November', 'December'
614 'Januar', 'Februar', 'März', 'April', 'Mai',
615 'Juni', 'Juli', 'August', 'September', 'Oktober',
616 'November', 'Dezember'
621 'Januari', 'Februari', 'Maart', 'April', 'Mei',
622 'Juni', 'Juli', 'Augustus', 'September', 'Oktober',
623 'November', 'December'
628 'enero', 'febrero', 'marzo', 'abril', 'mayo',
629 'junio', 'julio', 'agosto', 'septiembre', 'octubre',
630 'noviembre', 'diciembre'
636 'januar', 'februar', 'mars', 'april', 'mai',
637 'juni', 'juli', 'august', 'september', 'oktober',
638 'november', 'desember'
643 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio',
644 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro',
645 'Novembro', 'Dezembro'
651 'en' => \
@MONTH_NAMES_EN,
652 'de' => \
@MONTH_NAMES_DE,
653 'es' => \
@MONTH_NAMES_ES,
654 'nl' => \
@MONTH_NAMES_NL,
655 'no' => \
@MONTH_NAMES_NO,
656 'pt' => \
@MONTH_NAMES_PT
658 ########################################################################
659 # Control of Page layout:
660 # You can make changes of the Page layout at two levels:
661 # 1.) For small changes, it is often enough to change the value of
662 # some global string/hash/array variables
663 # 2.) For larger changes, reimplement one of the T2H_DEFAULT_<fnc>* routines,
664 # give them another name, and assign them to the respective
665 # $T2H_<fnc> variable.
667 # As a general interface, the hashes T2H_HREF, T2H_NAME, T2H_NODE hold
668 # href, html-name, node-name of
669 # This -- current section (resp. html page)
670 # Top -- top page ($T2H_TOP_FILE)
671 # Contents -- Table of contents
672 # Overview -- Short table of contents
673 # Index -- Index page
674 # About -- page which explain "navigation buttons"
675 # First -- first node
678 # Whether or not the following hash values are set, depends on the context
679 # (all values are w.r.t. 'This' section)
680 # Next -- next node of texinfo
681 # Prev -- previous node of texinfo
682 # Up -- up node of texinfo
683 # Forward -- next node in reading order
684 # Back -- previous node in reading order
685 # FastForward -- if leave node, up and next, else next node
686 # FastBackward-- if leave node, up and prev, else prev node
688 # Furthermore, the following global variabels are set:
689 # $T2H_THISDOC{title} -- title as set by @setttile
690 # $T2H_THISDOC{fulltitle} -- full title as set by @title...
691 # $T2H_THISDOC{subtitle} -- subtitle as set by @subtitle
692 # $T2H_THISDOC{author} -- author as set by @author
694 # and pointer to arrays of lines which need to be printed by t2h_print_lines
695 # $T2H_OVERVIEW -- lines of short table of contents
696 # $T2H_TOC -- lines of table of contents
697 # $T2H_TOP -- lines of Top texinfo node
698 # $T2H_THIS_SECTION -- lines of 'This' section
701 # There are the following subs which control the layout:
703 $T2H_print_section = \
&T2H_DEFAULT_print_section
;
704 $T2H_print_Top_header = \
&T2H_DEFAULT_print_Top_header
;
705 $T2H_print_Top_footer = \
&T2H_DEFAULT_print_Top_footer
;
706 $T2H_print_Top = \
&T2H_DEFAULT_print_Top
;
707 $T2H_print_Toc = \
&T2H_DEFAULT_print_Toc
;
708 $T2H_print_Overview = \
&T2H_DEFAULT_print_Overview
;
709 $T2H_print_Footnotes = \
&T2H_DEFAULT_print_Footnotes
;
710 $T2H_print_About = \
&T2H_DEFAULT_print_About
;
711 $T2H_print_misc_header = \
&T2H_DEFAULT_print_misc_header
;
712 $T2H_print_misc_footer = \
&T2H_DEFAULT_print_misc_footer
;
713 $T2H_print_misc = \
&T2H_DEFAULT_print_misc
;
714 $T2H_print_chapter_header = \
&T2H_DEFAULT_print_chapter_header
;
715 $T2H_print_chapter_footer = \
&T2H_DEFAULT_print_chapter_footer
;
716 $T2H_print_page_head = \
&T2H_DEFAULT_print_page_head
;
717 $T2H_print_page_foot = \
&T2H_DEFAULT_print_page_foot
;
718 $T2H_print_head_navigation = \
&T2H_DEFAULT_print_head_navigation
;
719 $T2H_print_foot_navigation = \
&T2H_DEFAULT_print_foot_navigation
;
720 $T2H_button_icon_img = \
&T2H_DEFAULT_button_icon_img
;
721 $T2H_print_navigation = \
&T2H_DEFAULT_print_navigation
;
722 $T2H_about_body = \
&T2H_DEFAULT_about_body
;
723 $T2H_print_frame = \
&T2H_DEFAULT_print_frame
;
724 $T2H_print_toc_frame = \
&T2H_DEFAULT_print_toc_frame
;
726 ########################################################################
727 # Layout for html for every sections
729 sub T2H_DEFAULT_print_section
732 local $T2H_BUTTONS = \
@T2H_SECTION_BUTTONS;
733 &$T2H_print_head_navigation($fh) if $T2H_SECTION_NAVIGATION;
734 my $nw = t2h_print_lines
($fh);
735 if ($T2H_SPLIT eq 'section' && $T2H_SECTION_NAVIGATION)
737 &$T2H_print_foot_navigation($fh, $nw);
741 print $fh '<HR SIZE="6">' . "\n";
745 ###################################################################
746 # Layout of top-page I recommend that you use @ifnothtml, @ifhtml,
747 # @html within the Top texinfo node to specify content of top-level
750 # If you enclose everything in @ifnothtml, then title, subtitle,
751 # author and overview is printed
752 # T2H_HREF of Next, Prev, Up, Forward, Back are not defined
753 # if $T2H_SPLIT then Top page is in its own html file
754 sub T2H_DEFAULT_print_Top_header
756 &$T2H_print_page_head(@_) if $T2H_SPLIT;
757 t2h_print_label
(@_); # this needs to be called, otherwise no label set
758 &$T2H_print_head_navigation(@_);
760 sub T2H_DEFAULT_print_Top_footer
762 &$T2H_print_foot_navigation(@_);
763 &$T2H_print_page_foot(@_) if $T2H_SPLIT;
765 sub T2H_DEFAULT_print_Top
769 # for redefining navigation buttons use:
770 # local $T2H_BUTTONS = [...];
771 # as it is, 'Top', 'Contents', 'Index', 'About' are printed
772 local $T2H_BUTTONS = \
@T2H_MISC_BUTTONS;
773 &$T2H_print_Top_header($fh);
774 if ($T2H_THIS_SECTION)
776 # if top-level node has content, then print it with extra header
777 print $fh "<H1>$T2H_NAME{Top}</H1>"
778 unless ($T2H_HAS_TOP_HEADING);
779 t2h_print_lines
($fh, $T2H_THIS_SECTION)
783 # top-level node is fully enclosed in @ifnothtml
784 # print fulltitle, subtitle, author, Overview
787 join("</H1>\n<H1>", split(/\n/, $T2H_THISDOC{fulltitle
})) .
789 print $fh "<H2>$T2H_THISDOC{subtitle}</H2>\n" if $T2H_THISDOC{subtitle
};
790 print $fh "$T2H_THISDOC{author}\n" if $T2H_THISDOC{author
};
798 t2h_print_lines
($fh, $T2H_OVERVIEW);
799 print $fh "</BLOCKQUOTE>\n";
801 &$T2H_print_Top_footer($fh);
804 ###################################################################
805 # Layout of Toc, Overview, and Footnotes pages
806 # By default, we use "normal" layout
807 # T2H_HREF of Next, Prev, Up, Forward, Back, etc are not defined
808 # use: local $T2H_BUTTONS = [...] to redefine navigation buttons
809 sub T2H_DEFAULT_print_Toc
811 return &$T2H_print_misc(@_);
813 sub T2H_DEFAULT_print_Overview
815 return &$T2H_print_misc(@_);
817 sub T2H_DEFAULT_print_Footnotes
819 return &$T2H_print_misc(@_);
821 sub T2H_DEFAULT_print_About
823 return &$T2H_print_misc(@_);
826 sub T2H_DEFAULT_print_misc_header
828 &$T2H_print_page_head(@_) if $T2H_SPLIT;
829 # this needs to be called, otherwise, no labels are set
831 &$T2H_print_head_navigation(@_);
833 sub T2H_DEFAULT_print_misc_footer
835 &$T2H_print_foot_navigation(@_);
836 &$T2H_print_page_foot(@_) if $T2H_SPLIT;
838 sub T2H_DEFAULT_print_misc
841 local $T2H_BUTTONS = \
@T2H_MISC_BUTTONS;
842 &$T2H_print_misc_header($fh);
843 print $fh "<H1>$T2H_NAME{This}</H1>\n";
844 t2h_print_lines
($fh);
845 &$T2H_print_misc_footer($fh);
848 ###################################################################
849 # chapter_header and chapter_footer are only called if
850 # T2H_SPLIT eq 'chapter'
851 # chapter_header: after print_page_header, before print_section
852 # chapter_footer: after print_section of last section, before print_page_footer
854 # If you want to get rid of navigation stuff after each section,
855 # redefine print_section such that it does not call print_navigation,
856 # and put print_navigation into print_chapter_header
857 @T2H_CHAPTER_BUTTONS =
859 'FastBack', 'FastForward', ' ',
861 'Top', 'Contents', 'Index', 'About',
864 sub T2H_DEFAULT_print_chapter_header
866 # nothing to do there, by default
867 if (! $T2H_SECTION_NAVIGATION)
870 local $T2H_BUTTONS = \
@T2H_CHAPTER_BUTTONS;
871 &$T2H_print_navigation($fh);
872 print $fh "\n<HR SIZE=2>\n";
876 sub T2H_DEFAULT_print_chapter_footer
878 local $T2H_BUTTONS = \
@T2H_CHAPTER_BUTTONS;
879 &$T2H_print_navigation(@_);
881 ###################################################################
882 $T2H_TODAY = &pretty_date
; # like "20 September 1993"
885 local($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);
887 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
888 $year += ($year < 70) ?
2000 : 1900;
889 # obachman: Let's do it as the Americans do
890 return($MONTH_NAMES->{$T2H_LANG}[$mon] . ", " . $mday . " " . $year);
894 ###################################################################
895 # Layout of standard header and footer
898 # Set the default body text, inserted between <BODY ... >
899 ###$T2H_BODYTEXT = 'LANG="EN" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000"';
900 $T2H_BODYTEXT = 'LANG="' . $T2H_LANG . '" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000"';
901 # text inserted after <BODY ...>
902 $T2H_AFTER_BODY_OPEN = '';
903 #text inserted before </BODY>
904 $T2H_PRE_BODY_CLOSE = '';
905 # this is used in footer
906 $T2H_ADDRESS = "by <I>$T2H_USER</I> " if $T2H_USER;
907 $T2H_ADDRESS .= "on <I>$T2H_TODAY</I>";
908 # this is added inside <HEAD></HEAD> after <TITLE> and some META NAME stuff
909 # can be used for <style> <script>, <meta> tags
910 $T2H_EXTRA_HEAD = '';
912 sub T2H_DEFAULT_print_page_head
915 my $longtitle = "$T2H_THISDOC{title}: $T2H_NAME{This}";
919 <!-- Created on $T2H_TODAY by $THISPROG -->
924 <TITLE>$longtitle</TITLE>
926 <META NAME="description" CONTENT="$longtitle">
927 <META NAME="keywords" CONTENT="$longtitle">
928 <META NAME="resource-type" CONTENT="document">
929 <META NAME="distribution" CONTENT="global">
930 <META NAME="Generator" CONTENT="$THISPROG">
939 sub T2H_DEFAULT_print_page_foot
945 This document was generated
947 using <A HREF="$T2H_HOMEPAGE"><I>texi2html</I></A>
954 ###################################################################
955 # Layout of navigation panel
957 # if this is set, then a vertical navigation panel is used
958 $T2H_VERTICAL_HEAD_NAVIGATION = 0;
959 sub T2H_DEFAULT_print_head_navigation
962 if ($T2H_VERTICAL_HEAD_NAVIGATION)
965 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
970 &$T2H_print_navigation($fh, $T2H_VERTICAL_HEAD_NAVIGATION);
971 if ($T2H_VERTICAL_HEAD_NAVIGATION)
978 elsif ($T2H_SPLIT eq 'section')
980 print $fh "<HR SIZE=1>\n";
984 # Specifies the minimum page length required before a navigation panel
985 # is placed at the bottom of a page (the default is that of latex2html)
986 # T2H_THIS_WORDS_IN_PAGE holds number of words of current page
987 $T2H_WORDS_IN_PAGE = 300;
988 sub T2H_DEFAULT_print_foot_navigation
992 if ($T2H_VERTICAL_HEAD_NAVIGATION)
1000 print $fh "<HR SIZE=1>\n";
1001 &$T2H_print_navigation($fh) if ($nwords >= $T2H_WORDS_IN_PAGE)
1004 ######################################################################
1007 # specify in this array which "buttons" should appear in which order
1008 # in the navigation panel for sections; use ' ' for empty buttons (space)
1009 @T2H_SECTION_BUTTONS =
1011 'Back', 'Forward', ' ', 'FastBack', 'Up', 'FastForward',
1013 'Top', 'Contents', 'Index', 'About',
1016 # buttons for misc stuff
1017 @T2H_MISC_BUTTONS = ('Top', 'Contents', 'Index', 'About');
1019 # insert here name of icon images for buttons
1020 # Icons are used, if $T2H_ICONS and resp. value are set
1040 # insert here name of icon images for these, if button is inactive
1041 %T2H_PASSIVE_ICONS =
1059 # how to create IMG tag
1060 sub T2H_DEFAULT_button_icon_img
1065 return qq{<IMG SRC
="$icon" BORDER
="0" ALT
="$button: $name" ALIGN
="MIDDLE">};
1068 # Names of text as alternative for icons
1069 %T2H_NAVIGATION_TEXT =
1072 'Contents', 'Contents',
1073 'Overview', 'Overview',
1077 'FastBack', ' << ',
1081 'Forward', ' > ',
1082 'FastForward', ' >> ',
1088 sub T2H_DEFAULT_print_navigation
1091 my $vertical = shift;
1093 print $fh "<TABLE CELLPADDING=$spacing CELLSPACING=$spacing BORDER=0>\n";
1095 print $fh "<TR>" unless $vertical;
1096 for $button (@
$T2H_BUTTONS)
1098 print $fh qq{<TR VALIGN
="TOP" ALIGN
="LEFT">\n} if $vertical;
1099 print $fh qq{<TD VALIGN
="MIDDLE" ALIGN
="LEFT">};
1101 if (ref($button) eq 'CODE')
1103 &$button($fh, $vertical);
1105 elsif ($button eq ' ')
1106 { # handle space button
1108 $T2H_ICONS && $T2H_ACTIVE_ICONS{' '} ?
1109 &$T2H_button_icon_img($button, $T2H_ACTIVE_ICONS{' '}) :
1110 $T2H_NAVIGATION_TEXT{' '};
1113 elsif ($T2H_HREF{$button})
1114 { # button is active
1116 $T2H_ICONS && $T2H_ACTIVE_ICONS{$button} ?
# use icon ?
1117 t2h_anchor
('', $T2H_HREF{$button}, # yes
1118 &$T2H_button_icon_img($button,
1119 $T2H_ACTIVE_ICONS{$button},
1120 $T2H_NAME{$button}))
1123 t2h_anchor
('', $T2H_HREF{$button}, $T2H_NAVIGATION_TEXT{$button}) .
1127 { # button is passive
1129 $T2H_ICONS && $T2H_PASSIVE_ICONS{$button} ?
1130 &$T2H_button_icon_img($button,
1131 $T2H_PASSIVE_ICONS{$button},
1132 $T2H_NAME{$button}) :
1134 "[" . $T2H_NAVIGATION_TEXT{$button} . "]";
1136 print $fh "</TD>\n";
1137 print $fh "</TR>\n" if $vertical;
1139 print $fh "</TR>" unless $vertical;
1140 print $fh "</TABLE>\n";
1143 ######################################################################
1144 # Frames: this is from "Richard Y. Kim" <ryk@coho.net>
1145 # Should be improved to be more conforming to other _print* functions
1147 sub T2H_DEFAULT_print_frame
1152 <HEAD><TITLE>$T2H_THISDOC{title}</TITLE></HEAD>
1153 <FRAMESET cols="140,*">
1154 <FRAME name=toc src="$docu_toc_frame_file">
1155 <FRAME name=main src="$docu_doc">
1161 sub T2H_DEFAULT_print_toc_frame
1164 &$T2H_print_page_head($fh);
1168 print $fh map {s/HREF=/target=\"main\" HREF=/; $_;} @stoc_lines;
1169 print $fh "</BODY></HTML>\n";
1172 ######################################################################
1176 # T2H_PRE_ABOUT might be a function
1177 $T2H_PRE_ABOUT = <<EOT;
1178 This document was generated $T2H_ADDRESS
1179 using <A HREF="$T2H_HOMEPAGE"><I>texi2html</I></A>
1182 $T2H_AFTER_ABOUT = '';
1184 sub T2H_DEFAULT_about_body
1187 if (ref($T2H_PRE_ABOUT) eq 'CODE')
1189 $about = &$T2H_PRE_ABOUT();
1193 $about = $T2H_PRE_ABOUT;
1196 The buttons in the navigation panels have the following meaning:
1198 <table border = "1">
1203 <TH> From 1.2.3 go to</TH>
1207 for $button (@T2H_SECTION_BUTTONS)
1209 next if $button eq ' ' || ref($button) eq 'CODE';
1215 ($T2H_ICONS && $T2H_ACTIVE_ICONS{$button} ?
1216 &$T2H_button_icon_img($button, $T2H_ACTIVE_ICONS{$button}) :
1217 " [" . $T2H_NAVIGATION_TEXT{$button} . "] ");
1224 $T2H_BUTTONS_GOTO{$button}
1227 $T2H_BUTTONS_EXAMPLE{$button}
1236 where the <STRONG> Example </STRONG> assumes that the current position
1237 is at <STRONG> Subsubsection One-Two-Three </STRONG> of a document of
1238 the following structure:
1240 <LI> 1. Section One </LI>
1242 <LI>1.1 Subsection One-One</LI>
1246 <LI>1.2 Subsection One-Two</LI>
1248 <LI>1.2.1 Subsubsection One-Two-One
1249 </LI><LI>1.2.2 Subsubsection One-Two-Two
1250 </LI><LI>1.2.3 Subsubsection One-Two-Three <STRONG>
1251 <== Current Position </STRONG>
1252 </LI><LI>1.2.4 Subsubsection One-Two-Four
1254 <LI>1.3 Subsection One-Three</LI>
1258 <LI>1.4 Subsection One-Four</LI>
1269 'Top', 'cover (top) of document',
1270 'Contents', 'table of contents',
1271 'Overview', 'short table of contents',
1272 'Index', 'concept index',
1273 'Back', 'previous section in reading order',
1274 'FastBack', 'previous or up-and-previous section ',
1275 'Prev', 'previous section same level',
1277 'Next', 'next section same level',
1278 'Forward', 'next section in reading order',
1279 'FastForward', 'next or up-and-next section',
1280 'About' , 'this page',
1281 'First', 'first section in reading order',
1282 'Last', 'last section in reading order',
1285 %T2H_BUTTONS_EXAMPLE =
1288 'Contents', ' ',
1289 'Overview', ' ',
1290 'Index', ' ',
1297 'FastForward', '1.3',
1298 'About', ' ',
1304 ######################################################################
1305 # from here on, its l2h init stuff
1308 ## initialization for latex2html as for Singular manual generation
1312 # Options controlling Titles, File-Names, Tracing and Sectioning
1320 $DESTDIR = ''; # should be overwritten by cmd-line argument
1322 $NO_SUBDIR = 0;# should be overwritten by cmd-line argument
1324 $PREFIX = ''; # should be overwritten by cmd-line argument
1326 $AUTO_PREFIX = 0; # this is needed, so that prefix settings are used
1332 $MAX_LINK_DEPTH = 0;
1334 $TMP = ''; # should be overwritten by cmd-line argument
1341 # Options controlling Extensions and Special Features
1343 $HTML_VERSION = "3.2";
1345 $TEXDEFS = 1; # we absolutely need that
1347 $EXTERNAL_FILE = '';
1349 $SCALABLE_FONTS = 1;
1351 $NO_SIMPLE_MATH = 1;
1364 # Switches controlling Image Generation
1370 $EXTERNAL_IMAGES = 0;
1382 $ANTI_ALIAS_TEXT = 1;
1385 #Switches controlling Navigation Panels
1389 $INFO = 0; # 0 = do not make a "About this document..." section
1392 #Switches for Linking to other documents
1394 # actuall -- we don't care
1396 $MAX_SPLIT_DEPTH = 0; # Stop making separate files at this depth
1398 $MAX_LINK_DEPTH = 0; # Stop showing child nodes at this depth
1400 $NOLATEX = 0; # 1 = do not pass unknown environments to Latex
1402 $EXTERNAL_IMAGES = 0; # 1 = leave the images outside the document
1404 $ASCII_MODE = 0; # 1 = do not use any icons or internal images
1406 # 1 = use links to external postscript images rather than inlined bitmap
1409 $SHOW_SECTION_NUMBERS = 0;
1411 ### Other global variables ###############################################
1414 # This is the line width measured in pixels and it is used to right justify
1415 # equations and equation arrays;
1418 # Used in conjunction with AUTO_NAVIGATION
1419 $WORDS_IN_PAGE = 300;
1421 # Affects ONLY the way accents are processed
1422 $default_language = 'english';
1424 # The value of this variable determines how many words to use in each
1425 # title that is added to the navigation panel (see below)
1427 $WORDS_IN_NAVIGATION_PANEL_TITLES = 0;
1429 # This number will determine the size of the equations, special characters,
1430 # and anything which will be converted into an inlined image
1431 # *except* "image generating environments" such as "figure", "table"
1433 # Effective values are those greater than 0.
1434 # Sensible values are between 0.1 - 4.
1435 $MATH_SCALE_FACTOR = 1.5;
1437 # This number will determine the size of
1438 # image generating environments such as "figure", "table" or "minipage".
1439 # Effective values are those greater than 0.
1440 # Sensible values are between 0.1 - 4.
1441 $FIGURE_SCALE_FACTOR = 1.6;
1444 # If both of the following two variables are set then the "Up" button
1445 # of the navigation panel in the first node/page of a converted document
1446 # will point to $EXTERNAL_UP_LINK. $EXTERNAL_UP_TITLE should be set
1447 # to some text which describes this external link.
1448 $EXTERNAL_UP_LINK = "";
1449 $EXTERNAL_UP_TITLE = "";
1451 # If this is set then the resulting HTML will look marginally better if viewed
1455 # Valid paper sizes are "letter", "legal", "a4","a3","a2" and "a0"
1456 # Paper sizes has no effect other than in the time it takes to create inlined
1457 # images and in whether large images can be created at all ie
1458 # - larger paper sizes *MAY* help with large image problems
1459 # - smaller paper sizes are quicker to handle
1462 # Replace "english" with another language in order to tell LaTeX2HTML that you
1463 # want some generated section titles (eg "Table of Contents" or "References")
1464 # to appear in a different language. Currently only "english" and "french"
1465 # is supported but it is very easy to add your own. See the example in the
1466 # file "latex2html.config"
1467 $TITLES_LANGUAGE = "english";
1469 1; # This must be the last non-comment line
1471 # End File texi2html.init
1472 ######################################################################
1475 require "$ENV{T2H_HOME}/texi2html.init"
1476 if ($0 =~ /\.pl$/ &&
1477 -e
"$ENV{T2H_HOME}/texi2html.init" && -r
"$ENV{T2H_HOME}/texi2html.init");
1479 #+++############################################################################
1482 # Pasted content of File $(srcdir)/MySimple.pm: Command-line processing #
1484 #---############################################################################
1486 # leave this within comments, and keep the require statement
1487 # This way, you can directly run texi2html.pl, if $ENV{T2H_HOME}/texi2html.init
1491 package Getopt
::MySimple
;
1497 # POD-style (incomplete) documentation is in file MySimple.pod
1503 # Ron Savage rpsavage@ozemail.com.au.
1504 # 1.00 19-Aug-97 Initial version.
1505 # 1.10 13-Oct-97 Add arrays of switches (eg '=s@').
1506 # 1.20 3-Dec-97 Add 'Help' on a per-switch basis.
1507 # 1.30 11-Dec-97 Change 'Help' to 'verbose'. Make all hash keys lowercase.
1508 # 1.40 10-Nov-98 Change width of help report. Restructure tests.
1509 # 1-Jul-00 Modifications for Texi2html
1511 # --------------------------------------------------------------------------
1512 # Locally modified by obachman (Display type instead of env, order by cmp)
1518 use vars
qw(@EXPORT @EXPORT_OK @ISA);
1519 use vars qw($fieldWidth $opt $VERSION);
1524 @ISA = qw(Exporter);
1526 @EXPORT_OK = qw($opt); # An alias for $self -> {'opt'}.
1528 # --------------------------------------------------------------------------
1533 # --------------------------------------------------------------------------
1539 return uc($a) cmp (uc($b));
1542 # --------------------------------------------------------------------------
1548 print 'Option', ' ' x ($fieldWidth - length('Option') ), "Value\n";
1550 for (sort byOrder keys(%{$self -> {'opt'} }) )
1552 print "-$_", ' ' x ($fieldWidth - (1 + length) ), "${$self->{'opt'} }{$_}\n";
1557 } # End of dumpOptions.
1559 # --------------------------------------------------------------------------
1566 push(@_, 0) if ($#_ == 2); # Default for $ignoreCase is 0.
1567 push(@_, 1) if ($#_ == 3); # Default for $helpThenExit is 1.
1569 my($self, $default, $helpText, $versionText,
1570 $helpThenExit, $versionThenExit, $ignoreCase) = @_;
1572 $helpThenExit = 1 unless (defined($helpThenExit));
1573 $versionThenExit = 1 unless (defined($versionThenExit));
1574 $ignoreCase = 0 unless (defined($ignoreCase));
1576 $self -> {'default'} = $default;
1577 $self -> {'helpText'} = $helpText;
1578 $self -> {'versionText'} = $versionText;
1579 $Getopt::Long::ignorecase = $ignoreCase;
1581 unless (defined($self -> {'default'}{'help'}))
1583 $self -> {'default'}{'help'} =
1587 linkage => sub {$self->helpOptions($_[1]); exit (0) if $helpThenExit;},
1588 verbose => "print help and exit"
1592 unless (defined($self -> {'default'}{'version'}))
1594 $self -> {'default'}{'version'} =
1598 linkage => sub {print $self->{'versionText'}; exit (0) if versionTheExit;},
1599 verbose => "print version and exit"
1603 for (keys(%{$self -> {'default'} }) )
1605 my $type = ${$self -> {'default'} }{$_}{'type'};
1606 push(@{$self -> {'type'} }, "$_$type");
1607 $self->{'opt'}->{$_} = ${$self -> {'default'} }{$_}{'linkage'}
1608 if ${$self -> {'default'} }{$_}{'linkage'};
1611 my($result) = &GetOptions($self -> {'opt'}, @{$self -> {'type'} });
1613 return $result unless $result;
1615 for (keys(%{$self -> {'default'} }) )
1617 if (! defined(${$self -> {'opt'} }{$_})) #{
1619 ${$self -> {'opt'} }{$_} = ${$self -> {'default'} }{$_}{'default'};
1624 } # End of getOptions.
1626 # --------------------------------------------------------------------------
1631 my($noHelp) = shift;
1632 $noHelp = 0 unless $noHelp;
1633 my($optwidth, $typewidth, $defaultwidth, $maxlinewidth, $valind, $valwidth)
1634 = (10, 5, 9, 78, 4, 11);
1636 print "$self->{'helpText'}" if ($self -> {'helpText'});
1638 print ' Option', ' ' x ($optwidth - length('Option') -1 ),
1639 'Type', ' ' x ($typewidth - length('Type') + 1),
1640 'Default', ' ' x ($defaultwidth - length('Default') ),
1643 for (sort byOrder keys(%{$self -> {'default'} }) )
1645 my($line, $help, $option, $val);
1647 next if ${$self->{'default'} }{$_}{'noHelp'} && ${$self->{'default'} }{$_}{'noHelp'} > $noHelp;
1648 $line = " -$_ " . ' ' x ($optwidth - (2 + length) ) .
1649 "${$self->{'default'} }{$_}{'type'} ".
1650 ' ' x ($typewidth - (1+length(${$self -> {'default'} }{$_}{'type'}) ));
1652 $val = ${$self->{'default'} }{$_}{'linkage'};
1655 if (ref($val) eq 'SCALAR')
1666 $val = ${$self->{'default'} }{$_}{'default'};
1669 $line .= ' ' x ($optwidth + $typewidth + $defaultwidth + 1 - length($line));
1671 if (defined(${$self -> {'default'} }{$_}{'verbose'}) &&
1672 ${$self -> {'default'} }{$_}{'verbose'} ne '')
1674 $help = "${$self->{'default'} }{$_}{'verbose'}";
1680 if ((length("$line") + length($help)) < $maxlinewidth)
1682 print $line , $help, "\n";
1686 print $line, "\n", ' ' x $valind, $help, "\n";
1688 for $val (sort byOrder keys(%{${$self->{'default'}}{$option}{'values'}}))
1690 print ' ' x ($valind + 2);
1691 print $val, ' ', ' ' x ($valwidth - length($val) - 2);
1692 print ${$self->{'default'}}{$option}{'values'}{$val}, "\n";
1697 Note: 'Options' may be abbreviated. 'Type' specifications mean:
1698 <none>| ! no argument: variable is set to 1 on -foo (or, to 0 on -nofoo)
1699 =s | :s mandatory (or, optional) string argument
1700 =i | :i mandatory (or, optional) integer argument
1702 } # End of helpOptions.
1704 #-------------------------------------------------------------------
1710 $self -> {'default'} = {};
1711 $self -> {'helpText'} = '';
1712 $self -> {'opt'} = {};
1713 $opt = $self -> {'opt'}; # An alias for $self -> {'opt'}.
1714 $self -> {'type'} = ();
1716 return bless $self, $class;
1720 # --------------------------------------------------------------------------
1726 require "$ENV{T2H_HOME}/MySimple.pm"
1727 if ($0 =~ /\.pl$/ &&
1728 -e
"$ENV{T2H_HOME}/texi2html.init" && -r
"$ENV{T2H_HOME}/texi2html.init");
1732 #+++############################################################################
1736 #---############################################################################
1748 $BIBRE = '\[[\w\/-]+\]'; # RE for a bibliography reference
1749 $FILERE = '[\/\w.+-]+'; # RE for a file name
1750 $VARRE = '[^\s\{\}]+'; # RE for a variable name
1751 $NODERE = '[^,:]+'; # RE for a node name
1752 $NODESRE = '[^:]+'; # RE for a list of node names
1754 $ERROR = "***"; # prefix for errors
1755 $WARN = "**"; # prefix for warnings
1758 $PROTECTTAG = "_ThisIsProtected_"; # tag to recognize protected sections
1760 $CHAPTEREND = "<!-- End chapter -->\n"; # to know where a chpater ends
1761 $SECTIONEND = "<!-- End section -->\n"; # to know where section ends
1762 $TOPEND = "<!-- End top -->\n"; # to know where top ends
1767 # pre-defined indices
1771 'c' => { name
=> 'cp'},
1772 'f' => { name
=> 'fn', code
=> 1},
1773 'v' => { name
=> 'vr', code
=> 1},
1774 'k' => { name
=> 'ky', code
=> 1},
1775 'p' => { name
=> 'pg', code
=> 1},
1776 't' => { name
=> 'tp', code
=> 1}
1780 %predefined_index = (
1802 # texinfo section names to level
1815 'appendixsection', 2,
1817 'unnumberedsubsec', 3,
1819 'appendixsubsec', 3,
1821 'unnumberedsubsubsec', 4,
1823 'appendixsubsubsec', 4,
1827 # accent map, TeX command to ISO name
1838 # texinfo "simple things" (@foo) to HTML ones
1842 "*", "<BR>", # HTML+
1845 "-", "­", # soft hyphen
1848 'tab', '<\/TD><TD>',
1858 # texinfo "things" (@foo{}) to HTML ones
1862 'br', '<P>', # paragraph break
1865 'dots', '<small>...<\/small>',
1866 'enddots', '<small>....<\/small>',
1868 'error', 'error-->',
1874 'today', $T2H_TODAY,
1886 'exclamdown', '¡',
1887 'questiondown', '¿',
1892 # texinfo styles (@foo{bar}) to HTML ones
1895 'acronym', '&do_acronym',
1901 'ctrl', '&do_ctrl', # special case
1902 'dfn', 'EM', # DFN tag is illegal in the standard
1903 'dmn', '', # useless
1904 'email', '&do_email', # insert a clickable email address
1907 'file', '"TT', # will put quotes, cf. &apply_style
1912 'option', '"SAMP', # will put quotes, cf. &apply_style
1913 'r', '', # unsupported
1914 'samp', '"SAMP', # will put quotes, cf. &apply_style
1915 'sc', '&do_sc', # special case
1918 'titlefont', '', # useless
1919 'uref', '&do_uref', # insert a clickable URL
1920 'url', '&do_url', # insert a clickable URL
1922 'w', '', # unsupported
1924 'dotaccent', '&do_accent',
1925 'ringaccent','&do_accent',
1926 'tieaccent', '&do_accent',
1928 'ubaraccent','&do_accent',
1929 'udotaccent','&do_accent',
1932 'dotless', '&do_accent'
1936 # texinfo format (@foo/@end foo) to HTML ones
1939 'quotation', 'BLOCKQUOTE',
1945 'flushright', 'PRE',
1949 # an eval of these $complex_format_map->{what}->[0] yields beginning
1950 # an eval of these $complex_format_map->{what}->[1] yieleds end
1951 $complex_format_map =
1955 q{"<TABLE><tr>$T2H_EXAMPLE_INDENT_CELL<td class=example><pre>"},
1956 q{'</pre></td></tr></table>'}
1960 q{"<TABLE><tr>$T2H_SMALL_EXAMPLE_INDENT_CELL<td class=smallexample><FONT SIZE=$T2H_SMALL_FONT_SIZE><pre>"},
1961 q{'</FONT></pre></td></tr></table>'}
1965 q{"<TABLE><tr>$T2H_EXAMPLE_INDENT_CELL<td class=display><pre " . 'style="font-family: serif">'},
1966 q{'</pre></td></tr></table>'}
1970 q{"<TABLE><tr>$T2H_SMALL_EXAMPLE_INDENT_CELL<td class=smalldisplay><FONT SIZE=$T2H_SMALL_FONT_SIZE><pre " . 'style="font-family: serif">'},
1971 q{'</pre></FONT></td></tr></table>'}
1975 $complex_format_map->{lisp
} = $complex_format_map->{example
};
1976 $complex_format_map->{smalllisp
} = $complex_format_map->{smallexample
};
1977 $complex_format_map->{format
} = $complex_format_map->{display
};
1978 $complex_format_map->{smallformat
} = $complex_format_map->{smalldisplay
};
1981 # texinfo definition shortcuts to real ones
2001 'defun', 'deffn Function',
2002 'defmac', 'deffn Macro',
2003 'defspec', 'deffn {Special Form}',
2004 'defvar', 'defvr Variable',
2005 'defopt', 'defvr {User Option}',
2006 'deftypefun', 'deftypefn Function',
2007 'deftypevar', 'deftypevr Variable',
2008 'defivar', 'defcv {Instance Variable}',
2009 'deftypeivar', 'defcv {Instance Variable}', # NEW: FIXME
2010 'defmethod', 'defop Method',
2011 'deftypemethod', 'defop Method', # NEW:FIXME
2013 'defunx', 'deffnx Function',
2014 'defmacx', 'deffnx Macro',
2015 'defspecx', 'deffnx {Special Form}',
2016 'defvarx', 'defvrx Variable',
2017 'defoptx', 'defvrx {User Option}',
2018 'deftypefunx', 'deftypefnx Function',
2019 'deftypevarx', 'deftypevrx Variable',
2020 'defivarx', 'defcvx {Instance Variable}',
2021 'defmethodx', 'defopx Method',
2042 'summarycontents', 1,
2048 # unsupported commands (formatting)
2056 'setchapternewpage', 1,
2066 'paragraphindent', 1,
2067 # unsupported formats
2074 #+++############################################################################
2076 # Argument parsing, initialisation #
2078 #---############################################################################
2081 # flush stdout and stderr after every write
2089 %value = (); # hold texinfo variables, see also -D
2090 $use_bibliography = 1;
2094 # called on -init-file
2097 my $init_file = shift;
2098 # second argument is value of options
2102 print "# reading initialization file from $init_file\n"
2104 require($init_file);
2108 print "$ERROR Error: can't read init file $int_file\n";
2115 sub SetDocumentLanguage
2118 if (! exists($T2H_WORDS->{$lang}))
2120 warn "$ERROR: Language specs for '$lang' do not exists. Reverting to '" .
2121 ($T2H_LANG ? T2H_LANG
: "en") . "'\n";
2125 print "# using '$lang' as document language\n" if ($T2H_VERBOSE);
2131 ## obsolete cmd line options
2133 $T2H_OBSOLETE_OPTIONS -> {'no-section_navigation'} =
2136 linkage
=> sub {$main::T2H_SECTION_NAVIGATION
= 0;},
2137 verbose
=> 'obsolete, use -nosec_nav',
2140 $T2H_OBSOLETE_OPTIONS -> {use_acc
} =
2143 linkage
=> \
$use_acc,
2144 verbose
=> 'obsolete',
2147 $T2H_OBSOLETE_OPTIONS -> {expandinfo
} =
2150 linkage
=> sub {$main::T2H_EXPAND
= 'info';},
2151 verbose
=> 'obsolete, use "-expand info" instead',
2154 $T2H_OBSOLETE_OPTIONS -> {expandtex
} =
2157 linkage
=> sub {$main::T2H_EXPAND
= 'tex';},
2158 verbose
=> 'obsolete, use "-expand tex" instead',
2161 $T2H_OBSOLETE_OPTIONS -> {monolithic
} =
2164 linkage
=> sub {$main::T2H_SPLIT
= '';},
2165 verbose
=> 'obsolete, use "-split no" instead',
2168 $T2H_OBSOLETE_OPTIONS -> {split_node
} =
2171 linkage
=> sub{$main::T2H_SPLIT
= 'section';},
2172 verbose
=> 'obsolete, use "-split section" instead',
2175 $T2H_OBSOLETE_OPTIONS -> {split_chapter
} =
2178 linkage
=> sub{$main::T2H_SPLIT
= 'chapter';},
2179 verbose
=> 'obsolete, use "-split chapter" instead',
2182 $T2H_OBSOLETE_OPTIONS -> {no_verbose
} =
2185 linkage
=> sub {$main::T2H_VERBOSE
= 0;},
2186 verbose
=> 'obsolete, use -noverbose instead',
2189 $T2H_OBSOLETE_OPTIONS -> {output_file
} =
2192 linkage
=> sub {$main::T2H_OUT
= @_[1]; $T2H_SPLIT = '';},
2193 verbose
=> 'obsolete, use -out_file instead',
2197 $T2H_OBSOLETE_OPTIONS -> {section_navigation
} =
2200 linkage
=> \
$T2H_SECTION_NAVIGATION,
2201 verbose
=> 'obsolete, use -sec_nav instead',
2205 $T2H_OBSOLETE_OPTIONS -> {verbose
} =
2208 linkage
=> \
$T2H_VERBOSE,
2209 verbose
=> 'obsolete, use -Verbose instead',
2213 # read initialzation from $sysconfdir/texi2htmlrc or $HOME/.texi2htmlrc
2214 my $home = $ENV{HOME
};
2215 defined($home) or $home = '';
2216 foreach $i ('/usr/local/etc/texi2htmlrc', "$home/.texi2htmlrc") {
2218 print "# reading initialization file from $i\n"
2225 #+++############################################################################
2227 # parse command-line options
2229 #---############################################################################
2230 $T2H_USAGE_TEXT = <<EOT;
2231 Usage: texi2html [OPTIONS] TEXINFO-FILE
2232 Translates Texinfo source documentation to HTML.
2234 $T2H_FAILURE_TEXT = <<EOT;
2235 Try 'texi2html -help' for usage instructions.
2237 $options = new Getopt
::MySimple
;
2239 # some older version of GetOpt::Long don't have
2240 # Getopt::Long::Configure("pass_through")
2241 eval {Getopt
::Long
::Configure
("pass_through");};
2242 $Configure_failed = $@
&& <<EOT;
2243 **WARNING: Parsing of obsolete command-line options could have failed.
2244 Consider to use only documented command-line options (run
2245 'texi2html -help 2' for a complete list) or upgrade to perl
2246 version 5.005 or higher.
2249 if (! $options->getOptions($T2H_OPTIONS, $T2H_USAGE_TEXT, "$THISVERSION\n"))
2251 print $Configure_failed if $Configure_failed;
2252 die $T2H_FAILURE_TEXT;
2257 eval {Getopt
::Long
::Configure
("no_pass_through");};
2258 if (! $options->getOptions($T2H_OBSOLETE_OPTIONS, $T2H_USAGE_TEXT, "$THISVERSION\n"))
2260 print $Configure_failed if $Configure_failed;
2261 die $T2H_FAILURE_TEXT;
2266 die "Need file to check\n$T2H_FAILURE_TEXT" unless @ARGV > 0;
2271 #+++############################################################################
2273 # evaluation of cmd line options
2275 #---############################################################################
2277 if ($T2H_EXPAND eq 'info')
2279 $to_skip{'ifinfo'} = 1;
2280 $to_skip{'end ifinfo'} = 1;
2282 elsif ($T2H_EXPAND eq 'tex')
2284 $to_skip{'iftex'} = 1;
2285 $to_skip{'end iftex'} = 1;
2289 $T2H_INVISIBLE_MARK = '<IMG SRC="invisible.xbm">' if $T2H_INVISIBLE_MARK eq 'xbm';
2292 # file name buisness
2294 die "Need exactly one file to translate\n$T2H_FAILURE_TEXT" unless @ARGV == 1;
2295 $docu = shift(@ARGV);
2296 if ($docu =~ /.*\//) {
2297 chop($docu_dir = $&);
2303 unshift(@T2H_INCLUDE_DIRS, $docu_dir);
2304 $docu_name =~ s/\.te?x(i|info)?$//; # basename of the document
2305 $docu_name = $T2H_PREFIX if ($T2H_PREFIX);
2308 if ($T2H_SUBDIR && ! $T2H_OUT)
2310 $T2H_SUBDIR =~ s|/*$||;
2311 unless (-d "$T2H_SUBDIR" && -w "$T2H_SUBDIR")
2313 if ( mkdir($T2H_SUBDIR, oct(755)))
2315 print "# created directory $T2H_SUBDIR\n" if ($T2H_VERBOSE);
2319 warn "$ERROR can't create directory
$T2H_SUBDIR. Put results into current directory
\n";
2325 if ($T2H_SUBDIR && ! $T2H_OUT)
2327 $docu_rdir = "$T2H_SUBDIR/";
2328 print "# putting result files into directory $docu_rdir\n" if ($T2H_VERBOSE);
2332 if ($T2H_OUT && $T2H_OUT =~ m
|(.*)/|)
2335 print "# putting result files into directory $docu_rdir\n" if ($T2H_VERBOSE);
2339 print "# putting result files into current directory \n" if ($T2H_VERBOSE);
2353 if ($T2H_TOP_FILE =~ /\..*$/)
2355 $T2H_TOP_FILE = $`.".$docu_ext";
2359 if (! $T2H_OUT && ($T2H_SPLIT =~ /section/i || $T2H_SPLIT =~ /node/i))
2361 $T2H_SPLIT = 'section';
2363 elsif (! $T2H_OUT && $T2H_SPLIT =~ /chapter/i)
2365 $T2H_SPLIT = 'chapter'
2372 $docu_doc = "$docu_name.$docu_ext"; # document's contents
2373 $docu_doc_file = "$docu_rdir$docu_doc";
2376 $docu_toc = $T2H_TOC_FILE || "${docu_name}_toc.$docu_ext"; # document's table of contents
2377 $docu_stoc = "${docu_name}_ovr.$docu_ext"; # document's short toc
2378 $docu_foot = "${docu_name}_fot.$docu_ext"; # document's footnotes
2379 $docu_about = "${docu_name}_abt.$docu_ext"; # about this document
2380 $docu_top = $T2H_TOP_FILE || $docu_doc;
2386 $docu_doc = $T2H_OUT;
2387 $docu_doc =~ s|.*/||;
2389 $docu_toc = $docu_foot = $docu_stoc = $docu_about = $docu_top = $docu_doc;
2392 $docu_toc_file = "$docu_rdir$docu_toc";
2393 $docu_stoc_file = "$docu_rdir$docu_stoc";
2394 $docu_foot_file = "$docu_rdir$docu_foot";
2395 $docu_about_file = "$docu_rdir$docu_about";
2396 $docu_top_file = "$docu_rdir$docu_top";
2398 $docu_frame_file = "$docu_rdir${docu_name}_frame.$docu_ext";
2399 $docu_toc_frame_file = "$docu_rdir${docu_name}_toc_frame.$docu_ext";
2404 $value{'html'} = 1; # predefine html (the output format)
2405 $value{'texi2html'} = $THISVERSION; # predefine texi2html (the translator)
2406 # _foo: internal to track @foo
2407 foreach ('_author', '_title', '_subtitle',
2408 '_settitle', '_setfilename', '_shorttitle') {
2409 $value{$_} = ''; # prevent -w warnings
2411 %node2sec = (); # node to section name
2412 %sec2node = (); # section to node name
2413 %sec2number = (); # section to number
2414 %number2sec = (); # number to section
2415 %idx2node = (); # index keys to node
2416 %node2href = (); # node to HREF
2417 %node2next = (); # node to next
2418 %node2prev = (); # node to prev
2419 %node2up = (); # node to up
2420 %bib2href = (); # bibliography reference to HREF
2421 %gloss2href = (); # glossary term to HREF
2422 @sections = (); # list of sections
2423 %tag2pro = (); # protected sections
2437 # can I use ISO8879 characters? (HTML+)
2440 $things_map{'bullet'} = "•";
2441 $things_map{'copyright'} = "©";
2442 $things_map{'dots'} = "…";
2443 $things_map{'equiv'} = "≡";
2444 $things_map{'expansion'} = "→";
2445 $things_map{'point'} = "∗";
2446 $things_map{'result'} = "⇒";
2450 # read texi2html extensions (if any)
2452 $extensions = 'texi2html.ext'; # extensions in working directory
2453 if (-f $extensions) {
2454 print "# reading extensions from $extensions\n" if $T2H_VERBOSE;
2455 require($extensions);
2457 ($progdir = $0) =~ s/[^\/]+$//;
2458 if ($progdir && ($progdir ne './')) {
2459 $extensions = "${progdir}texi2html.ext"; # extensions in texi2html directory
2460 if (-f $extensions) {
2461 print "# reading extensions from $extensions\n" if $T2H_VERBOSE;
2462 require($extensions);
2467 print "# reading from $docu\n" if $T2H_VERBOSE;
2469 #########################################################################
2473 # latex2html conversions consist of three stages:
2474 # 1) ToLatex: Put "latex" code into a latex file
2475 # 2) ToHtml: Use latex2html to generate corresponding html code and images
2476 # 3) FromHtml: Extract generated code and images from latex2html run
2479 ##########################
2483 # defaults for files and names
2489 return 0 unless ($root);
2491 $l2h_name = "${root}_l2h";
2493 $l2h_latex_file = "$docu_rdir${l2h_name}.tex";
2494 $l2h_cache_file = "${docu_rdir}l2h_cache.pm";
2495 $T2H_L2H_L2H = "latex2html" unless ($T2H_L2H_L2H);
2497 # destination dir -- generated images are put there, should be the same
2498 # as dir of enclosing html document --
2499 $l2h_html_file = "$docu_rdir${l2h_name}.html";
2500 $l2h_prefix = "${l2h_name}_";
2505 ##########################
2507 # First stage: Generation of Latex file
2508 # Initialize with: l2h_InitToLatex
2509 # Add content with: l2h_ToLatex($text) --> HTML placeholder comment
2510 # Finish with: l2h_FinishToLatex
2513 $l2h_latex_preample = <<EOT;
2514 % This document was automatically generated by the l2h extenstion of texi2html
2516 \\documentclass{article}
2521 $l2h_latex_closing = <<EOT;
2525 # return used latex 1, if l2h could be initalized properly, 0 otherwise
2529 unless ($T2H_L2H_SKIP)
2531 unless (open(L2H_LATEX
, ">$l2h_latex_file"))
2533 warn "$ERROR Error l2h: Can't open latex file '$latex_file' for writing\n";
2536 print "# l2h: use ${l2h_latex_file} as latex file\n" if ($T2H_VERBOSE);
2537 print L2H_LATEX
$l2h_latex_preample;
2539 # open database for caching
2541 $l2h_latex_count = 0;
2542 $l2h_to_latex_count = 0;
2543 $l2h_cached_count = 0;
2547 # print text (1st arg) into latex file (if not already there), return
2548 # HTML commentary which can be later on replaced by the latex2html
2555 $l2h_to_latex_count++;
2556 $text =~ s/(\s*)$//;
2558 # try whether we can cache it
2559 my $cached_text = l2h_FromCache
($text);
2562 $l2h_cached_count++;
2563 return $cached_text;
2566 # try whether we have text already on things to do
2567 unless ($count = $l2h_to_latex{$text})
2569 $count = $l2h_latex_count;
2571 $l2h_to_latex{$text} = $count;
2572 $l2h_to_latex[$count] = $text;
2573 unless ($T2H_L2H_SKIP)
2575 print L2H_LATEX
"\\begin{rawhtml}\n";
2576 print L2H_LATEX
"<!-- l2h_begin ${l2h_name} ${count} -->\n";
2577 print L2H_LATEX
"\\end{rawhtml}\n";
2579 print L2H_LATEX
"$text\n";
2581 print L2H_LATEX
"\\begin{rawhtml}\n";
2582 print L2H_LATEX
"<!-- l2h_end ${l2h_name} ${count} -->\n";
2583 print L2H_LATEX
"\\end{rawhtml}\n";
2586 return "<!-- l2h_replace ${l2h_name} ${count} -->";
2589 # print closing into latex file and close it
2590 sub l2h_FinishToLatex
2594 $reused = $l2h_to_latex_count - $l2h_latex_count - $l2h_cached_count;
2595 unless ($T2H_L2H_SKIP)
2597 print L2H_LATEX
$l2h_latex_closing;
2600 print "# l2h: finished to latex ($l2h_cached_count cached, $reused reused, $l2h_latex_count contents)\n" if ($T2H_VERBOSE);
2601 unless ($l2h_latex_count)
2609 ###################################
2610 # Second stage: Use latex2html to generate corresponding html code and images
2612 # l2h_ToHtml([$l2h_latex_file, [$l2h_html_dir]]):
2613 # Call latex2html on $l2h_latex_file
2614 # Put images (prefixed with $l2h_name."_") and html file(s) in $l2h_html_dir
2615 # Return 1, on success
2620 local($call, $ext, $root, $dotbug);
2624 print "# l2h: skipping latex2html run\n" if ($T2H_VERBOSE);
2628 # Check for dot in directory where dvips will work
2631 if ($T2H_L2H_TMP =~ /\./)
2633 warn "$ERROR Warning l2h: l2h_tmp dir contains a dot. Use /tmp, instead\n";
2639 if (&getcwd
=~ /\./)
2641 warn "$ERROR Warning l2h: current dir contains a dot. Use /tmp as l2h_tmp dir \n";
2645 # fix it, if necessary and hope that it works
2646 $T2H_L2H_TMP = "/tmp" if ($dotbug);
2648 $call = $T2H_L2H_L2H;
2649 # use init file, if specified
2650 $call = $call . " -init_file " . $init_file if ($init_file && -f
$init_file);
2652 $call .= ($docu_rdir ?
" -dir $docu_rdir" : " -no_subdir");
2653 # use l2h_tmp, if specified
2654 $call = $call . " -tmp $T2H_L2H_TMP" if ($T2H_L2H_TMP);
2655 # options we want to be sure of
2656 $call = $call ." -address 0 -info 0 -split 0 -no_navigation -no_auto_link";
2657 $call = $call ." -prefix ${l2h_prefix} $l2h_latex_file";
2659 print "# l2h: executing '$call'\n" if ($T2H_VERBOSE);
2662 warn "l2h ***Error: '${call}' did not succeed\n";
2667 print "# l2h: latex2html finished successfully\n" if ($T2H_VERBOSE);
2672 # this is directly pasted over from latex2html
2676 die "'pwd' failed (out of memory?)\n"
2683 ##########################
2684 # Third stage: Extract generated contents from latex2html run
2685 # Initialize with: l2h_InitFromHtml
2686 # open $l2h_html_file for reading
2687 # reads in contents into array indexed by numbers
2688 # return 1, on success -- 0, otherwise
2689 # Extract Html code with: l2h_FromHtml($text)
2690 # replaces in $text all previosuly inserted comments by generated html code
2691 # returns (possibly changed) $text
2692 # Finish with: l2h_FinishFromHtml
2693 # closes $l2h_html_dir/$l2h_name.".$docu_ext"
2695 sub l2h_InitFromHtml
2697 local($h_line, $h_content, $count, %l2h_img);
2699 if (! open(L2H_HTML
, "<${l2h_html_file}"))
2701 print "$ERROR Error l2h: Can't open ${l2h_html_file} for reading\n";
2704 print "# l2h: use ${l2h_html_file} as html file\n" if ($T2H_VERBOSE);
2706 $l2h_html_count = 0;
2708 while ($h_line = <L2H_HTML
>)
2710 if ($h_line =~ /^<!-- l2h_begin $l2h_name ([0-9]+) -->/)
2714 while ($h_line = <L2H_HTML
>)
2716 if ($h_line =~ /^<!-- l2h_end $l2h_name $count -->/)
2721 $h_content = l2h_ToCache
($count, $h_content);
2722 $l2h_from_html[$count] = $h_content;
2726 $h_content = $h_content.$h_line;
2730 print "$ERROR Warning l2h: l2h_end $l2h_name $count not found\n"
2737 print "# l2h: Got $l2h_html_count of $l2h_latex_count html contents\n"
2747 local($done, $to_do, $count);
2751 while ($to_do =~ /([^\000]*)<!-- l2h_replace $l2h_name ([0-9]+) -->([^\000]*)/)
2757 $done = "<!-- l2h_end $l2h_name $count -->".$done
2758 if ($T2H_DEBUG & $DEBUG_L2H);
2760 $done = &l2h_ExtractFromHtml
($count) . $done;
2762 $done = "<!-- l2h_begin $l2h_name $count -->".$done
2763 if ($T2H_DEBUG & $DEBUG_L2H);
2765 return $to_do.$done;
2769 sub l2h_ExtractFromHtml
2773 return $l2h_from_html[$count] if ($l2h_from_html[$count]);
2775 if ($count >= 0 && $count < $l2h_latex_count)
2777 # now we are in trouble
2780 $l2h_extract_error++;
2781 print "$ERROR l2h: can't extract content $count from html\n"
2783 # try simple (ordinary) substition (without l2h)
2786 $_ = $l2h_to_latex{$count};
2787 $_ = &substitute_style
($_);
2789 $_ = "<!-- l2h: ". __LINE__
. " use texi2html -->" . $_
2790 if ($T2H_DEBUG & $DEBUG_L2H);
2796 # now we have been incorrectly called
2798 print "$ERROR l2h: Request of $count content which is out of valide range [0,$l2h_latex_count)\n";
2799 return "<!-- l2h: ". __LINE__
. " out of range count $count -->"
2800 if ($T2H_DEBUG & $DEBUG_L2H);
2801 return "<!-- l2h: out of range count $count -->";
2805 sub l2h_FinishFromHtml
2809 if ($l2h_extract_error + $l2h_range_error)
2811 print "# l2h: finished from html ($l2h_extract_error extract and $l2h_range_error errors)\n";
2815 print "# l2h: finished from html (no errors)\n";
2825 print "# l2h: removing temporary files generated by l2h extension\n"
2827 while (<"$docu_rdir$l2h_name"*>)
2832 print "# l2h: Finished\n" if $T2H_VERBOSE;
2836 ##############################
2837 # stuff for l2h caching
2840 # I tried doing this with a dbm data base, but it did not store all
2841 # keys/values. Hence, I did as latex2html does it
2844 if (-r
"$l2h_cache_file")
2846 my $rdo = do "$l2h_cache_file";
2847 warn("$ERROR l2h Error: could not load $docu_rdir$l2h_cache_file: $@\n")
2854 return unless $l2h_latex_count;
2857 open(FH
, ">$l2h_cache_file") || return warn"$ERROR l2h Error: could not open $docu_rdir$l2h_cache_file for writing: $!\n";
2860 while (($key, $value) = each %l2h_cache)
2864 $key =~ s
|\\\\/|\\/|g
;
2865 # weird, a \ at the end of the key results in an error
2866 # maybe this also broke the dbm database stuff
2867 $key =~ s
|\\$|\\\\|;
2868 $value =~ s/\|/\\\|/g;
2869 $value =~ s/\\\\\|/\\\|/g;
2870 $value =~ s
|\\\\|\\\\\\\\|g
;
2871 print FH
"\n\$l2h_cache_key = q/$key/;\n";
2872 print FH
"\$l2h_cache{\$l2h_cache_key} = q|$value|;\n";
2878 # return cached html, if it exists for text, and if all pictures
2879 # are there, as well
2883 my $cached = $l2h_cache{$text};
2886 while ($cached =~ m/SRC="(.*?)"/g)
2888 unless (-e
"$docu_rdir$1")
2898 # insert generated html into cache, move away images,
2899 # return transformed html
2904 my $content = shift;
2905 my @images = ($content =~ /SRC="(.*?)"/g);
2910 $dest = $l2h_img{$src};
2914 if ($src =~ /.*\.(.*)$/ && $1 ne $docu_ext)
2920 warn "$ERROR: L2h image $src has invalid extension\n";
2923 while (-e
"$docu_rdir${docu_name}_$maximage.$ext") { $maximage++;}
2924 $dest = "${docu_name}_$maximage.$ext";
2925 system("cp -f $docu_rdir$src $docu_rdir$dest");
2926 $l2h_img{$src} = $dest;
2927 unlink "$docu_rdir$src" unless ($DEBUG & DEBUG_L2H
);
2929 $content =~ s/$src/$dest/g;
2931 $l2h_cache{$l2h_to_latex[$count]} = $content;
2936 #+++############################################################################
2938 # Pass 1: read source, handle command, variable, simple substitution #
2940 #---############################################################################
2942 @lines = (); # whole document
2943 @toc_lines = (); # table of contents
2944 @stoc_lines = (); # table of contents
2945 $curlevel = 0; # current level in TOC
2946 $node = ''; # current node name
2947 $node_next = ''; # current node next name
2948 $node_prev = ''; # current node prev name
2949 $node_up = ''; # current node up name
2950 $in_table = 0; # am I inside a table
2951 $table_type = ''; # type of table ('', 'f', 'v', 'multi')
2952 @tables = (); # nested table support
2953 $in_bibliography = 0; # am I inside a bibliography
2954 $in_glossary = 0; # am I inside a glossary
2955 $in_top = 0; # am I inside the top node
2956 $has_top = 0; # did I see a top node?
2957 $has_top_command = 0; # did I see @top for automatic pointers?
2958 $in_pre = 0; # am I inside a preformatted section
2959 $in_list = 0; # am I inside a list
2960 $in_html = 0; # am I inside an HTML section
2961 $first_line = 1; # is it the first line
2962 $dont_html = 0; # don't protect HTML on this line
2963 $deferred_ref = ''; # deferred reference for indexes
2964 @html_stack = (); # HTML elements stack
2965 $html_element = ''; # current HTML element
2967 %macros = (); # macros
2970 $T2H_L2H = &l2h_Init
($docu_name) if ($T2H_L2H);
2971 $T2H_L2H = &l2h_InitToLatex
if ($T2H_L2H);
2973 # build code for simple substitutions
2974 # the maps used (%simple_map and %things_map) MUST be aware of this
2975 # watch out for regexps, / and escaped characters!
2977 foreach (keys(%simple_map)) {
2978 ($re = $_) =~ s/(\W)/\\$1/g; # protect regexp chars
2979 $subst_code .= "s/\\\@$re/$simple_map{$_}/g;\n";
2981 foreach (keys(%things_map)) {
2982 $subst_code .= "s/\\\@$_\\{\\}/$things_map{$_}/g;\n";
2985 # accentuated characters
2986 foreach (keys(%accent_map)) {
2988 $subst_code .= "s/$;3";
2989 } elsif ($_ eq "'") {
2990 $subst_code .= "s/$;4";
2992 $subst_code .= "s/\\\@\\$_";
2994 $subst_code .= "([a-z])/&\${1}$accent_map{$_};/gi;\n";
2997 eval("sub simple_substitutions { $subst_code }");
3000 INPUT_LINE
: while ($_ = &next_line
) {
3002 # remove \input on the first lines only
3008 # non-@ substitutions cf. texinfmt.el
3010 # parse texinfo tags
3014 if (/^\s*\@end\s+(\w+)\b/) {
3016 } elsif (/^\s*\@(\w+)\b/) {
3020 # handle @html / @end html
3023 if ($end_tag eq 'html') {
3026 $tag2pro{$in_html} .= $_;
3029 } elsif ($tag eq 'html') {
3030 $in_html = $PROTECTTAG . ++$html_num;
3031 push(@lines, $in_html);
3036 # try to remove inlined comments
3037 # syntax from tex-mode.el comment-start-skip
3039 s/((^|[^\@])(\@\@)*)\@c(omment | |\{|$).*/$1/;
3041 # Sometimes I use @c right at the end of a line ( to suppress the line feed )
3042 # s/((^|[^\@])(\@\@)*)\@c(omment)?$/$1/;
3043 # s/((^|[^\@])(\@\@)*)\@c(omment)? .*/$1/;
3044 # s/(.*)\@c{.*?}(.*)/$1$2/;
3045 # s/(.*)\@comment{.*?}(.*)/$1$2/;
3047 # s/^(.*)\@comment /$1/;
3049 #############################################################
3050 # value substitution before macro expansion, so that
3051 # it works in macro arguments
3052 s/\@value{($VARRE)}/$value{$1}/eg;
3054 #############################################################
3055 # macro substitution
3058 if (exists($macros->{$1}))
3065 if ($after =~ /^\s*{(.*?[^\\])}(.*)/)
3070 elsif (@{$macros->{$name}->{Args}} == 1)
3077 $args =~ s|\\\\|\\|g;
3080 if (@{$macros->{$name}->{Args}} > 1)
3082 $args =~ s/(^|[^\\]),/$1$;/g ;
3084 @args = split(/$;\s*/, $args) if (@{$macros->{$name}->{Args}} > 1);
3091 my $macrobody = $macros->{$name}->{Body};
3092 for ($i=0; $i<=$#args; $i++)
3094 $macrobody =~ s|\\$macros->{$name}->{Args}->[$i]\\|$args[$i]|g;
3096 $macrobody =~ s|\\\\|\\|g;
3097 $_ = $before . $macrobody . $after;
3098 unshift @input_spool, map {$_ = $_."\n"} split(/\n/, $_);
3105 # try to skip the line
3108 $in_titlepage = 0 if $end_tag eq 'titlepage';
3109 next if $to_skip{"end $end_tag"};
3111 $in_titlepage = 1 if $tag eq 'titlepage';
3112 next if $to_skip{$tag};
3113 last if $tag eq 'bye';
3116 # parsing the top node
3117 if ($tag eq 'node' ||
3118 ($sec2level{$tag} && $tag !~ /unnumbered/ && $tag !~ /heading/))
3122 push(@lines, $TOPEND);
3128 s/([\w ])---([\w ])/$1--$2/g;
3135 &skip_until($tag), next if $tag eq 'ignore';
3136 &skip_until($tag), next if $tag eq 'ifnothtml';
3137 if ($tag eq 'ifinfo')
3139 &skip_until($tag), next unless $T2H_EXPAND eq 'info';
3141 if ($tag eq 'iftex')
3143 &skip_until($tag), next unless $T2H_EXPAND eq 'tex';
3147 # add to latex2html file
3148 if ($T2H_EXPAND eq 'tex' && $T2H_L2H && ! $in_pre)
3150 # add space to the end -- tex(i2dvi) does this, as well
3151 push(@lines, &l2h_ToLatex(&string_until($tag) . " "));
3159 if ($tag eq 'titlepage')
3163 # handle special tables
3164 if ($tag =~ /^(|f|v|multi)table$/) {
3169 if ($tag eq 'top' || ($tag eq 'node' && /^\@node\s+top\s*,/i)) {
3172 $has_top_command = 1 if $tag eq 'top';
3173 @lines = (); # ignore all lines before top (title page garbage)
3175 } elsif ($tag eq 'node') {
3179 push(@lines, $TOPEND);
3181 warn "$ERROR Bad node line: $_" unless $_ =~ /^\@node\s$NODESRE$/o;
3182 # request of "Richard Y. Kim" <ryk@ap.com>
3184 $_ = &protect_html($_); # if node contains '&' for instance
3185 ($node, $node_next, $node_prev, $node_up) = split(/,/);
3186 &normalise_node($node);
3187 &normalise_node($node_next);
3188 &normalise_node($node_prev);
3189 &normalise_node($node_up);
3191 push @lines, &html_debug("<A NAME='$node'></A>\n", __LINE__) :
3192 push @lines, &html_debug("<A NAME=\"$node\"></A>\n", __LINE__);
3194 } elsif ($tag eq 'include') {
3195 if (/^\@include\s+($FILERE)\s*$/o) {
3196 $file = LocateIncludeFile($1);
3197 if ($file && -e $file) {
3199 print "# including $file\n" if $T2H_VERBOSE;
3201 warn "$ERROR Can't find $1, skipping";
3204 warn "$ERROR Bad include line: $_";
3207 } elsif ($tag eq 'ifclear') {
3208 if (/^\@ifclear\s+($VARRE)\s*$/o) {
3209 next unless defined($value{$1});
3212 warn "$ERROR Bad ifclear line: $_";
3215 } elsif ($tag eq 'ifset') {
3216 if (/^\@ifset\s+($VARRE)\s*$/o) {
3217 next if defined($value{$1});
3220 warn "$ERROR Bad ifset line: $_";
3223 } elsif ($tag eq 'menu') {
3224 unless ($T2H_SHOW_MENU) {
3228 &html_push_if($tag);
3229 push(@lines, &html_debug('', __LINE__));
3230 } elsif ($format_map{$tag}) {
3231 $in_pre = 1 if $format_map{$tag} eq 'PRE';
3232 &html_push_if($format_map{$tag});
3233 push(@lines, &html_debug('', __LINE__));
3234 $in_list++ if $format_map{$tag} eq 'UL' || $format_map{$tag} eq 'OL' ;
3235 # push(@lines, &debug("<BLOCKQUOTE>\n", __LINE__))
3236 # if $tag =~ /example/i;
3237 # sunshine@sunshineco.com: <PRE>bla</PRE> looks better than
3238 # <PRE>\nbla</PRE> (at least on NeXTstep browser
3239 push(@lines, &debug("<$format_map{$tag}>" .
3240 ($in_pre ? '' : "\n"), __LINE__));
3243 elsif (exists $complex_format_map->{$tag})
3245 my $start = eval $complex_format_map->{$tag}->[0];
3248 print "$ERROR: eval of complex_format_map->{$tag}->[0] $complex_format_map->{$tag}->[0]: $@";
3251 $in_pre = 1 if $start =~ /<pre/;
3252 push(@lines, html_debug($start. ($in_pre ? '' : "\n"), __LINE__));
3254 } elsif ($tag eq 'table') {
3255 # anorland@hem2.passagen.se
3256 # if (/^\s*\@(|f|v|multi)table\s+\@(\w+)/) {
3257 if (/^\s*\@(|f|v|multi)table\s+\@(\w+)|(\{[^\}]*\})/) {
3259 unshift(@tables, join($;, $table_type, $in_table));
3260 if ($table_type eq "multi") {
3261 # don't use borders -- gets confused by empty cells
3262 push(@lines, &debug("<TABLE>\n", __LINE__));
3263 &html_push_if('TABLE');
3265 push(@lines, &debug("<DL COMPACT>\n", __LINE__));
3266 &html_push_if('DL');
3268 push(@lines, &html_debug('', __LINE__));
3270 warn "$ERROR Bad table line: $_";
3274 elsif ($tag eq 'synindex' || $tag eq 'syncodeindex')
3276 if (/^\@$tag\s+(\w+)\s+(\w+)\s*$/)
3280 my $prefix_from = IndexName2Prefix($from);
3281 my $prefix_to = IndexName2Prefix($to);
3283 warn("$ERROR unknown from index name $from ind syn*index line: $_"), next
3284 unless $prefix_from;
3285 warn("$ERROR unknown to index name $to ind syn*index line: $_"), next
3288 if ($tag eq 'syncodeindex')
3290 $index_properties->{$prefix_to}->{'from_code'}->{$prefix_from} = 1;
3294 $index_properties->{$prefix_to}->{'from'}->{$prefix_from} = 1;
3299 warn "$ERROR Bad syn*index line: $_";
3303 elsif ($tag eq 'defindex' || $tag eq 'defcodeindex')
3305 if (/^\@$tag\s+(\w+)\s*$/)
3308 $index_properties->{$name}->{name} = $name;
3309 $index_properties->{$name}->{code} = 1 if $tag eq 'defcodeindex';
3313 warn "$ERROR Bad defindex line: $_";
3317 elsif (/^\@printindex/)
3319 push (@lines, "<!--::${section}::-->$_");
3322 elsif ($tag eq 'sp') {
3323 push(@lines, &debug("<P>\n", __LINE__));
3325 } elsif ($tag eq 'center') {
3326 push(@lines, &debug("<center>\n", __LINE__));
3328 } elsif ($tag eq 'setref') {
3329 &protect_html; # if setref contains '&' for instance
3330 if (/^\@$tag\s*{($NODERE)}\s*$/) {
3332 $setref =~ s/\s+/ /g; # normalize
3334 $node2sec{$setref} = $name;
3335 $sec2node{$name} = $setref;
3336 $node2href{$setref} = "$docu_doc#$docid";
3338 warn "$ERROR Bad setref line: $_";
3341 } elsif ($tag eq 'lowersections') {
3342 local ($sec, $level);
3343 while (($sec, $level) = each %sec2level) {
3344 $sec2level{$sec} = $level + 1;
3347 } elsif ($tag eq 'raisesections') {
3348 local ($sec, $level);
3349 while (($sec, $level) = each %sec2level) {
3350 $sec2level{$sec} = $level - 1;
3354 elsif ($tag eq 'macro' || $tag eq 'rmacro')
3356 if (/^\@$tag\s*(\w+)\s*(.*)/)
3360 @args = split(/\s*,\s*/ , $1)
3361 if ($2 =~ /^\s*{(.*)}\s*/);
3363 $macros->{$name}->{Args} = \@args;
3364 $macros->{$name}->{Body} = '';
3365 while (($_ = &next_line) && $_ !~ /\@end $tag/)
3367 $macros->{$name}->{Body} .= $_;
3369 die "ERROR: No closing '\@end $tag' found for macro definition of '$name'\n"
3370 unless (/\@end $tag/);
3371 chomp $macros->{$name}->{Body};
3375 warn "$ERROR: Bad macro defintion $_"
3379 elsif ($tag eq 'unmacro')
3381 delete $macros->{$1} if (/^\@unmacro\s*(\w+)/);
3384 elsif ($tag eq 'documentlanguage')
3386 SetDocumentLanguage($1) if (!$T2H_LANG && /documentlanguage\s*(\w+)/);
3388 elsif (defined($def_map{$tag})) {
3389 if ($def_map{$tag}) {
3391 $tag = $def_map{$tag};
3395 } elsif (defined($user_sub{$tag})) {
3397 $sub = $user_sub{$tag};
3398 print "# user $tag = $sub, arg: $_" if $T2H_DEBUG & $DEBUG_USER;
3399 if (defined(&$sub)) {
3403 warn "$ERROR Bad user sub for $tag: $sub\n";
3407 if (defined($def_map{$tag})) {
3410 # extra definition line
3416 while (/\{([^\{\}]*)\}/) {
3417 # this is a {} construct
3418 ($before, $contents, $after) = ($`, $1, $');
3420 $contents =~ s/\s+/$;9/g;
3421 # restore $_ protecting {}
3422 $_ = "$before$;7$contents$;8$after";
3424 @args = split(/\s+/, &protect_html($_));
3426 s/$;9/ /g; # unprotect spaces
3430 $type = shift(@args);
3431 $type =~ s/^\{(.*)\}$/$1/;
3432 print "# def ($tag): {$type} ", join(', ', @args), "\n"
3433 if $T2H_DEBUG & $DEBUG_DEF;
3434 $type .= ':'; # it's nicer like this
3435 my $name = shift(@args);
3436 $name =~ s/^\{(.*)\}$/$1/;
3438 $_ = &debug("<DT>", __LINE__);
3440 $_ = &debug("<DL>\n<DT>", __LINE__);
3442 if ($tag eq 'deffn' || $tag eq 'defvr' || $tag eq 'deftp') {
3443 $_ .= "<U>$type</U> <B>$name</B>";
3444 $_ .= " <I>@args</I>" if @args;
3445 } elsif ($tag eq 'deftypefn' || $tag eq 'deftypevr'
3446 || $tag eq 'defcv' || $tag eq 'defop') {
3448 $name = shift(@args);
3449 $name =~ s/^\{(.*)\}$/$1/;
3450 $_ .= "<U>$type</U> $ftype <B>$name</B>";
3451 $_ .= " <I>@args</I>" if @args;
3453 warn "$ERROR Unknown definition type: $tag\n";
3454 $_ .= "<U>$type</U> <B>$name</B>";
3455 $_ .= " <I>@args</I>" if @args;
3457 $_ .= &debug("\n<DD>", __LINE__);
3458 $name = &unprotect_html($name);
3459 if ($tag eq 'deffn' || $tag eq 'deftypefn') {
3460 EnterIndexEntry('f', $name, $docu_doc, $section, \@lines);
3461 # unshift(@input_spool, "\@findex $name\n");
3462 } elsif ($tag eq 'defop') {
3463 EnterIndexEntry('f', "$name on $ftype", $docu_doc, $section, \@lines);
3464 # unshift(@input_spool, "\@findex $name on $ftype\n");
3465 } elsif ($tag eq 'defvr' || $tag eq 'deftypevr' || $tag eq 'defcv') {
3466 EnterIndexEntry('v', $name, $docu_doc, $section, \@lines);
3467 # unshift(@input_spool, "\@vindex $name\n");
3469 EnterIndexEntry('t', $name, $docu_doc, $section, \@lines);
3470 # unshift(@input_spool, "\@tindex $name\n");
3474 } elsif ($end_tag) {
3475 if ($format_map{$end_tag}) {
3476 $in_pre = 0 if $format_map{$end_tag} eq 'PRE';
3477 $in_list-- if $format_map{$end_tag} eq 'UL' || $format_map{$end_tag} eq 'OL' ;
3481 push(@lines, &debug("</$format_map{$end_tag}>\n", __LINE__));
3482 push(@lines, &html_debug('', __LINE__));
3484 elsif (exists $complex_format_map->{$end_tag})
3486 my $end = eval $complex_format_map->{$end_tag}->[1];
3489 print "$ERROR: eval of complex_format_map->{$end_tag}->[1] $complex_format_map->{$end_tag}->[0]: $@";
3492 $in_pre = 0 if $end =~ m|</pre>|;
3493 push(@lines, html_debug($end, __LINE__));
3494 } elsif ($end_tag =~ /^(|f|v|multi)table$/) {
3496 warn "$ERROR \@end $end_tag without \@*table\n";
3500 ($table_type, $in_table) = split($;, shift(@tables));
3501 unless ($1 eq $table_type) {
3502 warn "$ERROR \@end $end_tag without matching \@$end_tag\n";
3505 if ($table_type eq "multi") {
3506 push(@lines, "</TR></TABLE>\n");
3509 push(@lines, "</DL>\n");
3514 ($table_type, $in_table) = split($;, $tables[0]);
3518 } elsif (defined($def_map{$end_tag})) {
3519 push(@lines, &debug("</DL>\n", __LINE__));
3520 } elsif ($end_tag eq 'menu') {
3522 push(@lines, $_); # must keep it for pass 2
3526 #############################################################
3528 while (/\@anchor\s*\{(.*?)\}/)
3532 $anchor = &normalise_node($anchor);
3533 push @lines, &html_debug("<A NAME=\"$anchor\"></A>\n");
3534 $node2href{$anchor} = "$docu_doc#$anchor";
3535 next INPUT_LINE if $_ =~ /^\s*$/;
3538 #############################################################
3539 # index entry generation, after value substitutions
3540 if (/^\@(\w+?)index\s+/)
3542 EnterIndexEntry($1, $', $docu_doc, $section, \
@lines);
3546 # protect texi and HTML things
3548 $_ = &protect_html
($_) unless $dont_html;
3550 # substitution (unsupported things)
3554 # other substitutions
3555 &simple_substitutions
;
3556 s/\@footnote\{/\@footnote$docu_doc\{/g; # mark footnotes, cf. pass 4
3558 # analyze the tag again
3561 if (defined($sec2level{$tag}) && $sec2level{$tag} > 0) {
3562 if (/^\@$tag\s+(.+)$/) {
3564 $name = &normalise_node
($name);
3565 $level = $sec2level{$tag};
3567 $first_index_chapter = $name
3568 if ($level == 1 && !$first_index_chapter &&
3570 if ($in_top && /heading/){
3571 $T2H_HAS_TOP_HEADING = 1;
3572 $_ = &debug
("<H$level>$name</H$level>\n", __LINE__
);
3573 &html_push_if
('body');
3574 print "# top heading, section $name, level $level\n"
3575 if $T2H_DEBUG & $DEBUG_TOC;
3579 unless (/^\@\w*heading/)
3581 unless (/^\@unnumbered/)
3583 my $number = &update_sec_num
($tag, $level);
3584 $name = $number. ' ' . $name if $T2H_NUMBER_SECTIONS;
3585 $sec2number{$name} = $number;
3586 $number2sec{$number} = $name;
3588 if (defined($toplevel))
3590 push @lines, ($level==$toplevel ?
$CHAPTEREND : $SECTIONEND);
3594 # first time we see a "section"
3595 unless ($level == 1)
3597 warn "$WARN The first section found is not of level 1: $_";
3601 push(@sections, $name);
3602 next_doc
() if ($T2H_SPLIT eq 'section' ||
3603 $T2H_SPLIT && $level == $toplevel);
3606 $docid = "SEC$sec_num";
3607 $tocid = (/^\@\w*heading/ ?
undef : "TOC$sec_num");
3608 # check biblio and glossary
3609 $in_bibliography = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*bibliography$/i);
3610 $in_glossary = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*glossary$/i);
3614 warn "$ERROR Duplicate node found: $node\n"
3615 if ($node2sec{$node});
3619 $name .= ' ' while ($node2sec{$name});
3622 $name .= ' ' while ($sec2node{$name});
3624 $node2sec{$node} = $name;
3625 $sec2node{$name} = $node;
3626 $node2href{$node} = "$docu_doc#$docid";
3627 $node2next{$node} = $node_next;
3628 $node2prev{$node} = $node_prev;
3629 $node2up{$node} = $node_up;
3630 print "# node $node, section $name, level $level\n"
3631 if $T2H_DEBUG & $DEBUG_TOC;
3640 while ($level > $curlevel) {
3642 push(@toc_lines, "<UL>\n");
3644 while ($level < $curlevel) {
3646 push(@toc_lines, "</UL>\n");
3648 $_ = &t2h_anchor
($tocid, "$docu_doc#$docid", $name, 1);
3649 $_ = &substitute_style
($_);
3650 push(@stoc_lines, "$_<BR>\n") if ($level == 1);
3651 if ($T2H_NUMBER_SECTIONS)
3653 push(@toc_lines, $_ . "<BR>\n")
3657 push(@toc_lines, "<LI>" . $_ ."</LI>");
3662 push(@lines, &html_debug
("<A NAME=\"$docid\"></A>\n",
3666 push(@lines, &html_debug
('', __LINE__
));
3668 $_ = "<H$level> $name </H$level>\n<!--docid::${docid}::-->\n";
3669 $_ = &debug
($_, __LINE__
);
3670 push(@lines, &html_debug
('', __LINE__
));
3673 foreach $line (split(/\n+/, $_)) {
3674 push(@lines, "$line\n");
3678 warn "$ERROR Bad section line: $_";
3682 $value{$1} = Unprotect_texi
($2), next if /^\@set\s+($VARRE)\s+(.*)$/o;
3683 delete $value{$1}, next if /^\@clear\s+($VARRE)\s*$/o;
3685 $value{'_shorttitle'} = Unprotect_texi
($1), next if /^\@shorttitle\s+(.*)$/;
3686 $value{'_setfilename'} = Unprotect_texi
($1), next if /^\@setfilename\s+(.*)$/;
3687 $value{'_settitle'} = Unprotect_texi
($1), next if /^\@settitle\s+(.*)$/;
3688 $value{'_author'} .= Unprotect_texi
($1)."\n", next if /^\@author\s+(.*)$/;
3689 $value{'_subtitle'} .= Unprotect_texi
($1)."\n", next if /^\@subtitle\s+(.*)$/;
3690 $value{'_title'} .= Unprotect_texi
($1)."\n", next if /^\@title\s+(.*)$/;
3693 if (/^\s*\@itemx?\s+/) {
3696 if ($in_bibliography && $use_bibliography) {
3697 if ($what =~ /^$BIBRE$/o) {
3698 $id = 'BIB
' . ++$bib_num;
3699 $bib2href{$what} = "$docu_doc#$id";
3700 print "# found bibliography for '$what' id $id\n"
3701 if $T2H_DEBUG & $DEBUG_BIB;
3702 $what = &t2h_anchor($id, '', $what);
3704 } elsif ($in_glossary && $T2H_USE_GLOSSARY) {
3705 $id = 'GLOSS
' . ++$gloss_num;
3707 $entry =~ tr/A-Z/a-z/ unless $entry =~ /^[A-Z\s]+$/;
3708 $gloss2href{$entry} = "$docu_doc#$id";
3709 print "# found glossary for '$entry' id $id\n"
3710 if $T2H_DEBUG & $DEBUG_GLOSS;
3711 $what = &t2h_anchor($id, '', $what);
3713 elsif ($in_table && ($table_type eq 'f
' || $table_type eq 'v
'))
3715 EnterIndexEntry($table_type, $what, $docu_doc, $section, \@lines);
3718 if ($html_element eq 'DL
' || $html_element eq 'DD
') {
3719 if ($things_map{$in_table} && !$what) {
3720 # special case to allow @table @bullet for instance
3721 push(@lines, &debug("<DT>$things_map{$in_table}\n", __LINE__));
3723 push(@lines, &debug("<DT>\@$in_table\{$what\}\n", __LINE__));
3725 push(@lines, "<DD>");
3726 &html_push('DD
') unless $html_element eq 'DD
';
3727 if ($table_type) { # add also an index
3728 unshift(@input_spool, "\@${table_type}index $what\n");
3730 } elsif ($html_element eq 'TABLE
') {
3731 push(@lines, &debug("<TR><TD>$what</TD>\n", __LINE__));
3733 } elsif ($html_element eq 'TR
') {
3734 push(@lines, &debug("</TR>\n", __LINE__));
3735 push(@lines, &debug("<TR><TD>$what</TD>\n", __LINE__));
3737 push(@lines, &debug("<LI>$what\n", __LINE__));
3738 &html_push('LI
') unless $html_element eq 'LI
';
3740 push(@lines, &html_debug('', __LINE__));
3741 if ($deferred_ref) {
3742 push(@lines, &debug("$deferred_ref\n", __LINE__));
3746 } elsif (/^\@tab\s+(.*)$/) {
3747 push(@lines, "<TD>$1</TD>\n");
3752 # paragraph separator
3753 if ($_ eq "\n" && ! $in_pre) {
3754 next if $#lines >= 0 && $lines[$#lines] eq "\n";
3755 if ($html_element eq 'P
') {
3756 push (@lines, &debug("</P><P>\n", __LINE__));
3760 # push(@lines, "<P></P>\n");
3761 # $_ = &debug("<P></P>\n", __LINE__);
3763 elsif ($html_element eq 'body
' || $html_element eq 'BLOCKQUOTE
' || $html_element eq 'DD
' || $html_element eq 'LI
')
3766 push(@lines, &debug("<P>\n", __LINE__));
3770 push(@lines, $_) unless $in_titlepage;
3771 push(@lines, &debug("</center>\n", __LINE__)) if ($tag eq 'center
');
3776 while ($level < $curlevel) {
3778 push(@toc_lines, "</UL>\n");
3781 print "# end of pass 1\n" if $T2H_VERBOSE;
3783 SetDocumentLanguage('en
') unless ($T2H_LANG);
3784 #+++############################################################################
3786 # Stuff related to Index generation #
3788 #---############################################################################
3794 my $docu_doc = shift;
3795 my $section = shift;
3799 warn "$ERROR Undefined index command: $_", next
3800 unless (exists ($index_properties->{$prefix}));
3805 $_ = &protect_html($_);
3806 my $html_key = substitute_style($_);
3808 $key = remove_style($key);
3809 $key = remove_things($key);
3813 while (exists $index->{$prefix}->{$key}) {$key .= ' '};
3814 if ($lines->[$#lines] =~ /^<!--docid::(.+)::-->$/)
3820 $id = 'IDX
' . ++$idx_num;
3821 push(@$lines, &t2h_anchor($id, '', $T2H_INVISIBLE_MARK, !$in_pre));
3823 $index->{$prefix}->{$key}->{html_key} = $html_key;
3824 $index->{$prefix}->{$key}->{section} = $section;
3825 $index->{$prefix}->{$key}->{href} = "$docu_doc#$id";
3826 print "# found ${prefix}index for '$key' with id $id\n"
3827 if $T2H_DEBUG & $DEBUG_INDEX;
3830 sub IndexName2Prefix
3835 for $prefix (keys %$index_properties)
3837 return $prefix if ($index_properties->{$prefix}->{name} eq $name);
3846 my ($entries, $prefix, $key) = ({});
3848 for $prefix (keys %$normal)
3850 for $key (keys %{$index->{$prefix}})
3852 $entries->{$key} = {%{$index->{$prefix}->{$key}}};
3858 for $prefix (keys %$code)
3860 unless (exists $normal->{$keys})
3862 for $key (keys %{$index->{$prefix}})
3864 $entries->{$key} = {%{$index->{$prefix}->{$key}}};
3865 $entries->{$key}->{html_key} = "<CODE>$entries->{$key}->{html_key}</CODE>";
3875 if ($a =~ /^[A-Za-z]/)
3877 if ($b =~ /^[A-Za-z]/)
3879 return lc($a) cmp lc($b);
3886 elsif ($b =~ /^[A-Za-z]/)
3892 return lc($a) cmp lc($b);
3898 my $entries = shift;
3899 my (@Letters, $key);
3900 my ($EntriesByLetter, $Pages, $page) = ({}, [], {});
3901 my @keys = sort byAlpha keys %$entries;
3905 push @{$EntriesByLetter->{uc(substr($key,0, 1))}} , $entries->{$key};
3907 @Letters = sort byAlpha keys %$EntriesByLetter;
3909 $T2H_SPLIT_INDEX = 0 unless ($T2H_SPLIT);
3911 unless ($T2H_SPLIT_INDEX)
3913 $page->{First} = $Letters[0];
3914 $page->{Last} = $Letters[$#Letters];
3915 $page->{Letters} = \@Letters;
3916 $page->{EntriesByLetter} = $EntriesByLetter;
3917 push @$Pages, $page;
3921 if ($T2H_SPLIT_INDEX =~ /^\d+$/)
3924 my ($prev_letter, $letter);
3925 $page->{First} = $Letters[0];
3926 for $letter (@Letters)
3928 if ($i > $T2H_SPLIT_INDEX)
3930 $page->{Last} = $prev_letter;
3931 push @$Pages, {%$page};
3932 $page->{Letters} = [];
3933 $page->{EntriesByLetter} = {};
3934 $page->{First} = $letter;
3937 push @{$page->{Letters}}, $letter;
3938 $page->{EntriesByLetter}->{$letter} = [@{$EntriesByLetter->{$letter}}];
3939 $i += scalar(@{$EntriesByLetter->{$letter}});
3940 $prev_letter = $letter;
3942 $page->{Last} = $Letters[$#Letters];
3943 push @$Pages, {%$page};
3950 my $first_page = shift;
3953 my ($page, $letter, $summary, $i, $l1, $l2, $l);
3956 $summary = '<table
><tr
><th valign
=top
>Jump to
:  
; </th
><td
>';
3958 for $page ($first_page, @$Pages)
3960 for $letter (@{$page->{Letters}})
3962 $l = t2h_anchor('', "$page->{href}#${name}_$letter", "<b>$letter</b>",
3963 0, 'style
="text-decoration:none"') . "\n \n";
3965 if ($letter =~ /^[A-Za-z]/)
3975 $summary .= $l1 . "<BR>\n" if ($l1);
3976 $summary .= $l2 . '</td></tr
></table
><br
>';
3983 my $summary = shift;
3987 push @$lines, $summary;
3989 push @$lines , <<EOT;
3992 <TR><TD></TD><TH ALIGN=LEFT>Index Entry</TH><TH ALIGN=LEFT> Section</TH></TR>
3993 <TR><TD COLSPAN=3> <HR></TD></TR>
3996 for $letter (@
{$page->{Letters
}})
3998 push @
$lines, "<TR><TH><A NAME=\"${name}_$letter\"></A>$letter</TH><TD></TD><TD></TD></TR>\n";
3999 for $entry (@
{$page->{EntriesByLetter
}->{$letter}})
4002 "<TR><TD></TD><TD valign=top>" .
4003 t2h_anchor
('', $entry->{href
}, $entry->{html_key
}) .
4004 "</TD><TD valign=top>" .
4005 t2h_anchor
('', sec_href
($entry->{section
}), clean_name
($entry->{section
})) .
4008 push @
$lines, "<TR><TD COLSPAN=3> <HR></TD></TR>\n";
4010 push @
$lines, "</TABLE><P></P>";
4011 push @
$lines, $summary;
4018 my $section = shift;
4019 $section = 'Top' unless $section;
4020 my $prefix = IndexName2Prefix
($name);
4022 warn ("$ERROR printindex: bad index name: $name"), return
4025 if ($index_properties->{$prefix}->{code
})
4027 $index_properties->{$prefix}->{from_code
}->{$prefix} = 1;
4031 $index_properties->{$prefix}->{from
}->{$prefix}= 1;
4034 my $Entries = GetIndexEntries
($index_properties->{$prefix}->{from
},
4035 $index_properties->{$prefix}->{from_code
});
4036 return unless %$Entries;
4038 if ($T2H_IDX_SUMMARY)
4041 open(FHIDX
, ">$docu_rdir$docu_name" . "_$name.idx")
4042 || die "Can't open > $docu_rdir$docu_name" . "_$name.idx for writing: $!\n";
4043 print "# writing $name index summary in $docu_rdir$docu_name" . "_$name.idx...\n" if $T2H_VERBOSE;
4045 for $key (sort keys %$Entries)
4047 print FHIDX
"$key\t$Entries->{$key}->{href}\n";
4051 my $Pages = GetIndexPages
($Entries);
4053 my $first_page = shift @
$Pages;
4054 my $sec_name = $section;
4055 # remove section number
4056 $sec_name =~ s/.*? // if $sec_name =~ /^([A-Z]|\d+)\./;
4058 ($first_page->{href
} = sec_href
($section)) =~ s/\#.*$//;
4059 # Update tree structure of document
4065 while (@sections && $sections[$#sections] ne $section)
4067 unshift @after, pop @sections;
4072 my $node = ($page->{First
} ne $page->{Last
} ?
4073 "$sec_name: $page->{First} -- $page->{Last}" :
4074 "$sec_name: $page->{First}");
4075 push @sections, $node;
4076 $node2sec{$node} = $node;
4077 $sec2node{$node} = $node;
4078 $node2up{$node} = $section;
4079 $page->{href
} = next_doc
();
4080 $page->{name
} = $node;
4081 $node2href{$node} = $page->{href
};
4084 $node2next{$prev_node} = $node;
4085 $node2prev{$node} = $prev_node;
4089 push @sections, @after;
4092 my $summary = GetIndexSummary
($first_page, $Pages, $name);
4093 PrintIndexPage
($lines, $summary, $first_page, $name);
4096 push @
$lines, ($T2H_SPLIT eq 'chapter' ?
$CHAPTEREND : $SECTIONEND);
4097 push @
$lines, "<H2 ALIGN=\"Left\">$page->{name}</H2>\n";
4098 PrintIndexPage
($lines, $summary, $page, $name);
4103 #+++############################################################################
4105 # Pass 2/3: handle style, menu, index, cross-reference #
4107 #---############################################################################
4109 @lines2 = (); # whole document (2nd pass)
4110 @lines3 = (); # whole document (3rd pass)
4111 $in_menu = 0; # am I inside a menu
4116 # special case (protected sections)
4118 if (/^$PROTECTTAG/o) {
4128 $in_menu_listing = 1;
4129 push(@lines2, &debug
("<BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> \n", __LINE__
));
4132 if (/^\@end\s+menu\b/)
4134 if ($in_menu_listing)
4136 push(@lines2, &debug
("</TABLE></BLOCKQUOTE>\n", __LINE__
));
4140 push(@lines2, &debug
("</BLOCKQUOTE>\n", __LINE__
));
4143 $in_menu_listing = 0;
4148 my ($node, $name, $descr);
4149 if (/^\*\s+($NODERE)::/o)
4154 elsif (/^\*\s+(.+):\s+([^\t,\.\n]+)[\t,\.\n]/)
4162 warn "$ERROR Bad menu line: $_";
4166 if ($in_menu_listing)
4168 $in_menu_listing = 0;
4169 push(@lines2, &debug
("</TABLE>\n", __LINE__
));
4171 # should be like verbatim -- preseve spaces, etc
4178 if (! $in_menu_listing)
4180 $in_menu_listing = 1;
4181 push(@lines2, &debug
("<TABLE BORDER=0 CELLSPACING=0>\n", __LINE__
));
4183 # look for continuation
4184 while ($lines[0] =~ /^\s+\w+/)
4186 $descr .= shift(@lines);
4188 &menu_entry
($node, $name, $descr);
4195 PrintIndex
(\
@lines2, $2, $1), next
4196 if (/^<!--::(.*)::-->\@printindex\s+(\w+)/);
4198 # simple style substitutions
4200 $_ = &substitute_style
($_);
4204 while (/\@(x|px|info|)ref{([^{}]+)(}?)/) {
4205 # note: Texinfo may accept other characters
4206 ($type, $nodes, $full) = ($1, $2, $3);
4207 ($before, $after) = ($`, $');
4208 if (! $full && $after) {
4209 warn "$ERROR Bad xref (no ending } on line): $_";
4210 $_ = "$before$;0${type}ref\{$nodes$after";
4214 $type = "$T2H_WORDS->{$T2H_LANG}->{'See'} ";
4215 } elsif ($type eq 'px') {
4216 $type = "$T2H_WORDS->{$T2H_LANG}->{'see'} ";
4217 } elsif ($type eq 'info') {
4218 $type = "$T2H_WORDS->{$T2H_LANG}->{'See'} Info";
4223 $next = shift(@lines);
4224 $next = &substitute_style($next);
4225 chop($nodes); # remove final newline
4226 if ($next =~ /\}/) { # split on 2 lines
4231 $next = shift(@lines);
4232 $next = &substitute_style($next);
4234 if ($next =~ /\}/) { # split on 3 lines
4238 warn "$ERROR Bad xref (no ending }): $_";
4239 $_ = "$before$;0xref\{$nodes$after";
4240 unshift(@lines, $next);
4245 $nodes =~ s/\s+/ /g; # remove useless spaces
4246 @args = split(/\s*,\s*/, $nodes);
4247 $node = $args[0]; # the node is always the first arg
4248 $node = &normalise_node($node);
4249 $sec = $args[2] || $args[1] || $node2sec{$node};
4250 $href = $node2href{$node};
4251 if (@args == 5) { # reference to another manual
4252 $sec = $args[2] || $node;
4253 $man = $args[4] || $args[3];
4254 $_ = "${before}${type}$T2H_WORDS->{$T2H_LANG}->{'section'} `$sec' in \@cite{$man}$after";
4255 } elsif ($type =~ /Info/) { # inforef
4256 warn "$ERROR Wrong number of arguments: $_" unless @args == 3;
4257 ($nn, $_, $in) = @args;
4258 $_ = "${before}${type} file `$in', node
`$nn'$after";
4259 } elsif ($sec && $href && ! $T2H_SHORT_REF) {
4260 $_ = "${before}${type}";
4261 $_ .= "$T2H_WORDS->{$T2H_LANG}->{'section'} " if ${type};
4262 $_ .= &t2h_anchor('', $href, $sec) . $after;
4266 $_ = "${before}${type} " .
4267 &t2h_anchor('', $href, $args[2] || $args[1] || $node) .
4271 warn "$ERROR Undefined node ($node): $_";
4272 $_ = "$before$;0xref{$nodes}$after";
4277 s[\@image\s*{(.+?)}]
4279 my @args = split (/\s*,\s*/, $1);
4280 my $base = $args[0];
4282 LocateIncludeFile("$base.png") ||
4283 LocateIncludeFile("$base.jpg") ||
4284 LocateIncludeFile("$base.gif");
4285 warn "$ERROR no image file for $base: $_" unless ($image && -e $image);
4286 "<IMG SRC=\"$image\" ALT=\"$base\">";
4287 ($T2H_CENTER_IMAGE ?
4288 "<CENTER><IMG SRC=\"$image\" ALT=\"$base\"></CENTER>" :
4289 "<IMG SRC=\"$image\" ALT=\"$base\">");
4293 # try to guess bibliography references or glossary terms
4295 unless (/^<H\d><A NAME=\"SEC\d/) {
4296 if ($use_bibliography) {
4299 ($pre, $what, $post) = ($`, $&, $');
4300 $href = $bib2href{$what};
4301 if (defined($href) && $post !~ /^[^<]*<\/A>/) {
4302 $done .= $pre . &t2h_anchor('', $href, $what);
4304 $done .= "$pre$what";
4310 if ($T2H_USE_GLOSSARY) {
4313 ($pre, $what, $post) = ($`, $&, $');
4315 $entry =~ tr/A-Z/a-z/ unless $entry =~ /^[A-Z\s]+$/;
4316 $href = $gloss2href{$entry};
4317 if (defined($href) && $post !~ /^[^<]*<\/A
>/) {
4318 $done .= $pre . &t2h_anchor
('', $href, $what);
4320 $done .= "$pre$what";
4330 print "# end of pass 2\n" if $T2H_VERBOSE;
4333 # split style substitutions
4336 $_ = shift(@lines2);
4338 # special case (protected sections)
4340 if (/^$PROTECTTAG/o) {
4345 # split style substitutions
4348 while ($old ne $_) {
4351 ($before, $style, $after) = ($`, $1, $');
4352 if (defined($style_map{$style})) {
4365 $_ = shift(@lines2);
4369 die "* Bad syntax (\@$style) after: $before\n";
4371 $text = &apply_style($style, $text);
4372 $_ = "$before$text$after";
4380 print "# end of pass 3\n" if $T2H_VERBOSE;
4382 #+++############################################################################
4384 # Pass 4: foot notes, final cleanup #
4386 #---############################################################################
4388 @foot_lines = (); # footnotes
4389 @doc_lines = (); # final document
4390 $end_of_para = 0; # true if last line is <P>
4393 $_ = shift(@lines3);
4395 # special case (protected sections)
4397 if (/^$PROTECTTAG/o) {
4398 push(@doc_lines, $_);
4405 while (/\@footnote([^\{\s]+)\{/) {
4406 ($before, $d, $after) = ($`, $1, $');
4419 $_ = shift(@lines3);
4423 die "* Bad syntax (\@footnote) after: $before\n";
4426 $docid = "DOCF$foot_num";
4427 $footid = "FOOT$foot_num";
4428 $foot = "($foot_num)";
4429 push(@foot_lines, "<H3>" . &t2h_anchor($footid, "$d#$docid", $foot) . "</H3>\n");
4430 $text = "<P>$text" unless $text =~ /^\s*<P>/;
4431 push(@foot_lines, "$text\n");
4432 $_ = $before . &t2h_anchor($docid, "$docu_foot#$footid", $foot) . $after;
4436 # remove unnecessary <P>
4438 if (/^\s*<P>\s*$/) {
4439 next if $end_of_para++;
4444 push(@doc_lines, $_);
4447 print "# end of pass 4\n" if $T2H_VERBOSE;
4449 #+++############################################################################
4451 # Pass 5: print things #
4453 #---############################################################################
4455 $T2H_L2H = &l2h_FinishToLatex if ($T2H_L2H);
4456 $T2H_L2H = &l2h_ToHtml if ($T2H_L2H);
4457 $T2H_L2H = &l2h_InitFromHtml if ($T2H_L2H);
4459 # fix node2up, node2prev, node2next, if desired
4460 if ($has_top_command)
4462 for $section (keys %sec2number)
4464 $node = $sec2node{$section};
4465 $node2up{$node} = Sec2UpNode($section) unless $node2up{$node};
4466 $node2prev{$node} = Sec2PrevNode($section) unless $node2prev{$node};
4467 $node2next{$node} = Sec2NextNode($section) unless $node2next{$node};
4471 # prepare %T2H_THISDOC
4472 $T2H_THISDOC{fulltitle} = $value{'_title'} || $value{'_settitle'} || "Untitled Document";
4473 $T2H_THISDOC{title} = $value{'_settitle'} || $T2H_THISDOC{fulltitle};
4474 $T2H_THISDOC{author} = $value{'_author'};
4475 $T2H_THISDOC{subtitle} = $value{'_subtitle'};
4476 $T2H_THISDOC{shorttitle} = $value{'_shorttitle'};
4477 for $key (keys %T2H_THISDOC)
4479 $_ = &substitute_style($T2H_THISDOC{$key});
4482 $T2H_THISDOC{$key} = $_;
4485 # if no sections, then simply print document as is
4488 print "# Writing content into $docu_top_file \n" if $T2H_VERBOSE;
4489 open(FILE, "> $docu_top_file")
4490 || die "$ERROR: Can't open $docu_top_file for writing: $!\n";
4492 &$T2H_print_page_head(\*FILE);
4493 $T2H_THIS_SECTION = \@doc_lines;
4494 t2h_print_lines(\*FILE);
4495 &$T2H_print_foot_navigation(\*FILE);
4496 &$T2H_print_page_foot(\*FILE);
4501 # initialize $T2H_HREF, $T2H_NAME
4504 'First' , sec_href($sections[0]),
4505 'Last', sec_href($sections[$#sections]),
4506 'About', $docu_about. '#SEC_About',
4509 # prepare TOC, OVERVIEW, TOP
4510 $T2H_TOC = \@toc_lines;
4511 $T2H_OVERVIEW = \@stoc_lines;
4516 $_ = shift @doc_lines;
4520 $T2H_HREF{'Top'} = $docu_top . '#SEC_Top';
4524 $T2H_HREF{'Top'} = $T2H_HREF{First};
4527 $node2href{Top} = $T2H_HREF{Top};
4528 $T2H_HREF{Contents} = $docu_toc.'#SEC_Contents' if @toc_lines;
4529 $T2H_HREF{Overview} = $docu_stoc.'#SEC_OVERVIEW' if @stoc_lines;
4532 if ($T2H_INDEX_CHAPTER)
4534 $T2H_HREF{Index} = $node2href{normalise_node($T2H_INDEX_CHAPTER)};
4535 warn "$ERROR T2H_INDEX_CHAPTER '$T2H_INDEX_CHAPTER' not found\n"
4536 unless $T2H_HREF{Index};
4538 if (! $T2H_HREF{Index} && $first_index_chapter)
4540 $T2H_INDEX_CHAPTER = $first_index_chapter;
4541 $T2H_HREF{Index} = $node2href{$T2H_INDEX_CHAPTER};
4544 print "# Using '" . clean_name($T2H_INDEX_CHAPTER) . "' as index page\n"
4545 if ($T2H_VERBOSE && $T2H_HREF{Index});
4549 'First', clean_name($sec2node{$sections[0]}),
4550 'Last', clean_name($sec2node{$sections[$#sections]}),
4551 'About', $T2H_WORDS->{$T2H_LANG}->{'About_Title'},
4552 'Contents', $T2H_WORDS->{$T2H_LANG}->{'ToC_Title'},
4553 'Overview', $T2H_WORDS->{$T2H_LANG}->{'Overview_Title'},
4554 'Index' , clean_name($T2H_INDEX_CHAPTER),
4555 'Top', clean_name($T2H_TOP_HEADING || $T2H_THISDOC{'title'} || $T2H_THISDOC{'shorttitle'}),
4558 #############################################################################
4559 # print frame and frame toc file
4563 open(FILE, "> $docu_frame_file")
4564 || die "$ERROR: Can't open $docu_frame_file for writing: $!\n";
4565 print "# Creating frame in $docu_frame_file ...\n" if $T2H_VERBOSE;
4566 &$T2H_print_frame(\*FILE);
4569 open(FILE, "> $docu_toc_frame_file")
4570 || die "$ERROR: Can't open $docu_toc_frame_file for writing: $!\n";
4571 print "# Creating toc frame in $docu_frame_file ...\n" if $T2H_VERBOSE;
4572 &$T2H_print_toc_frame(\*FILE);
4577 #############################################################################
4580 open(FILE, "> $docu_top_file")
4581 || die "$ERROR: Can't open $docu_top_file for writing: $!\n";
4582 &$T2H_print_page_head(\*FILE) unless ($T2H_SPLIT);
4586 print "# Creating Top in $docu_top_file ...\n" if $T2H_VERBOSE;
4587 $T2H_THIS_SECTION = $T2H_TOP;
4588 $T2H_HREF{This} = $T2H_HREF{Top};
4589 $T2H_NAME{This} = $T2H_NAME{Top};
4590 &$T2H_print_Top(\*FILE);
4593 close(FILE) if $T2H_SPLIT;
4595 #############################################################################
4598 $T2H_NODE{Forward} = $sec2node{$sections[0]};
4599 $T2H_NAME{Forward} = &clean_name($sec2node{$sections[0]});
4600 $T2H_HREF{Forward} = sec_href($sections[0]);
4601 $T2H_NODE{This} = 'Top';
4602 $T2H_NAME{This} = $T2H_NAME{Top};
4603 $T2H_HREF{This} = $T2H_HREF{Top};
4606 print "# writing " . scalar(@sections) .
4607 " sections in $docu_rdir$docu_name"."_[1..$doc_num]"
4609 $previous = ($T2H_SPLIT eq 'chapter' ? $CHAPTEREND : $SECTIONEND);
4615 print "# writing " . scalar(@sections) . " sections in $docu_top_file ..."
4622 # loop through sections
4623 while ($section = shift(@sections))
4625 if ($T2H_SPLIT && ($T2H_SPLIT eq 'section' || $previous eq $CHAPTEREND))
4629 #close previous page
4630 &$T2H_print_chapter_footer($FH) if $T2H_SPLIT eq 'chapter';
4631 &$T2H_print_page_foot($FH);
4636 $T2H_NAME{Back} = $T2H_NAME{This};
4637 $T2H_HREF{Back} = $T2H_HREF{This};
4638 $T2H_NODE{Back} = $T2H_NODE{This};
4639 $T2H_NAME{This} = $T2H_NAME{Forward};
4640 $T2H_HREF{This} = $T2H_HREF{Forward};
4641 $T2H_NODE{This} = $T2H_NODE{Forward};
4644 $T2H_NODE{Forward} = $sec2node{$sections[0]};
4645 $T2H_NAME{Forward} = &clean_name($T2H_NODE{Forward});
4646 $T2H_HREF{Forward} = sec_href($sections[0]);
4650 undef $T2H_HREF{Forward}, $T2H_NODE{Forward}, $T2H_NAME{Forward};
4653 $node = $node2up{$T2H_NODE{This}};
4654 $T2H_HREF{Up} = $node2href{$node};
4655 if ($T2H_HREF{Up} eq $T2H_HREF{This} || ! $T2H_HREF{Up})
4657 $T2H_NAME{Up} = $T2H_NAME{Top};
4658 $T2H_HREF{Up} = $T2H_HREF{Top};
4659 $T2H_NODE{Up} = 'Up';
4663 $T2H_NAME{Up} = &clean_name($node);
4664 $T2H_NODE{Up} = $node;
4667 $node = $T2H_NODE{This};
4668 $node = $node2prev{$node};
4669 $T2H_NAME{Prev} = &clean_name($node);
4670 $T2H_HREF{Prev} = $node2href{$node};
4671 $T2H_NODE{Prev} = $node;
4673 $node = $T2H_NODE{This};
4674 if ($node2up{$node} && $node2up{$node} ne 'Top'&&
4675 ($node2prev{$node} eq $T2H_NODE{Back} || ! $node2prev{$node}))
4677 $node = $node2up{$node};
4678 while ($node && $node ne $node2up{$node} && ! $node2prev{$node})
4680 $node = $node2up{$node};
4682 $node = $node2prev{$node}
4683 unless $node2up{$node} eq 'Top' || ! $node2up{$node};
4687 $node = $node2prev{$node};
4689 $T2H_NAME{FastBack} = &clean_name($node);
4690 $T2H_HREF{FastBack} = $node2href{$node};
4691 $T2H_NODE{FastBack} = $node;
4693 $node = $T2H_NODE{This};
4694 $node = $node2next{$node};
4695 $T2H_NAME{Next} = &clean_name($node);
4696 $T2H_HREF{Next} = $node2href{$node};
4697 $T2H_NODE{Next} = $node;
4699 $node = $T2H_NODE{This};
4700 if ($node2up{$node} && $node2up{$node} ne 'Top'&&
4701 ($node2next{$node} eq $T2H_NODE{Forward} || ! $node2next{$node}))
4703 $node = $node2up{$node};
4704 while ($node && $node ne $node2up{$node} && ! $node2next{$node})
4706 $node = $node2up{$node};
4709 $node = $node2next{$node};
4710 $T2H_NAME{FastForward} = &clean_name($node);
4711 $T2H_HREF{FastForward} = $node2href{$node};
4712 $T2H_NODE{FastForward} = $node;
4716 my $file = $T2H_HREF{This};
4718 open(FILE, "> $docu_rdir$file") ||
4719 die "$ERROR: Can't open $docu_rdir$file for writing: $!\n";
4721 &$T2H_print_page_head($FH);
4722 t2h_print_label($FH);
4723 &$T2H_print_chapter_header($FH) if $T2H_SPLIT eq 'chapter';
4727 t2h_print_label($FH);
4730 $T2H_THIS_SECTION = [];
4731 while (@doc_lines) {
4732 $_ = shift(@doc_lines);
4733 last if ($_ eq $SECTIONEND || $_ eq $CHAPTEREND);
4734 push(@$T2H_THIS_SECTION, $_);
4737 &$T2H_print_section($FH);
4742 print "." if $counter =~ /00$/;
4747 &$T2H_print_chapter_footer($FH) if $T2H_SPLIT eq 'chapter';
4748 &$T2H_print_page_foot($FH);
4751 print "\n" if $T2H_VERBOSE;
4753 #############################################################################
4754 # Print ToC, Overview, Footnotes
4756 undef $T2H_HREF{Prev};
4757 undef $T2H_HREF{Next};
4758 undef $T2H_HREF{Back};
4759 undef $T2H_HREF{Forward};
4760 undef $T2H_HREF{Up};
4764 print "# writing Footnotes in $docu_foot_file...\n" if $T2H_VERBOSE;
4765 open (FILE, "> $docu_foot_file") || die "$ERROR: Can't open $docu_foot_file for writing: $!\n"
4767 $T2H_HREF{This} = $docu_foot;
4768 $T2H_NAME{This} = $T2H_WORDS->{$T2H_LANG}->{'Footnotes_Title'};
4769 $T2H_THIS_SECTION = \@foot_lines;
4770 &$T2H_print_Footnotes(\*FILE);
4771 close(FILE) if $T2H_SPLIT;
4776 print "# writing Toc in $docu_toc_file...\n" if $T2H_VERBOSE;
4777 open (FILE, "> $docu_toc_file") || die "$ERROR: Can't open $docu_toc_file for writing: $!\n"
4779 $T2H_HREF{This} = $T2H_HREF{Contents};
4780 $T2H_NAME{This} = $T2H_NAME{Contents};
4781 $T2H_THIS_SECTION = \@toc_lines;
4782 &$T2H_print_Toc(\*FILE);
4783 close(FILE) if $T2H_SPLIT;
4788 print "# writing Overview in $docu_stoc_file...\n" if $T2H_VERBOSE;
4789 open (FILE, "> $docu_stoc_file") || die "$ERROR: Can't open $docu_stoc_file for writing: $!\n"
4792 $T2H_HREF{This} = $T2H_HREF{Overview};
4793 $T2H_NAME{This} = $T2H_NAME{Overview};
4794 $T2H_THIS_SECTION = \@stoc_lines;
4795 unshift @$T2H_THIS_SECTION, "<BLOCKQUOTE>\n";
4796 push @$T2H_THIS_SECTION, "\n</BLOCKQUOTE>\n";
4797 &$T2H_print_Overview(\*FILE);
4798 close(FILE) if $T2H_SPLIT;
4801 if ($about_body = &$T2H_about_body())
4803 print "# writing About in $docu_about_file...\n" if $T2H_VERBOSE;
4804 open (FILE, "> $docu_about_file") || die "$ERROR: Can't open $docu_about_file for writing: $!\n"
4807 $T2H_HREF{This} = $T2H_HREF{About};
4808 $T2H_NAME{This} = $T2H_NAME{About};
4809 $T2H_THIS_SECTION = [$about_body];
4810 &$T2H_print_About(\*FILE);
4811 close(FILE) if $T2H_SPLIT;
4816 &$T2H_print_page_foot(\*FILE);
4821 &l2h_FinishFromHtml if ($T2H_L2H);
4822 &l2h_Finish if($T2H_L2H);
4823 print "# that's all folks\n" if $T2H_VERBOSE;
4827 #+++############################################################################
4829 # Low level functions #
4831 #---############################################################################
4833 sub LocateIncludeFile
4838 return $file if (-e $file && -r $file);
4839 foreach $dir (@T2H_INCLUDE_DIRS)
4841 return "$dir/$file" if (-e "$dir/$file" && -r "$dir/$file");
4849 $_ = &remove_style($_[0]);
4854 sub update_sec_num {
4855 local($name, $level) = @_;
4858 $level--; # here we start at 0
4859 if ($name =~ /^appendix/ || defined(@appendix_sec_num)) {
4861 if (defined(@appendix_sec_num)) {
4862 &incr_sec_num($level, @appendix_sec_num);
4864 @appendix_sec_num = ('A', 0, 0, 0);
4866 $ret = join('.', @appendix_sec_num[0..$level]);
4869 if (defined(@normal_sec_num))
4871 &incr_sec_num($level, @normal_sec_num);
4875 @normal_sec_num = (1, 0, 0, 0);
4877 $ret = join('.', @normal_sec_num[0..$level]);
4880 $ret .= "." if $level == 0;
4888 foreach $l ($level+1 .. 3) {
4896 my $num = $sec2number{$sec};
4898 return '' unless $num;
4899 return 'Top' unless $num =~ /\.\d+/;
4900 $num =~ s/\.[^\.]*$//;
4901 $num = $num . '.' unless $num =~ /\./;
4902 return $sec2node{$number2sec{$num}};
4908 my $num = $sec2number{$sec};
4911 if ($num =~ /(\w+)(\.$|$)/)
4918 $i = $normal_sec_num[0];
4922 # unfortunately, -- operator is not magical
4923 $i = chr(ord($i) + 1);
4929 return $sec2node{$number2sec{$num . $i . $post}}
4937 my $num = $sec2number{$sec};
4940 if ($num =~ /(\w+)(\.$|$)/)
4945 if ($post eq '.' && $i eq $normal_sec_num[0])
4953 return $sec2node{$number2sec{$num . $i . $post}}
4959 local($_, %seen, %context, $before, $match, $after);
4962 if (/\@(\*|\.|\:|\@|\{|\})/) {
4964 $context{$&} .= "> $_" if $T2H_VERBOSE;
4969 ($before, $match, $after) = ($`, $&, $');
4970 if ($before =~ /\b[\w-]+$/ && $after =~ /^[\w-.]*\b/) { # e-mail address
4971 $seen{'e-mail address'}++;
4972 $context{'e-mail address'} .= "> $_" if $T2H_VERBOSE;
4975 $context{$match} .= "> $_" if $T2H_VERBOSE;
4978 $_ = "$before$match$after";
4983 foreach (sort(keys(%seen))) {
4988 print "$_ ($seen{$_})\n";
4997 if (open($fh_name, $name)) {
4998 unshift(@fhs, $fh_name);
5000 warn "$ERROR Can't read file $name: $!\n";
5005 @fhs = (); # hold the file handles to read
5006 @input_spool = (); # spooled lines to read
5015 $line = shift(@input_spool);
5021 return($line) if $line;
5028 # used in pass 1, use &next_line
5033 while ($_ = &next_line
) {
5034 return if /^\@end\s+$tag\s*$/;
5036 die "* Failed to find '$tag' after: " . $lines[$#lines];
5039 # used in pass 1 for l2h use &next_line
5044 while ($_ = &next_line
) {
5045 return $string if /^\@end\s+$tag\s*$/;
5046 # $_ =~ s/hbox/mbox/g;
5047 $string = $string.$_;
5049 die "* Failed to find '$tag' after: " . $lines[$#lines];
5053 # HTML stacking to have a better HTML output
5057 @html_stack = ('html');
5058 $html_element = 'body';
5063 push(@html_stack, $html_element);
5064 $html_element = $what;
5069 push(@html_stack, $html_element)
5070 if ($html_element && $html_element ne 'P');
5071 $html_element = $what;
5075 $html_element = pop(@html_stack);
5083 if ($elt eq $html_element) {
5084 $html_element = pop(@html_stack) if @html_stack;
5089 $html_element = pop(@html_stack) if @html_stack;
5094 local($what, $line) = @_;
5095 if ($T2H_DEBUG & $DEBUG_HTML)
5097 $what = "\n" unless $what;
5098 return("<!-- $line @html_stack, $html_element -->$what")
5103 # to debug the output...
5105 local($what, $line) = @_;
5106 return("<!-- $line -->$what")
5107 if $T2H_DEBUG & $DEBUG_HTML;
5116 $_ = substitute_style
($_);
5120 sub normalise_node
{
5127 $_ = substitute_style
($_);
5133 my ($node, $name, $descr) = @_;
5136 &normalise_node
($node);
5137 $href = $node2href{$node};
5142 $descr = SimpleTexi2Html
($descr);
5143 if ($T2H_NUMBER_SECTIONS && !$T2H_NODE_NAME_IN_MENU && $node2sec{$node})
5145 $entry = $node2sec{$node};
5150 &normalise_node
($name);
5151 $entry = ($name && ($name ne $node || ! $T2H_AVOID_MENU_REDUNDANCY)
5152 ?
"$name : $node" : $node);
5155 if ($T2H_AVOID_MENU_REDUNDANCY && $descr)
5157 my $clean_entry = $entry;
5158 $clean_entry =~ s/^.*? // if ($clean_entry =~ /^([A-Z]|\d+)\.[\d\.]* /);
5159 $clean_entry =~ s/[^\w]//g;
5160 my $clean_descr = $descr;
5161 $clean_descr =~ s/[^\w]//g;
5162 $descr = '' if ($clean_entry eq $clean_descr)
5164 push(@lines2,&debug
('<TR><TD ALIGN="left" VALIGN="TOP">' .
5165 &t2h_anchor
('', $href, $entry) .
5166 '</TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">' .
5168 "</TD></TR>\n", __LINE__
));
5170 elsif ($node =~ /^\(.*\)\w+/)
5172 push(@lines2,&debug
('<TR><TD ALIGN="left" VALIGN="TOP">' .
5174 '</TD><TD ALIGN="left" VALIGN="TOP">' . $descr .
5175 "</TD></TR>\n", __LINE__
))
5179 warn "$ERROR Undefined node of menu_entry ($node): $_";
5183 sub do_ctrl
{ "^$_[0]" }
5186 local($addr, $text) = split(/,\s*/, $_[0]);
5188 $text = $addr unless $text;
5189 &t2h_anchor
('', "mailto:$addr", $text);
5194 # l2h does this much better
5195 return &l2h_ToLatex
("{\\sc ".&unprotect_html
($_[0])."}") if ($T2H_L2H);
5201 return &l2h_ToLatex
("\$".&unprotect_html
($_[0])."\$") if ($T2H_L2H);
5202 return "<EM>".$text."</EM>";
5206 local($url, $text, $only_text) = split(/,\s*/, $_[0]);
5208 $text = $only_text if $only_text;
5209 $text = $url unless $text;
5210 &t2h_anchor
('', $url, $text);
5213 sub do_url
{ &t2h_anchor
('', $_[0], $_[0]) }
5217 return '<FONT SIZE="-1">' . $_[0] . '</FONT>';
5222 return "&$_[0]acute;" if $_[1] eq 'H';
5223 return "$_[0]." if $_[1] eq 'dotaccent';
5224 return "$_[0]*" if $_[1] eq 'ringaccent';
5225 return "$_[0]".'[' if $_[1] eq 'tieaccent';
5226 return "$_[0]".'(' if $_[1] eq 'u';
5227 return "$_[0]_" if $_[1] eq 'ubaraccent';
5228 return ".$_[0]" if $_[1] eq 'udotaccent';
5229 return "$_[0]<" if $_[1] eq 'v';
5230 return "&$_[0]cedil;" if $_[1] eq ',';
5231 return "$_[0]" if $_[1] eq 'dotless';
5236 local($texi_style, $text) = @_;
5239 $style = $style_map{$texi_style};
5240 if (defined($style)) { # known style
5241 if ($style =~ /^\"/) { # add quotes
5243 $text = "\`$text\'";
5245 if ($style =~ /^\&/) { # custom
5247 $text = &$style($text, $texi_style);
5248 } elsif ($style) { # good style
5249 $text = "<$style>$text</$style>";
5252 } else { # unknown style
5258 # remove Texinfo styles
5261 1 while(s/\@\w+{([^\{\}]+)}/$1/g);
5272 sub substitute_style
{
5274 local($changed, $done, $style, $text);
5276 &simple_substitutions
;
5281 while (/\@(\w+){([^\{\}]+)}/ || /\@(,){([^\{\}]+)}/) {
5282 $text = &apply_style
($1, $2);
5297 local($name, $href, $text, $newline, $extra_attribs) = @_;
5301 $result .= " NAME=\"$name\"" if $name;
5304 $href =~ s
|^$T2H_HREF_DIR_INSTEAD_FILE|./|
5305 if ($T2H_HREF_DIR_INSTEAD_FILE);
5306 $result .= ($href =~ /\"/ ?
" HREF='$href'" : " HREF=\"$href\"");
5308 $result .= " $extra_attribs" if $extra_attribs;
5309 $result .= ">$text</A>";
5310 $result .= "\n" if $newline;
5315 local(@MoY, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);
5317 @MoY = ('January', 'February', 'March', 'April', 'May', 'June',
5318 'July', 'August', 'September', 'October', 'November', 'December');
5319 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
5320 $year += ($year < 70) ?
2000 : 1900;
5321 # obachman: Let's do it as the Americans do
5322 return("$MoY[$mon], $mday $year");
5328 return("${docu_name}_$num.$docu_ext");
5333 return $node2href{$sec2node{$_[0]}};
5337 $docu_doc = &doc_href
(++$doc_num);
5340 sub t2h_print_lines
{
5341 my ($fh, $lines) = @_;
5343 $lines = $T2H_THIS_SECTION unless $lines;
5347 $_ = l2h_FromHtml
($_) if ($T2H_L2H);
5348 if (/^$PROTECTTAG/o) {
5354 $cnt += split(/\W*\s+\W*/);
5371 $what =~ s/\&/\&\#38;/g;
5372 $what =~ s/\</\&\#60;/g;
5373 $what =~ s/\>/\&\#62;/g;
5374 # restore anything in quotes
5375 # this fixes my problem where I had:
5376 # < IMG SRC="leftarrow.gif" ALT="<--" > but what if I wanted < in my ALT text ??
5377 # maybe byte stuffing or some other technique should be used.
5378 $what =~ s/\"([^\&]+)\&\#60;(.*)\"/"$1<$2"/g;
5379 $what =~ s/\"([^\&]+)\&\#62;(.*)\"/"$1>$2"/g;
5380 $what =~ s/\"([^\&]+)\&\#38;(.*)\"/"$1&$2"/g;
5381 # but recognize some HTML things
5382 $what =~ s/\&\#60;\/A\&\#62;/<\
/A>/g; # </A>
5383 $what =~ s/\&\#60;A ([^\&]+)\&\#62;/<A $1>/g; # <A [^&]+>
5384 $what =~ s/\&\#60;IMG ([^\&]+)\&\#62;/<IMG $1>/g; # <IMG [^&]+>
5388 sub unprotect_texi
{
5403 sub unprotect_html
{
5405 $what =~ s/\&\#38;/\&/g;
5406 $what =~ s/\&\#60;/\</g;
5407 $what =~ s/\&\#62;/\>/g;
5414 my $href = shift || $T2H_HREF{This
};
5415 $href =~ s/.*#(.*)$/$1/;
5416 print $fh qq{<A NAME
="$href"></A
>\n};
5419 ##############################################################################
5421 # These next few lines are legal in both Perl and nroff.
5425 'di \" finish diversion--previous line must be blank
5426 .nr nl 0-1 \" fake up transition to first page again
5427 .nr % 0 \" start at page 1
5428 '; __END__
############# From here on it's a standard manual page ############
5429 .so
/usr/local/man/man
1/texi2html
.1