Changeset 4e425a in git


Ignore:
Timestamp:
Jul 30, 1999, 12:37:05 PM (24 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
Children:
3d276d2b96d8b91e89923453839edc84b93c91ed
Parents:
9613a6779c21616f1854f49fb05fae3c10886d20
Message:
* lib2doc
* new parsing of help strings


git-svn-id: file:///usr/local/Singular/svn/trunk@3387 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
doc
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • doc/Makefile.lib2doc

    r9613a6 r4e425a  
    22##
    33## Makefiel for generation of docu for libraries
    4 ## $Id: Makefile.lib2doc,v 1.1 1999-07-28 11:36:31 obachman Exp $
     4## $Id: Makefile.lib2doc,v 1.2 1999-07-30 10:37:02 obachman Exp $
    55#####################################################################
    66
     
    1919## 2.) Set this to the name of your latex2html program, if you have latex2html
    2020##
    21 LATEX2HTML =
     21LATEX2HTML = latex2html
    2222
    2323
  • doc/lib2doc.texi

    r9613a6 r4e425a  
    1616@strong{Important:}
    1717@*To use @code{lib2doc}, you need
    18 to have @code{Singular}, @code{libparse}, and @code{perl} (version 5 or
     18to have @code{perl} (version 5 or
     19higher)  and @code{Singular} and @code{libparse} (version 1-3-4 or
    1920higher) installed on your system.
    20 
    2121
    2222To generate the documentation for a library, follow these steps:
  • doc/pl2doc.pl

    r9613a6 r4e425a  
    11#!/usr/local/bin/perl
    2 # $Id: pl2doc.pl,v 1.6 1999-07-28 11:36:32 obachman Exp $
     2# $Id: pl2doc.pl,v 1.7 1999-07-30 10:37:04 obachman Exp $
    33###################################################################
    44#  Computer Algebra System SINGULAR
     
    5555
    5656undef @procs; # will be again defined by OutLibInfo
     57$parsing = "info-string of lib $lib:";
    5758$ref = OutLibInfo(\*LDOC, $info, ! $no_fun);
    5859OutRef(\*LDOC, $ref) if $ref;
     
    9596      $table_is_open = 1;
    9697      # print help
     98      $parsing = "help-string of $lib:$procs[$i]:";
    9799      $ref = OutInfo(\*LDOC, $help{$procs[$i]});
    98100      print LDOC "\@end table\n";
     
    118120{
    119121 print LDOC <<EOT;
     122\@c ----------------------------------------------------------
     123\@node Index, , Singular libraries, Top
     124\@chapter Index
     125\@printindex cp
    120126
    121127\@bye
     
    124130 
    125131close(LDOC);
     132if ($error)
     133{
     134  print STDERR "ERROR: $error\n";
     135  exit(1);
     136}
    126137exit(0);
    127138
     
    134145  my ($FH, $info, $l_fun) = @_;
    135146  print $FH "\@c ---content LibInfo---\n";
    136     if ($info =~ /^\@/)
     147  if ($info =~ /^\@/)
    137148  {
    138149    print $FH $info;
     
    153164{
    154165  my ($FH, $info, $l_fun) = @_;
    155   if ($info =~ /^\s*\@/)
     166  if ($info =~ /^\@/)
    156167  {
    157168    print $FH $info;
     
    184195{
    185196  my $length = shift;
     197  my ($pline, $line, $text, $ptext, $special);
     198  my ($in_format, $in_example, $in_texinfo);
     199
    186200  $length = 0 unless $length;
    187   # insert @* infront of all lines whose previous line is shorter than
    188   # 60 characters
    189   $_ = ' ' x $length . $_;
    190   if (/^(.*)\n/)
    191   {
    192     $_ .= "\n";
    193     my $pline;
    194     my $line;
    195     my $ptext = $_;
    196     my $text = '';
    197     while ($ptext =~ /(.*)\n/g)
    198     {
    199       $line = $1;
    200       # break line if
    201       $text .= '@*'
    202         if ($line =~ /\w/ && $pline =~ /\w/ # line and prev line are not empty
    203             && $line !~ /^\s*\@\*/  # line does not start with @*
    204             && $pline !~ /\@\*\s*/  # prev line does not end with @*
    205             &&
    206             ((length($pline) < 60  && # prev line is shorter than 60 chars
    207               $pline !~ /\@code{.*?}/ # and does not contain @code, @math
    208               && $pline !~ /\@math{.*?}/)
    209              ||
    210              $line =~ /^\s*\w*\(.*?\)/ # $line starts with \w*(..)
    211              ||
    212              $pline =~ /^\s*\w*\(.*?\)[\s;:]*$/)); # prev line is only \w(..)
    213       $line =~ s/\s*$//;
    214       $text .= "$line\n";
    215       $pline = $line;
    216     }
    217     $_ = $text;
    218   }
    219   s/\t/ /g;
    220   s/\n +/\n/g;
    221   s/\s*$//g;
    222   s/ +/ /g;  # replace double whitespaces by one
    223   s/(\w+\(.*?\))/\@code{$1}/g;
    224   s/\@\*\s*/\@\*/g;
    225   s/(\@[^\*])/\@$1/g; # escape @ signs, except @*
    226   s/{/\@{/g; # escape {}
    227   s/}/\@}/g;
    228   # unprotect @@math@{@}, @code@{@}
    229   while (s/\@\@math\@{(.*?)\@}/\@math{$1}/g) {}
    230   while (s/\@\@code\@{(.*?)\@}/\@code{$1}/g) {}
    231   # remove @code{} inside @code{} and inside @math{}
    232   while (s/\@math{([^}]*)\@code{(.*?)}(.*)?}/\@math{$1$2$3}/g) {}
    233   while (s/\@code{([^}]*)\@code{(.*?)}(.*)?}/\@code{$1$2$3}/g) {}
     201  $_ .= "\n";
     202  $ptext = $_;
     203  while ($ptext =~ /(.*)\n/g)
     204  {
     205    $pline = $line;
     206    $line = $1;
     207    # check whether we are in protected env
     208    if ($in_format || $in_example || $in_texinfo)
     209    {
     210      # end protected env?
     211      if ($line =~ /^\s*\@end (format|example|texinfo)\s*$/)
     212      {
     213        if ($in_format && $1 eq 'format')
     214        {
     215          $in_format = 0;
     216          $text .= "$line\n";
     217        }
     218        elsif ($in_example && $1 eq 'example')
     219        {
     220          $in_example = 0;
     221          $text .= "\@end smallexample\n";
     222        }
     223        elsif ($in_texinfo && $1 eq 'texinfo')
     224        {
     225          $in_texinfo = 0;
     226          $text .= "\n";
     227        }
     228        else
     229        {
     230          $error = "While parsing $parsing: \@end $1 found without matching \@$1" unless $error;
     231        }
     232        next;
     233      }
     234      else
     235      {
     236        $text .= "$line\n";
     237        next;
     238      }
     239    }
     240    # look for @example, @format, @texinfo
     241    if ($line =~ /^\s*\@(example|format|texinfo)\s*$/)
     242    {
     243      $special = 1;
     244      if ($1 eq 'example')
     245      {
     246        $text .= "\@smallexample\n";
     247        $in_example = 1;
     248      }
     249      elsif ($1 eq 'format')
     250      {
     251        $text .= "$line\n";
     252        $in_format = 1;
     253      }
     254      else
     255      {
     256        $text .= "\n";
     257        $in_texinfo = 1;
     258      }
     259      next;
     260    }
     261    if ($line =~ /([^\@]|^)\@(code|math){(.*?)}/)
     262    {
     263      my $l = $line;
     264      $l =~ s/^\s*//;
     265      $l =~ s/\s$//;
     266      while ($l =~ /([^\@]|^)\@(code|math){(.*?)}/)
     267      {
     268        $text .= CleanAscii($`.$1);
     269        $text .= "\@$2\{$3\}";
     270        $l = $';
     271      }
     272      $special = 1;
     273      $text .= CleanAscii($l) . "\n";
     274      next;
     275    }
     276    # break line if
     277    $text .= '@*'
     278      if ($line =~ /\w/
     279          && $pline =~ /\w/      # line and prev line are not empty
     280          && $line !~ /^\s*\@\*/ # line does not start with @*
     281          && $pline !~ /\@\*\s*/ # prev line does not end with @*
     282          && length($pline) + $length < 60 # prev line is shorter than 60 chars
     283          && ! $special);        # prev line was not special line
     284    $line =~ s/^\s*//;
     285    $line =~ s/\s$//;
     286    $special = 0;
     287    $text .= CleanAscii($line) . "\n";
     288  }
     289  $_ = $text;
     290  s/^\s*//;
     291  s/\s*$//;
     292  $_ .= "\n";
     293  if ($in_format || $in_texinfo || $in_example)
     294  {
     295    $error = "While parsing $parsing: no matching \@end " .
     296      ($in_format ? "format" : ($in_texinfo ? "texinfo" : "example" )) .
     297        " found"
     298          unless $error;
     299  }
     300}
     301
     302sub CleanAscii
     303{
     304  my $a = shift;
     305  $a =~ s/(\@([^\*]|$))/\@$1/g; # escape @ signs, except @*, @{, @}
     306  $a =~ s/{/\@{/g; # escape {}
     307  $a =~ s/}/\@}/g;
     308  $a =~ s/\t/ /g;
     309  $a =~ s/ +/ /g;         
     310  return $a;
    234311}
    235312
     
    237314{
    238315  my ($FH, $item, $text, $l_fun) = @_;
     316  local $parsing  = $parsing . uc($item);
    239317
    240318  $item = lc $item;
     
    291369    return '';
    292370  }
    293 
     371  elsif ($item =~ m/keywords/i || m/keyphrases/i)
     372  {
     373    # index entries
     374    return OutKeywords($FH, $text);
     375  }
     376 
    294377  if (! $table_is_open)
    295378  {
     
    326409  s/\n/ /g;
    327410  FormatInfoText();
    328  
    329411  if ($l_fun)
    330412  {
    331     print $FH "* ${proc}:: $_\n";
     413    print $FH "* ${proc}:: $_";
    332414    push @procs, $proc;
    333415  }
     
    335417  {
    336418    print $FH "\@item \@code{$proc($procargs)}  ";
    337     print $FH "\n\@cindex $proc\n$_\n";
     419    print $FH "\n\@cindex $proc\n$_";
    338420  }
    339421}
     
    360442}
    361443
     444sub OutKeywords
     445{
     446  my ($FH, $kws) = @_;
     447  for $kw (split (/;/, $kws))
     448  {
     449    $kw =~ s/^\s*(.*?)\s*$/$1/;
     450    print $FH "\@cindex $kw\n";
     451  }
     452}
     453
    362454sub CleanUpExample
    363455{
     
    408500\@setfilename $hlp_file
    409501\@settitle Formatted manual of $lib.lib
     502\@paragraphindent 0
    410503\@c %**end of header
    411504
     
    426519\@menu
    427520* Singular libraries::
     521* Index::
    428522\@end menu
    429523
    430 \@node Singular libraries,,,Top
     524\@node Singular libraries, Index,,Top
    431525\@comment node-name,next, previous, up
    432526\@chapter Singular libraries
  • doc/t2h_singular.init

    r9613a6 r4e425a  
    6767EOT
    6868}
     69
     70# always use bottom navigation
     71$T2H_WORDS_IN_PAGE = 0;
    6972
    7073$T2H_VERTICAL_HEAD_NAVIGATION = 1;
  • doc/texi2html

    r9613a6 r4e425a  
    1 #!/usr/bin/perl
     1#!/usr/local/bin/perl
    22'di ';
    33'ig 00 ';
    4 # $Id: texi2html,v 1.7 1998-06-19 15:55:28 obachman Exp $
    5 # Description: Program to transform most Texinfo documents to HTML.
    6 # The plan is for the next version of makeinfo to support HTML output
    7 # directly, but until then ...
    8 
    9 $THISPROG = "texi2html 1.54";                   # program name and version
    10 # This version of texi2html is currently maintained at
    11 # ftp://ftp.cs.umb.edu/pub/tex/texi2html by kb@cs.umb.edu.
    12 
     4#+##############################################################################
     5#                                                                              #
     6# File: texi2html                                                              #
     7#                                                                              #
     8# Description: Program to transform most Texinfo documents to HTML             #
     9#                                                                              #
     10#-##############################################################################
     11
     12# From @(#)texi2html    1.52 01/05/98   
     13# $Id: texi2html,v 1.8 1999-07-30 10:37:05 obachman Exp $
     14# Homepage:
     15$T2H_HOMEPAGE = <<EOT;
     16http://www.mathematik.uni-kl.de/~obachman/Texi2html
     17EOT
     18# Authors: 
     19$T2H_AUTHORS = <<EOT;
     20Written (mainly) by: Lionel Cons, Lionel.Cons\@cern.ch
     21Currently maintained by : Olaf Bachmann, obachman\@mathematik.uni-kl.de
     22EOT
     23# Version:
     24$THISVERSION = "1.58";
     25$THISPROG = "texi2html $THISVERSION";   # program name and version
     26 
    1327# The man page for this program is included at the end of this file and can be
    1428# viewed using the command 'nroff -man texi2html'.
    1529# Please read the copyright at the end of the man page.
    1630
    17 # Fixme:
    18 # deal with @macro @unmacro @shorttitlepage @detailmenu @image
    19 # [plus more fixmes below]
    20 # Use <link>s for Up, Index, Glossary?
    21 # Inserting copyright links: Having texinfo markup for the online copyright
    22 #  would allow a link to that from wherever.
     31$T2H_TODAY = &pretty_date;              # like "20 September 1993"
     32($T2H_USER = (getpwuid ($<))[6]) =~ s/,.*//; # Who am i
     33
     34#+++############################################################################
     35#                                                                              #
     36# Initialization                                                               #
     37# Pasted content of File $T2H_HOME/texi2html.init                              #
     38#                                                                              #
     39#---############################################################################
     40
     41require "$ENV{T2H_HOME}/texi2html.init"; # Makefile:include
    2342
    2443#+++############################################################################
     
    3554$DEBUG_HTML  = 32;
    3655$DEBUG_USER  = 64;
    37 
    38 #$IMG_FIRST_ACTIVE  = "<IMG SRC=\"first-b.gif\">";
    39 #$IMG_FIRST_PASSIVE = "<IMG SRC=\"first-t.gif\">";
    40 #$IMG_LAST_ACTIVE   = "<IMG SRC=\"last-b.gif\">";
    41 #$IMG_LAST_PASSIVE  = "<IMG SRC=\"last-t.gif\">";
    42 #$IMG_NEXT_ACTIVE   = "<IMG SRC=\"next-b.gif\">";
    43 #$IMG_NEXT_PASSIVE  = "<IMG SRC=\"next-t.gif\">";
    44 #$IMG_PREV_ACTIVE   = "<IMG SRC=\"previous-b.gif\">";
    45 #$IMG_PREV_PASSIVE  = "<IMG SRC=\"previous-t.gif\">";
    46 #$IMG_TOC           = "<IMG SRC=\"toc-b.gif\">";
    47 $IMG_FIRST_ACTIVE  = "";
    48 $IMG_FIRST_PASSIVE = "";
    49 $IMG_LAST_ACTIVE   = "";
    50 $IMG_LAST_PASSIVE  = "";
    51 $IMG_NEXT_ACTIVE   = "<IMG SRC=\"images/next_motif.gif\">";
    52 $IMG_NEXT_PASSIVE  = "<IMG SRC=\"images/next_motif_gr.gif\">";
    53 $IMG_PREV_ACTIVE   = "<IMG SRC=\"images/previous_motif.gif\">";
    54 $IMG_PREV_PASSIVE  = "<IMG SRC=\"images/previous_motif_gr.gif\">";
    55 $IMG_TOC           = "<IMG SRC=\"images/contents_motif.gif\">";
    56 $IMG_LEFT          = "images/bg_left.gif";
    57 $IMG_RIGHT         = "images/bg_right.gif";
    58 
    59 $BIBRE = '\[[\w\/]+\]';                 # RE for a bibliography reference
     56$DEBUG_L2H   = 128;
     57
     58
     59$BIBRE = '\[[\w\/-]+\]';                # RE for a bibliography reference
    6060$FILERE = '[\/\w.+-]+';                 # RE for a file name
    6161$VARRE = '[^\s\{\}]+';                  # RE for a variable name
     
    6565
    6666$ERROR = "***";                         # prefix for errors and warnings
    67 $HOMEPAGE = "http://wwwcn.cern.ch/dci/texi2html/"; # program home page
    68 $TODAY = &pretty_date;                  # like "20 September 1993"
    69 $SPLITTAG = "<!-- SPLIT HERE -->\n";    # tag to know where to split
     67                                        # program home page
    7068$PROTECTTAG = "_ThisIsProtected_";      # tag to recognize protected sections
    71 $TOPTAG = "<!--top-->";         # tag to mark first node (end of preamble)
    72 $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//EN">';
    73 
     69
     70$CHAPTEREND = "<!-- End chapter -->\n"; # to know where a chpater ends
     71$SECTIONEND = "<!-- End section -->\n"; # to know where section ends
     72$TOPEND     = "<!-- End top     -->\n"; # to know where top ends
     73
     74 
    7475#
    7576# language dependent constants
     
    8182#$LDC_GOTO = 'Go to the';
    8283#$LDC_FOOT = 'Footnotes';
    83 # TODO: @def* shortcuts
     84#TODO: @def* shortcuts
    8485
    8586#
     
    141142               '`',  'grave',
    142143               '\'', 'acute',
    143                ',',  'cedil',
    144                # fixme: (not Latin1) = H d dotaccent dotless ringaccent
    145                # tieaccent u ubaraccent v
    146144               );
    147145
     
    152150               # cf. makeinfo.c
    153151               "*", "<BR>",             # HTML+
    154                " ", "&#160;",   # nbsp
     152               " ", " ",
     153               "\t", " ",
     154               "-", "&#173;",   # soft hyphen
    155155               "\n", "\n",
    156156               "|", "",
     157               'tab', '<\/TD><TD>',
    157158               # spacing commands
    158159               ":", "",
     
    160161               "?", "?",
    161162               ".", ".",
    162                "\t", " ",
    163                "-", "&#173;",   # soft hyphen
    164                'tab', '<TD>',
    165                '-', '',
     163               "-", "",
    166164               );
    167165
     
    171169%things_map = (
    172170               'TeX', 'TeX',
    173                'br', '<P>',             # paragraph break.  Gone from texinfo 3.9
     171               'br', '<P>',             # paragraph break
    174172               'bullet', '*',
    175                'copyright', '&#169;',
     173               'copyright', '(C)',
    176174               'dots', '...',
    177                'enddots', '....',
    178175               'equiv', '==',
    179176               'error', 'error-->',
     
    183180               'print', '-|',
    184181               'result', '=>',
    185                'today', $TODAY,
    186                # fixme: output these Latin1 characters as such rather
    187                # than as entities?
    188                'pounds', '&#163;',
    189                'questiondown', '&#191;',
    190                'ss', '&#223;',
    191                'exclamdown', '&#161;',
    192                'AA', '&#197;',
    193                'AE', '&#198;',
    194                'aa', '&#229;',
    195                'ae', '&#230;',
    196                'O', '&#216;',
    197                'o', '&#248;',
    198                # follow info rendering:
    199                'L', 'L\/',
    200                'l', 'l\/',
    201                'OE', 'OE',
    202                'oe', 'oe',
     182               'today', $T2H_TODAY,
     183               'aa', '&aring;',
     184               'AA', '&Aring;',
     185               'ae', '&aelig;',
     186               'AE', '&AElig;',
     187               'o',  '&oslash;',
     188               'O',  '&Oslash;',
     189               'ss', '&szlig;',
    203190               );
    204191
     
    206193# texinfo styles (@foo{bar}) to HTML ones
    207194#
    208 %style_l_map = (
    209               'center', 'CENTER',
    210               );
    211 
    212195%style_map = (
    213               'asis', '',               # ??
     196              'asis', '',
    214197              'b', 'B',
    215198              'cite', 'CITE',
    216199              'code', 'CODE',
    217               'ctrl', '&do_ctrl',       # special case (obsolete)
    218               'dfn', 'STRONG',          # DFN tag is illegal in the standard
     200              'ctrl', '&do_ctrl',       # special case
     201              'dfn', 'EM',              # DFN tag is illegal in the standard
    219202              'dmn', '',                # useless
     203              'email', '&do_email',     # insert a clickable email address
    220204              'emph', 'EM',
    221               'email', '&do_email',     # new special case
    222205              'file', '"TT',            # will put quotes, cf. &apply_style
    223206              'i', 'I',
    224               'image', '&do_image',     # in-line images
    225207              'kbd', 'KBD',
    226               'key', 'KBD',             # fixme: probably not <KBD>; possibly
    227                                         # enclose in angles like makeinfo now does
     208              'key', 'KBD',
     209              'math', '&do_math',
    228210              'r', '',                  # unsupported
    229211              'samp', '"SAMP',          # will put quotes, cf. &apply_style
     
    231213              'strong', 'STRONG',
    232214              't', 'TT',
    233               'titlefont', 'B',         # make it distinctive, at least
    234               'uref', '&do_uref',       # new special case
    235               'url', '&do_url',         # new special case
     215              'titlefont', '',          # useless
     216              'uref', '&do_uref',       # insert a clickable URL
     217              'url', '&do_url',         # insert a clickable URL
    236218              'var', 'VAR',
    237219              'w', '',                  # unsupported
    238 #             'math', 'I',              # not very useful, but at least italicize
    239               'math', '',               # don't want italic numbers
    240220              );
    241221
     
    246226               'display', 'PRE',
    247227               'example', 'PRE',
    248                'format', 'PRE', # fixme: shouldn't use tt, but can't avoid?
     228               'format', 'PRE',
    249229               'lisp', 'PRE',
    250230               'quotation', 'BLOCKQUOTE',
     
    304284# things to skip
    305285#
    306 %to_ignore = (
    307             'manual', 1,
    308             'end manual', 1,
    309             );
    310 
    311286%to_skip = (
    312287            # comments
    313288            'c', 1,
    314289            'comment', 1,
     290            'ifnotinfo', 1,
     291            'ifnottex', 1,
     292            'ifhtml', 1,
     293            'end ifhtml', 1,
     294            'end ifnotinfo', 1,
     295            'end ifnottex', 1,
    315296            # useless
     297            'detailmenu', 1,
     298            'direntry', 1,
    316299            'contents', 1,
    317300            'shortcontents', 1,
     
    322305            'titlepage', 1,
    323306            'end titlepage', 1,
    324             'dircategory', 1,
    325307            # unsupported commands (formatting)
    326308            'afourpaper', 1,
     
    328310            'finalout', 1,
    329311            'headings', 1,
     312            'sp', 1,
    330313            'need', 1,
    331314            'page', 1,
     
    340323            'vskip', 1,
    341324            'filbreak', 1,
    342             'centerchap', 1,
    343             'setchapterstyle', 1,
    344             'hyphenation', 1,
     325            'paragraphindent', 1,
    345326            # unsupported formats
    346327            'cartouche', 1,
     
    350331            );
    351332
    352 %append2num = (
    353                'A', 1,
    354                'B', 2,
    355                'C', 3,
    356                'D', 4,
    357                'E', 5,
    358                'F', 6,
    359                'G', 7,
    360                'H', 8,
    361                'I', 9,
    362                'J', 10,
    363                );
    364333#+++############################################################################
    365334#                                                                              #
     
    368337#---############################################################################
    369338
     339#
     340# flush stdout and stderr after every write
     341#
     342select(STDERR);
     343$| = 1;
     344select(STDOUT);
     345$| = 1;
     346
     347%value = ();                            # hold texinfo variables, see also -D
     348
    370349$use_bibliography = 1;
    371350$use_acc = 0;
    372 $debug = 0;
    373 $doctype = '';
    374 $check = 0;
    375 $expandinfo = 0;
    376 $use_glossary = 0;
    377 $invisible_mark = '';
    378 $use_iso = 0;
    379 @include_dirs = ();
    380 $show_menu = 0;
    381 $number_sections = 0;
    382 $split_node = 0;
    383 $split_chapter = 0;
    384 $monolithic = 0;
    385 $verbose = 0;
    386 $make_entry_page = 1;
    387 $make_menu_page = 1;
    388 $section_type = 0;
    389 $ignore_part = 0;
    390351$usage = <<EOT;
    391352This is $THISPROG
    392353To convert a Texinfo file to HMTL: $0 [options] file
    393   where options can be:
    394     -expandinfo    : use \@ifinfo sections, not \@iftex
    395     -glossary      : handle a glossary
    396     -invisible name: use 'name' as an invisible anchor
    397     -I dir         : search also for files in 'dir'
    398     -menu          : handle menus and don\'t do the ToC
    399     -monolithic    : output only one file including ToC
    400     -number        : number sections
    401     -split_chapter : split on main sections
    402     -split_node    : split on nodes
    403     -check         : check given file for possible Texinfo commands
    404     -usage         : print usage instructions
    405     -verbose       : verbose output
     354 where options can be:
     355  -expandinfo         : use \@ifinfo sections, not \@iftex
     356  -glossary           : handle a glossary
     357  -invisible name     : use 'name' as an invisible anchor
     358  -Dname              : define name like with \@set
     359  -I dir              : search also for files in 'dir'
     360  -index_file file    : use 'file' as index file
     361  -menu               : handle menus
     362  -number             : number sections
     363  -split node|chapter : split on node or chapter
     364  -short_ref          : cross references without section numbers
     365  -l2h                : use latex2html for \@math, \@tex, and \@sc
     366  -l2h_latex2html prog: use 'prog' as latex2html program
     367                        (default: 'latex2html')
     368  -l2h_tmp dir        : use 'dir' as temp dir for latex2html
     369  -l2h_clean          : remove temporary files generated by l2h extension
     370  -l2h_skip           : skip latex2html run (needs temporary files)
     371  -init_file 'file'   : use 'file' for texi2html and latex2html initialization
     372  -sidx               : index jump label to top of section
     373  -usage              : print usage instructions
     374  -verbose            : verbose output
    406375To check converted files: $0 -check [-verbose] files
    407376EOT
    408377
    409 while ($#ARGV >= 0 && $ARGV[0] =~ /^-/) {
     378while (@ARGV && $ARGV[0] =~ /^-/) {
    410379    $_ = shift(@ARGV);
    411380    if (/^-acc$/)            { $use_acc = 1; next; }
    412     if (/^-d(ebug)?(\d+)?$/) { $debug = $2 || shift(@ARGV); next; }
    413     if (/^-doctype$/)        { $doctype = shift(@ARGV); next; }
    414     if (/^-c(heck)?$/)       { $check = 1; next; }
    415     if (/^-e(xpandinfo)?$/)  { $expandinfo = 1; next; }
    416     if (/^-g(lossary)?$/)    { $use_glossary = 1; next; }
    417     if (/^-i(nvisible)?$/)   { $invisible_mark = shift(@ARGV); next; }
    418     if (/^-iso$/)            { $use_iso = 1; next; }
    419     if (/^-I(.+)?$/)         { push(@include_dirs, $1 || shift(@ARGV)); next; }
    420     if (/^-m(enu)?$/)        { $show_menu = 1; next; }
    421     if (/^-mono(lithic)?$/)  { $monolithic = 1; next; }
    422     if (/^-n(umber)?$/)      { $number_sections = 1; next; }
    423     if (/^-s(plit)?_?(n(ode)?|c(hapter)?)?$/) {
    424         if ($2 =~ /^n/) {
    425             $split_node = 1;
    426         } else {
    427             $split_chapter = 1;
    428         }
    429         next;
    430     }
    431     if (/^-v(erbose)?$/)     { $verbose = 1; next; }
    432     die $usage;
    433 }
    434 if ($check) {
    435     die $usage unless @ARGV > 0;
     381    if (/^-D(.+)?$/)         { $value{$1 || shift(@ARGV)} = 1; next; }
     382    if (/^-d(ebug)?(\d+)?$/) { $T2H_DEBUG = $2 || shift(@ARGV); next; }
     383    if (/^-doctype$/)        { $T2H_DOCTYPE = shift(@ARGV); next; }
     384    if (/^-c(heck)?$/)       { $T2H_CHECK = 1; next; }
     385    if (/^-e(xpand)?$/)      { $T2H_EXPAND = shift(@ARGV); next; }
     386    if (/^-g(lossary)?$/)    { $T2H_USE_GLOSSARY = 1; next; }
     387    if (/^-i(nvisible)?$/)   { $T2H_INVISIBLE_MARK = shift(@ARGV); next; }
     388    if (/^-I(.+)?$/)         { push(@T2H_INCLUDE_DIRS, $1 || shift(@ARGV)); next; }
     389    if (/^-iso$/)            { $T2H_USE_ISO = 1; next; }
     390    if (/^-init_file$/)     
     391    {
     392      $init_file = shift(@ARGV);
     393      if (-f $init_file)
     394      {
     395        print "# reading initialization file from $init_file\n"
     396          if ($T2H_VERBOSE);
     397        require($init_file);
     398      }
     399      else
     400      {
     401        print "$ERROR Error: can't read init file $int_file\n";
     402        $init_file = '';
     403      }
     404      next;
     405    }
     406    if (/^-l2h$/)            { $T2H_L2H     = 1;            next; }
     407    if (/^-l2h_l2h$/)        { $T2H_L2H_L2H = shift(@ARGV); next; }
     408    if (/^-l2h_skip$/)       { $T2H_L2H_SKIP= 1;            next; }
     409    if (/^-l2h_tmp$/)        { $T2H_L2H_TMP = shift(@ARGV); next; }
     410    if (/^-l2h_clean$/)      { $T2H_L2H_CLEAN= 1;            next; }
     411    if (/^-m(enu)?$/)        { $T2H_SHOW_MENU = 1; next; }
     412    if (/^-nu(mber)?$/)      { $T2H_NUMBER_SECTIONS = 1; next; }
     413    if (/^-o(ut_file)?$/)    { $T2H_OUT = shift (@ARGV);
     414                               undef $T2H_SPLIT; next;}   
     415    if (/^-p(refix)?$/)      { $T2H_PREFIX = shift(@ARGV); next; }
     416    if (/^-su(bdir)?$/)      { $T2H_SUBDIR = shift(@ARGV); next; }
     417    if (/^-short_e(xtn)?$/)  { $T2H_SHORTEXTN = 1; next; }
     418    if (/^-short_r(ef)?$/)   { $T2H_SHORT_REF = 1; next; }
     419    if (/^-si(dx)?$/)        { $T2H_SECTION_IDX = 1; next; }
     420    if (/^-s(plit)?$/)       { $T2H_SPLIT = shift(@ARGV); next;}
     421    if (/^-t(op_file)?$/)    { $T2H_TOP_FILE = shift (@ARGV); next;}   
     422    if (/^-v(erbose)?$/)     { $T2H_VERBOSE = 1; next; }
     423    if (/^-no_v(erbose)?$/)  { $T2H_VERBOSE = 0; next; }
     424    if (/^-vers(ion)?$/)     { print "$THISPROGRAM\n"; exit;}
     425    die "Unknown option: $_\n$usage";
     426}
     427if ($T2H_CHECK) {
     428    die "Need file to check\n$usage" unless @ARGV > 0;
    436429    &check;
    437430    exit;
    438431}
    439432
    440 if (($split_node || $split_chapter) && $monolithic) {
    441     warn "Can't use -monolithic with -split, -monolithic ignored.\n";
    442     $monolithic = 0;
    443 }
    444 if ($expandinfo) {
    445     $to_skip{'ifinfo'}++;
    446     $to_skip{'end ifinfo'}++;
    447 } else {
    448     $to_skip{'iftex'}++;
    449     $to_skip{'end iftex'}++;
    450 }
    451 $invisible_mark = '<IMG SRC="images/invisible.xbm" ALT="">' if $invisible_mark eq 'xbm';
    452 die $usage unless @ARGV == 1;
     433if ($T2H_EXPAND eq 'info')
     434{
     435  $to_skip{'ifinfo'} = 1;
     436  $to_skip{'end ifinfo'} = 1;
     437}
     438elsif ($T2H_EXPAND eq 'tex')
     439{
     440  $to_skip{'iftex'} = 1;
     441  $to_skip{'end iftex'} = 1;
     442 
     443}
     444
     445$T2H_INVISIBLE_MARK = '<IMG SRC="invisible.xbm">' if $T2H_INVISIBLE_MARK eq 'xbm';
     446
     447#
     448# file name buisness
     449#
     450die "Need exactly one file to translate\n$usage" unless @ARGV == 1;
    453451$docu = shift(@ARGV);
    454452if ($docu =~ /.*\//) {
     
    459457    $docu_name = $docu;
    460458}
    461 unshift(@include_dirs, $docu_dir);
     459unshift(@T2H_INCLUDE_DIRS, $docu_dir);
    462460$docu_name =~ s/\.te?x(i|info)?$//;     # basename of the document
    463 
    464 $docu_doc = "$docu_name.html";          # document's contents
    465 if ($monolithic) {
    466     $docu_toc = $docu_foot = $docu_doc;
    467 } else {
    468     $docu_toc  = "${docu_name}_toc.html";  # document's table of contents
    469     $docu_foot = "${docu_name}_foot.html"; # document's footnotes
    470     $docu_left = "${docu_name}_left.html";
    471     $docu_main = "index.html";
    472 }
     461$docu_name = $T2H_PREFIX if ($T2H_PREFIX);
     462
     463# subdir
     464if ($T2H_SUBDIR && ! $T2H_OUT)
     465{
     466  $T2H_SUBDIR =~ s|/*$||;
     467  unless (-d "$T2H_SUBDIR" && -w "$T2H_SUBDIR")
     468  {
     469    if ( mkdir($T2H_SUBDIR, oct(755)))
     470    {
     471      print "# created directory $T2H_SUBDIR\n" if ($T2H_VERBOSE);
     472    }
     473    else
     474    {
     475      warn "$ERROR can't create directory $T2H_SUBDIR. Put results into current directory\n";
     476      $T2H_SUBDIR = '';
     477    }
     478  }
     479}
     480
     481if ($T2H_SUBDIR && ! $T2H_OUT)
     482{
     483  $docu_rdir = "$T2H_SUBDIR/";
     484  print "# putting result files into directory $docu_rdir\n" if ($T2H_VERBOSE);
     485}
     486else
     487{
     488  if ($T2H_OUT && $T2H_OUT =~ m|(.*)/|)
     489  {
     490    $docu_rdir = "$1/";
     491    print "# putting result files into directory $docu_rdir\n" if ($T2H_VERBOSE);
     492  }
     493  else
     494  {
     495    print "# putting result files into current directory \n" if ($T2H_VERBOSE);
     496    $docu_rdir = '';
     497  }
     498}
     499
     500# extension
     501if ($T2H_SHORTEXTN)
     502{
     503  $docu_ext = "htm";
     504}
     505else
     506{
     507  $docu_ext = "html";
     508}
     509if ($T2H_TOP_FILE =~ /\..*$/)
     510{
     511  $T2H_TOP_FILE = $`.".$docu_ext";
     512}
     513else
     514{
     515  $T2H_TOP_FILE .= ".$docu_ext";
     516}
     517
     518# result files
     519if (! $T2H_OUT && ($T2H_SPLIT =~ /section/i || $T2H_SPLIT =~ /node/i))
     520{
     521  $T2H_SPLIT = 'section';
     522}
     523elsif (! $T2H_OUT && $T2H_SPLIT =~ /chapter/i)
     524{
     525  $T2H_SPLIT = 'chapter'
     526}
     527else
     528{
     529  undef $T2H_SPLIT;
     530}
     531
     532$docu_doc = "$docu_name.$docu_ext";             # document's contents
     533$docu_doc_file = "$docu_rdir$docu_doc";
     534if ($T2H_SPLIT)
     535{
     536  $docu_toc  = "${docu_name}_toc.$docu_ext"; # document's table of contents
     537  $docu_stoc = "${docu_name}_ovr.$docu_ext"; # document's short toc
     538  $docu_foot = "${docu_name}_fot.$docu_ext"; # document's footnotes
     539  $docu_about = "${docu_name}_abt.$docu_ext"; # about this document
     540  $docu_top  = $T2H_TOP_FILE;
     541}
     542else
     543{
     544  if ($T2H_OUT)
     545  {
     546    $docu_doc = $T2H_OUT;
     547    $docu_doc =~ s|.*/||;
     548  }
     549  $docu_toc = $docu_foot = $docu_stoc = $docu_about = $docu_top = $docu_doc;
     550}
     551
     552$docu_toc_file  = "$docu_rdir$docu_toc";
     553$docu_stoc_file = "$docu_rdir$docu_stoc";
     554$docu_foot_file = "$docu_rdir$docu_foot";
     555$docu_about_file = "$docu_rdir$docu_about";
     556$docu_top_file  = "$docu_rdir$docu_top";
    473557
    474558#
    475559# variables
    476560#
    477 %value = ();                            # hold texinfo variables
    478561$value{'html'} = 1;                     # predefine html (the output format)
    479 $value{'texi2html'} = '1.51a';          # predefine texi2html (the translator)
     562$value{'texi2html'} = $THISVERSION;     # predefine texi2html (the translator)
    480563# _foo: internal to track @foo
    481564foreach ('_author', '_title', '_subtitle',
     
    484567}
    485568%node2sec = ();                         # node to section name
     569%sec2node = ();                         # section to node name
    486570%node2href = ();                        # node to HREF
     571%node2next = ();                        # node to next
     572%node2prev = ();                        # node to prev
     573%node2up   = ();                        # node to up
    487574%bib2href = ();                         # bibliography reference to HREF
    488575%gloss2href = ();                       # glossary term to HREF
    489576@sections = ();                         # list of sections
    490 @left_index = ();
    491577%tag2pro = ();                          # protected sections
    492578
     
    505591# can I use ISO8879 characters? (HTML+)
    506592#
    507 if ($use_iso) {
     593if ($T2H_USE_ISO) {
    508594    $things_map{'bullet'} = "&bull;";
    509595    $things_map{'copyright'} = "&copy;";
     
    520606$extensions = 'texi2html.ext'; # extensions in working directory
    521607if (-f $extensions) {
    522     print "# reading extensions from $extensions\n" if $verbose;
     608    print "# reading extensions from $extensions\n" if $T2H_VERBOSE;
    523609    require($extensions);
    524610}
     
    527613    $extensions = "${progdir}texi2html.ext"; # extensions in texi2html directory
    528614    if (-f $extensions) {
    529         print "# reading extensions from $extensions\n" if $verbose;
     615        print "# reading extensions from $extensions\n" if $T2H_VERBOSE;
    530616        require($extensions);
    531617    }
    532618}
    533619
    534 print "# reading from $docu\n" if $verbose;
     620
     621print "# reading from $docu\n" if $T2H_VERBOSE;
     622
     623#########################################################################
     624#
     625# latex2html stuff
     626#
     627# latex2html conversions consist of three stages:
     628# 1) ToLatex: Put "latex" code into a latex file
     629# 2) ToHtml: Use latex2html to generate corresponding html code and images
     630# 3) FromHtml: Extract generated code and images from latex2html run
     631#
     632
     633##########################
     634# default settings
     635#
     636
     637# defaults for files and names
     638
     639sub l2h_Init
     640{
     641  local($root) = @_;
     642 
     643  return 0 unless ($root);
     644 
     645  $l2h_name =  "${root}_l2h";
     646 
     647  $l2h_latex_file = "$docu_rdir${l2h_name}.tex";
     648  $l2h_cache_file = "${docu_rdir}l2h_cache.pm";
     649  $T2H_L2H_L2H = "latex2html" unless ($T2H_L2H_L2H);
     650 
     651  # destination dir -- generated images are put there, should be the same
     652  # as dir of enclosing html document --
     653  $l2h_html_file = "$docu_rdir${l2h_name}.html";
     654  $l2h_prefix = "${l2h_name}_";
     655  return 1;
     656}
     657
     658
     659##########################
     660#
     661# First stage: Generation of Latex file
     662# Initialize with: l2h_InitToLatex
     663# Add content with: l2h_ToLatex($text) --> HTML placeholder comment
     664# Finish with: l2h_FinishToLatex
     665#
     666
     667$l2h_latex_preample = <<EOT;
     668% This document was automatically generated by the l2h extenstion of texi2html
     669% DO NOT EDIT !!!
     670\\documentclass{article}
     671\\usepackage{html}
     672\\begin{document}
     673EOT
     674
     675$l2h_latex_closing = <<EOT;
     676\\end{document}
     677EOT
     678
     679# return used latex 1, if l2h could be initalized properly, 0 otherwise
     680sub l2h_InitToLatex
     681{
     682  %l2h_to_latex = ();
     683  unless ($T2H_L2H_SKIP)
     684  {
     685    unless (open(L2H_LATEX, ">$l2h_latex_file"))
     686    {
     687      warn "$ERROR Error l2h: Can't open latex file '$latex_file' for writing\n";
     688      return 0;
     689    } 
     690    print "# l2h: use ${l2h_latex_file} as latex file\n" if ($T2H_VERBOSE);
     691    print L2H_LATEX $l2h_latex_preample;
     692  }
     693  # open database for caching
     694  l2h_InitCache();
     695  $l2h_latex_count = 0;
     696  $l2h_to_latex_count = 0;
     697  $l2h_cached_count = 0;
     698  return  1;
     699}
     700
     701# print text (1st arg) into latex file (if not already there), return
     702# HTML commentary which can be later on replaced by the latex2html
     703# generated text
     704sub l2h_ToLatex
     705{
     706  my($text) = @_;
     707  my($count);
     708 
     709  $l2h_to_latex_count++;
     710  $text =~ s/(\s*)$//;
     711 
     712  # try whether we can cache it
     713  my $cached_text = l2h_FromCache($text);
     714  if ($cached_text)
     715  {
     716    $l2h_cached_count++;
     717    return $cached_text;
     718  }
     719 
     720  # try whether we have text already on things to do
     721  unless ($count = $l2h_to_latex{$text})
     722  {
     723    $count = $l2h_latex_count;
     724    $l2h_latex_count++;
     725    $l2h_to_latex{$text} = $count;
     726    $l2h_to_latex[$count] = $text;
     727    unless ($T2H_L2H_SKIP)
     728    {
     729      print L2H_LATEX "\\begin{rawhtml}\n";
     730      print L2H_LATEX "<!-- l2h_begin ${l2h_name} ${count} -->\n";
     731      print L2H_LATEX "\\end{rawhtml}\n";
     732     
     733      print L2H_LATEX "$text\n";
     734     
     735      print L2H_LATEX "\\begin{rawhtml}\n";
     736      print L2H_LATEX "<!-- l2h_end ${l2h_name} ${count} -->\n";
     737      print L2H_LATEX "\\end{rawhtml}\n";
     738    }
     739  }
     740  return "<!-- l2h_replace ${l2h_name} ${count} -->";
     741}
     742
     743# print closing into latex file and close it
     744sub l2h_FinishToLatex
     745{
     746  local ($reused);
     747 
     748  $reused = $l2h_to_latex_count - $l2h_latex_count - $l2h_cached_count;
     749  unless ($T2H_L2H_SKIP)
     750  {
     751    print L2H_LATEX $l2h_latex_closing;
     752    close(L2H_LATEX);
     753  }
     754  print "# l2h: finished to latex ($l2h_cached_count cached, $reused reused, $l2h_latex_count contents)\n" if ($T2H_VERBOSE);
     755  unless ($l2h_latex_count)
     756  {
     757    l2h_Finish();
     758    return 0;
     759  }
     760  return 1;
     761}
     762
     763###################################
     764# Second stage: Use latex2html to generate corresponding html code and images
     765#
     766# l2h_ToHtml([$l2h_latex_file, [$l2h_html_dir]]):
     767#   Call latex2html on $l2h_latex_file
     768#   Put images (prefixed with $l2h_name."_") and html file(s) in $l2h_html_dir
     769#   Return 1, on success
     770#          0, otherwise
     771#
     772sub l2h_ToHtml
     773{
     774  local($call, $ext, $root, $dotbug);
     775 
     776  if ($T2H_L2H_SKIP)
     777  {
     778    print "# l2h: skipping latex2html run\n" if ($T2H_VERBOSE);
     779    return 1;
     780  }
     781 
     782  # Check for dot in directory where dvips will work
     783  if ($T2H_L2H_TMP)
     784  {
     785    if ($T2H_L2H_TMP =~ /\./)
     786    {
     787      warn "$ERROR Warning l2h: l2h_tmp dir contains a dot. Use /tmp, instead\n";
     788      $dotbug = 1;
     789    }
     790  }
     791  else
     792  {
     793    if (&getcwd =~ /\./)
     794    {
     795     warn "$ERROR Warning l2h: current dir contains a dot. Use /tmp as l2h_tmp dir \n";
     796     $dotbug = 1;
     797   }
     798  }
     799  # fix it, if necessary and hope that it works
     800  $T2H_L2H_TMP = "/tmp" if ($dotbug);
     801   
     802  $call = $T2H_L2H_L2H;
     803  # use init file, if specified
     804  $call = $call . " -init_file " . $init_file if ($init_file && -f $init_file);
     805  # set output dir
     806  $call .=  ($docu_rdir ? " -dir $docu_rdir" : " -no_subdir");
     807  # use l2h_tmp, if specified
     808  $call = $call . " -tmp $T2H_L2H_TMP" if ($T2H_L2H_TMP);
     809  # options we want to be sure of
     810  $call = $call ." -address 0 -info 0 -split 0 -no_navigation -no_auto_link";
     811  $call = $call ." -prefix ${l2h_prefix} $l2h_latex_file";
     812
     813  print "# l2h: executing '$call'\n" if ($T2H_VERBOSE);
     814  if (system($call))
     815  {
     816    warn "l2h ***Error: '${call}' did not succeed\n";
     817    return 0;
     818  }
     819  else
     820  {
     821    print "# l2h: latex2html finished successfully\n" if ($T2H_VERBOSE);
     822    return 1;
     823  }
     824}
     825
     826# this is directly pasted over from latex2html
     827sub getcwd {
     828    local($_) = `pwd`;
     829
     830    die "'pwd' failed (out of memory?)\n"
     831        unless length;
     832    chop;
     833    $_;
     834}
     835
     836
     837##########################
     838# Third stage: Extract generated contents from latex2html run
     839# Initialize with: l2h_InitFromHtml
     840#   open $l2h_html_file for reading
     841#   reads in contents into array indexed by numbers
     842#   return 1,  on success -- 0, otherwise
     843# Extract Html code with: l2h_FromHtml($text)
     844#   replaces in $text all previosuly inserted comments by generated html code
     845#   returns (possibly changed) $text
     846# Finish with: l2h_FinishFromHtml
     847#   closes $l2h_html_dir/$l2h_name.".$docu_ext"
     848
     849sub l2h_InitFromHtml
     850{
     851  local($h_line, $h_content, $count, %l2h_img);
     852
     853  if (! open(L2H_HTML, "<${l2h_html_file}"))
     854  {
     855    print "$ERROR Error l2h: Can't open ${l2h_html_file} for reading\n";
     856    return 0;
     857  }
     858  print "# l2h: use ${l2h_html_file} as html file\n" if ($T2H_VERBOSE);
     859
     860  $l2h_html_count = 0;
     861 
     862  while ($h_line = <L2H_HTML>)
     863  {
     864    if ($h_line =~ /^<!-- l2h_begin $l2h_name ([0-9]+) -->/)
     865    {
     866      $count = $1;
     867      $h_content = "";
     868      while ($h_line = <L2H_HTML>)
     869      {
     870        if ($h_line =~ /^<!-- l2h_end $l2h_name $count -->/)
     871        {
     872          chomp $h_content;
     873          chomp $h_content;
     874          $l2h_html_count++;
     875          $h_content = l2h_ToCache($count, $h_content);
     876          $l2h_from_html[$count] = $h_content;
     877          $h_content = '';
     878          last;
     879        }
     880        $h_content = $h_content.$h_line;
     881      }
     882      if ($hcontent)
     883      {
     884        print "$ERROR Warning l2h: l2h_end $l2h_name $count not found\n"
     885          if ($T2H_VERBOSE);
     886        close(L2H_HTML);
     887        return 0;
     888      }
     889    }
     890  }
     891  print "# l2h: Got $l2h_html_count of $l2h_latex_count html contents\n"
     892    if ($T2H_VERBOSE);
     893
     894  close(L2H_HTML);
     895  return 1;
     896}
     897
     898sub l2h_FromHtml
     899{
     900  local($text) = @_;
     901  local($done, $to_do, $count);
     902 
     903  $to_do = $text;
     904 
     905  while ($to_do =~ /([^\000]*)<!-- l2h_replace $l2h_name ([0-9]+) -->([^\000]*)/)
     906  {
     907    $to_do = $1;
     908    $count = $2;
     909    $done = $3.$done;
     910   
     911    $done = "<!-- l2h_end $l2h_name $count -->".$done
     912      if ($T2H_DEBUG & $DEBUG_L2H);
     913
     914    $done = &l2h_ExtractFromHtml($count) . $done;
     915
     916    $done = "<!-- l2h_begin $l2h_name $count -->".$done
     917      if ($T2H_DEBUG & $DEBUG_L2H);
     918  }
     919  return $to_do.$done;
     920}
     921
     922
     923sub l2h_ExtractFromHtml
     924{
     925  local($count) = @_;
     926 
     927  return $l2h_from_html[$count] if ($l2h_from_html[$count]);
     928 
     929  if ($count >= 0 && $count < $l2h_latex_count)
     930  {
     931    # now we are in trouble
     932    local($l_l2h, $_);
     933
     934    $l2h_extract_error++;
     935    print "$ERROR l2h: can't extract content $count from html\n"
     936      if ($T2H_VERBOSE);
     937    # try simple (ordinary) substition (without l2h)
     938    $l_l2h = $T2H_L2H;
     939    $T2H_L2H = 0;
     940    $_ = $l2h_to_latex{$count};
     941    $_ = &substitute_style($_);
     942    &unprotect_texi;
     943    $_ = "<!-- l2h: ". __LINE__ . " use texi2html -->" . $_
     944      if ($T2H_DEBUG & $DEBUG_L2H);
     945    $T2H_L2H = $l_l2h;
     946    return $_;
     947  }
     948  else
     949  {
     950    # now we have been incorrectly called
     951    $l2h_range_error++;
     952    print "$ERROR l2h: Request of $count content which is out of valide range [0,$l2h_latex_count)\n";
     953    return "<!-- l2h: ". __LINE__ . " out of range count $count -->"
     954      if ($T2H_DEBUG & $DEBUG_L2H);
     955    return "<!-- l2h: out of range count $count -->";
     956  }
     957}
     958   
     959sub l2h_FinishFromHtml
     960{
     961  if ($T2H_VERBOSE)
     962  {
     963    if ($l2h_extract_error + $l2h_range_error)
     964    {
     965      print "# l2h: finished from html ($l2h_extract_error extract and $l2h_range_error errors)\n";
     966    }
     967    else
     968    {
     969      print "# l2h: finished from html (no errors)\n";
     970    }
     971  }
     972}
     973
     974sub l2h_Finish
     975{
     976  l2h_StoreCache();
     977  if ($T2H_L2H_CLEAN)
     978  {
     979    print "# l2h: removing temporary files generated by l2h extension\n"
     980      if $T2H_VERBOSE;
     981    while (<"$docu_rdir$l2h_name"*>)
     982    {
     983      unlink $_;
     984    }
     985  }
     986  print "# l2h: Finished\n" if $T2H_VERBOSE;
     987  return 1;
     988}
     989
     990##############################
     991# stuff for l2h caching
     992#
     993
     994# I tried doing this with a dbm data base, but it did not store all
     995# keys/values. Hence, I did as latex2html does it
     996sub l2h_InitCache
     997{
     998  if (-r "$l2h_cache_file")
     999  {
     1000    my $rdo = do "$l2h_cache_file";
     1001    warn("$ERROR l2h Error: could not load $docu_rdir$l2h_cache_file: $@\n")
     1002      unless ($rdo);
     1003  }
     1004}
     1005
     1006sub l2h_StoreCache
     1007{
     1008  return unless $l2h_latex_count;
     1009 
     1010  my ($key, $value);
     1011  open(FH, ">$l2h_cache_file") || return warn"$ERROR l2h Error: could not open $docu_rdir$l2h_cache_file for writing: $!\n";
     1012
     1013 
     1014  while (($key, $value) = each %l2h_cache)
     1015  {
     1016    # escape stuff
     1017    $key =~ s|/|\\/|g;
     1018    $key =~ s|\\\\/|\\/|g;
     1019    # weird, a \ at the end of the key results in an error
     1020    # maybe this also broke the dbm database stuff
     1021    $key =~ s|\\$|\\\\|;
     1022    $value =~ s/\|/\\\|/g;
     1023    $value =~ s/\\\\\|/\\\|/g;
     1024    $value =~ s|\\\\|\\\\\\\\|g;
     1025    print FH "\n\$l2h_cache_key = q/$key/;\n";
     1026    print FH "\$l2h_cache{\$l2h_cache_key} = q|$value|;\n";
     1027  }
     1028  print FH "1;";
     1029  close(FH);
     1030}
     1031
     1032# return cached html, if it exists for text, and if all pictures
     1033# are there, as well
     1034sub l2h_FromCache
     1035{
     1036  my $text = shift;
     1037  my $cached = $l2h_cache{$text};
     1038  if ($cached)
     1039  {
     1040    while ($cached =~ m/SRC="(.*?)"/g)
     1041    {
     1042      unless (-e "$docu_rdir$1")
     1043      {
     1044        return undef;
     1045      }
     1046    }
     1047    return $cached;
     1048  }
     1049  return undef;
     1050}
     1051
     1052# insert generated html into cache, move away images,
     1053# return transformed html
     1054$maximage = 1;
     1055sub l2h_ToCache
     1056{
     1057  my $count = shift;
     1058  my $content = shift;
     1059  my @images = ($content =~ /SRC="(.*?)"/g);
     1060  my ($src, $dest);
     1061
     1062  for $src (@images)
     1063  {
     1064    $dest = $l2h_img{$src};
     1065    unless ($dest)
     1066    {
     1067      my $ext;
     1068      if ($src =~ /.*\.(.*)$/ && $1 ne $docu_ext)
     1069      {
     1070        $ext = $1;
     1071      }
     1072      else
     1073      {
     1074        warn "$ERROR: L2h image $src has invalid extension\n";
     1075        next;
     1076      }
     1077      while (-e "$docu_rdir${docu_name}_$maximage.$ext") { $maximage++;}
     1078      $dest = "${docu_name}_$maximage.$ext";
     1079      system("cp -f $docu_rdir$src $docu_rdir$dest");
     1080      $l2h_img{$src} = $dest;
     1081      unlink "$docu_rdir$src" unless ($DEBUG & DEBUG_L2H);
     1082    }
     1083    $content =~ s/$src/$dest/g;
     1084  }
     1085  $l2h_cache{$l2h_to_latex[$count]} = $content;
     1086  return $content;
     1087}
     1088
    5351089
    5361090#+++############################################################################
     
    5421096@lines = ();                            # whole document
    5431097@toc_lines = ();                        # table of contents
    544 @top_lines = ();                        # contents of top node
    545 @menu_lines = ();
    546 $toplevel = 0;                          # top level seen in hierarchy
     1098@stoc_lines = ();                       # table of contents
    5471099$curlevel = 0;                          # current level in TOC
    5481100$node = '';                             # current node name
     1101$node_next = '';                        # current node next name               
     1102$node_prev = '';                        # current node prev name
     1103$node_up = '';                          # current node up name
    5491104$in_table = 0;                          # am I inside a table
    550 $table_type = '';                       # type of table ('', 'f', 'v')
     1105$table_type = '';                       # type of table ('', 'f', 'v', 'multi')
    5511106@tables = ();                           # nested table support
    5521107$in_bibliography = 0;                   # am I inside a bibliography
    5531108$in_glossary = 0;                       # am I inside a glossary
    5541109$in_top = 0;                            # am I inside the top node
     1110$has_top = 0;                           # did I see a top node?
    5551111$in_pre = 0;                            # am I inside a preformatted section
    5561112$in_list = 0;                           # am I inside a list
    557 $in_html = 0;                           # am I inside an HTML section (@ifhtml)
    558 $in_raw_html = 0;                       # am I inside an HTML section (@html)
    559 $in_preamble = 1;                       # am I before the top node
     1113$in_html = 0;                           # am I inside an HTML section
    5601114$first_line = 1;                        # is it the first line
    5611115$dont_html = 0;                         # don't protect HTML on this line
    562 $split_num = 0;                         # split index
    5631116$deferred_ref = '';                     # deferred reference for indexes
    5641117@html_stack = ();                       # HTML elements stack
    5651118$html_element = '';                     # current HTML element
    5661119&html_reset;
    567 @raw_html = ();
     1120
     1121# init l2h
     1122$T2H_L2H = &l2h_Init($docu_name) if ($T2H_L2H);
     1123$T2H_L2H = &l2h_InitToLatex      if ($T2H_L2H);   
    5681124
    5691125# build code for simple substitutions
     
    6071163    $tag = '';
    6081164    $end_tag = '';
    609     if (/^\@end\s+(\w+)\b/) {
     1165    if (/^\s*\@end\s+(\w+)\b/) {
    6101166        $end_tag = $1;
    611     } elsif (/^\@(\w+)\b/) {
     1167    } elsif (/^\s*\@(\w+)\b/) {
    6121168        $tag = $1;
    6131169    }
    6141170    #
    615     # handle @ifhtml / @end ifhtml
     1171    # handle @html / @end html
    6161172    #
    6171173    if ($in_html) {
    618         if ($end_tag eq 'ifhtml') {
     1174        if ($end_tag eq 'html') {
    6191175            $in_html = 0;
    6201176        } else {
     
    6221178        }
    6231179        next;
    624     } elsif ($tag eq 'ifhtml') {
     1180    } elsif ($tag eq 'html') {
    6251181        $in_html = $PROTECTTAG . ++$html_num;
    626         push(@raw_html, $in_html);
     1182        push(@lines, $in_html);
    6271183        next;
    628     }
    629     #
    630     # do raw HTML (no escapes)
    631     #
    632     if ($in_raw_html) {
    633         if ($end_tag eq 'html') {
    634             $in_raw_html = 0;
    635         } else {
    636             push (@raw_html, $_);
    637         }
    638         next;
    639     } elsif ($tag eq 'html') {
    640         $in_raw_html = 1;
    6411184    }
    6421185    #
     
    6491192        last if $tag eq 'bye';
    6501193    }
    651 
    652     if ($end_tag) {
    653         if ($to_ignore{"end $end_tag"}) {
    654             $ignore_part = 0;
    655             next;
    656         }
    657     } elsif ($tag) {
    658         if ($to_ignore{$tag}) {
    659             $ignore_part = 1;
    660         }
    661     }
    662     next if $ignore_part;
    663 
     1194    if ($in_top) {
     1195        # parsing the top node
     1196        if ($tag eq 'node' || $tag eq 'include' || $sec2level{$tag}) {
     1197            # no more in top
     1198            $in_top = 0;
     1199            push(@lines, $TOPEND);
     1200        }
     1201    }
    6641202    #
    6651203    # try to remove inlined comments
    6661204    # syntax from tex-mode.el comment-start-skip
    6671205    #
    668     s/((^|[^\@])(\@\@)*)\@c(omment)? .*/$1/;
     1206    s/((^|[^\@])(\@\@)*)\@c(omment | |\{).*/$1/;
     1207#     s/((^|[^\@])(\@\@)*)\@c(omment)? .*/$1/;
     1208#     s/(.*)\@c{.*?}(.*)/$1$2/;
     1209#     s/(.*)\@comment{.*?}(.*)/$1$2/;
     1210#     s/^(.*)\@c /$1/;
     1211#     s/^(.*)\@comment /$1/;
    6691212    # non-@ substitutions cf. texinfmt.el
    670     s/``/\"/g;
    671     s/''/\"/g;
    672     s/([\w ])---([\w ])/$1--$2/g;
     1213    unless ($in_pre) {
     1214        s/``/\"/g;
     1215        s/''/\"/g;
     1216        s/([\w ])---([\w ])/$1--$2/g;
     1217    }
    6731218    #
    6741219    # analyze the tag
     
    6771222        # skip lines
    6781223        &skip_until($tag), next if $tag eq 'ignore';
    679         if ($expandinfo) {
    680             &skip_until($tag), next if $tag eq 'iftex';
    681         } else {
    682             &skip_until($tag), next if $tag eq 'ifinfo' &&
    683                 ! $in_preamble; # we want the contents of the top node
    684         }
    685         &skip_until($tag), next if $tag eq 'tex';
     1224        &skip_until($tag), next if $tag eq 'ifnothtml';
     1225        if ($tag eq 'ifinfo')
     1226        {
     1227          &skip_until($tag), next unless $T2H_EXPAND eq 'info';
     1228        }
     1229        if ($tag eq 'iftex')
     1230        {
     1231          &skip_until($tag), next unless $T2H_EXPAND eq 'tex';
     1232        }
     1233        if ($tag eq 'tex')
     1234        {
     1235          # add to latex2html file
     1236          if ($T2H_EXPAND eq 'tex' && $T2H_L2H && ! $in_pre)
     1237          {
     1238            # add space to the end -- tex(i2dvi) does this, as well
     1239            push(@lines, &l2h_ToLatex(&string_until($tag) . " "));
     1240          }
     1241          else
     1242          {
     1243            &skip_until($tag);
     1244          }
     1245          next;
     1246        }
    6861247        # handle special tables
    687         if ($tag eq 'table') {
    688             $table_type = '';
    689         } elsif ($tag eq 'ftable') {
     1248        if ($tag =~ /^(|f|v|multi)table$/) {
     1249            $table_type = $1;
    6901250            $tag = 'table';
    691             $table_type = 'f';
    692         } elsif ($tag eq 'vtable') {
    693             $tag = 'table';
    694             $table_type = 'v';
    695         } elsif ($tag eq 'multitable') {
    696             $tag = 'table';
    697             $table_type = '';
    6981251        }
    6991252        # special cases
    700         if ($tag eq 'top' || ($tag eq 'node' && /^\@node\s+Top\s*,/i)) {
    701             # We want to stash the contents of the top node (including
    702             # @ifinfo bits).
     1253        if ($tag eq 'top' || ($tag eq 'node' && /^\@node\s+top\s*,/i)) {
    7031254            $in_top = 1;
    704             $in_preamble = 0;
    705             #@lines = (); # ignore all lines before top (title page garbage)
    706             @lines = @raw_html;
     1255            $has_top = 1;
     1256            @lines = (); # ignore all lines before top (title page garbage)
    7071257            next;
    7081258        } elsif ($tag eq 'node') {
    709             push (@lines, "$TOPTAG") if ($in_top); # Mark end of top node
     1259          if ($in_top)
     1260          {
    7101261            $in_top = 0;
    711             $in_preamble = 0;
    712             warn "$ERROR Bad node line: $_" unless $_ =~ /^\@node\s$NODESRE$/o;
    713             $_ = &protect_html($_); # if node contains '&' for instance
    714             s/^\@node\s+//;
    715             ($node) = split(/,/);
    716             &normalise_node($node);
    717             if ($split_node) {
    718                 &next_doc;
    719                 push(@lines, $SPLITTAG) if $split_num++;
    720                 push(@sections, $node);
    721             }
    722             next;
     1262            push(@lines, $TOPEND);
     1263          }
     1264          warn "$ERROR Bad node line: $_" unless $_ =~ /^\@node\s$NODESRE$/o;
     1265          $_ = &protect_html($_); # if node contains '&' for instance
     1266          s/^\@node\s+//;
     1267          ($node, $node_next, $node_prev, $node_up) = split(/,/);
     1268          &normalise_node($node);
     1269          &normalise_node($node_next);
     1270          &normalise_node($node_prev);
     1271          &normalise_node($node_up);
     1272          next;
    7231273        } elsif ($tag eq 'include') {
    7241274            if (/^\@include\s+($FILERE)\s*$/o) {
    7251275                $file = $1;
    7261276                unless (-e $file) {
    727                     foreach $dir (@include_dirs) {
     1277                    foreach $dir (@T2H_INCLUDE_DIRS) {
    7281278                        $file = "$dir/$1";
    7291279                        last if -e $file;
     
    7321282                if (-e $file) {
    7331283                    &open($file);
    734                     print "# including $file\n" if $verbose;
     1284                    print "# including $file\n" if $T2H_VERBOSE;
    7351285                } else {
    7361286                    warn "$ERROR Can't find $file, skipping";
     
    7571307            next;
    7581308        } elsif ($tag eq 'menu') {
    759             unless ($show_menu) {
     1309            unless ($T2H_SHOW_MENU) {
    7601310                &skip_until($tag);
    7611311                next;
     
    7681318            push(@lines, &html_debug("\n", __LINE__));
    7691319            $in_list++ if $format_map{$tag} eq 'UL' || $format_map{$tag} eq 'OL' ;
     1320            push(@lines, &debug('<FONT size="-1">'."\n", __LINE__))
     1321               if $tag =~ /smallexample/i;
     1322            push(@lines, &debug("<BLOCKQUOTE>\n", __LINE__))
     1323              if $tag =~ /example/i;
    7701324            push(@lines, &debug("<$format_map{$tag}>\n", __LINE__));
    7711325            next;
    7721326        } elsif ($tag eq 'table') {
    773             if (/^\@[fv]?table\s+\@(\w+)\s*$/) {
    774                 $in_table = $1;
     1327            if (/^\s*\@(|f|v|multi)table\s+\@(\w+)/) {
     1328                $in_table = $2;
    7751329                unshift(@tables, join($;, $table_type, $in_table));
    776                 push(@lines, &debug("<DL COMPACT>\n", __LINE__));
    777                 &html_push_if('DL');
    778                 push(@lines, &html_debug("\n", __LINE__));
    779             } elsif (/^\@multitable\s+/) {
    780                 # Note descent to HTML 3.2 necessary for multitable.
    781                 $in_table = ' ';
    782                 unshift(@tables, join($;, $table_type, $in_table));
    783                 push(@lines, &debug("<TABLE>\n", __LINE__));
    784                 &html_push_if('TABLE');
     1330                if ($table_type eq "multi") {
     1331                    # don't use borders -- gets confused by empty cells
     1332                    push(@lines, &debug("<TABLE>\n", __LINE__));
     1333                    &html_push_if('TABLE');
     1334                } else {
     1335                    push(@lines, &debug("<DL COMPACT>\n", __LINE__));
     1336                    &html_push_if('DL');
     1337                }
    7851338                push(@lines, &html_debug("\n", __LINE__));
    7861339            } else {
     
    7981351            push(@lines, &debug("<P>\n", __LINE__));
    7991352            next;
     1353        } elsif ($tag eq 'center') {
     1354            push(@lines, &debug("<center>\n", __LINE__));
     1355            s/\@center//;
    8001356        } elsif ($tag eq 'setref') {
    8011357            &protect_html; # if setref contains '&' for instance
     
    8051361                $setref =~ s/ $//;
    8061362                $node2sec{$setref} = $name;
     1363                $sec2node{$name} = $setref;
    8071364                $node2href{$setref} = "$docu_doc#$docid";
    8081365            } else {
     
    8171374            }
    8181375            next;
    819         } elsif ($tag eq 'direntry') {
    820             &skip_until ($tag);
     1376        } elsif ($tag eq 'lowersections') {
     1377            local ($sec, $level);
     1378            while (($sec, $level) = each %sec2level) {
     1379                $sec2level{$sec} = $level + 1;
     1380            }
     1381            next;
     1382        } elsif ($tag eq 'raisesections') {
     1383            local ($sec, $level);
     1384            while (($sec, $level) = each %sec2level) {
     1385                $sec2level{$sec} = $level - 1;
     1386            }
    8211387            next;
    8221388        } elsif (defined($def_map{$tag})) {
     
    8301396            s/^\@$tag\s+//;
    8311397            $sub = $user_sub{$tag};
    832             print "# user $tag = $sub, arg: $_" if $debug & $DEBUG_USER;
     1398            print "# user $tag = $sub, arg: $_" if $T2H_DEBUG & $DEBUG_USER;
    8331399            if (defined(&$sub)) {
    8341400                chop($_);
     
    8651431            $type =~ s/^\{(.*)\}$/$1/;
    8661432            print "# def ($tag): {$type} ", join(', ', @args), "\n"
    867                 if $debug & $DEBUG_DEF;
     1433                if $T2H_DEBUG & $DEBUG_DEF;
    8681434            $type .= ':'; # it's nicer like this
    8691435            $name = shift(@args);
     
    9091475            &html_pop_if();
    9101476            push(@lines, &debug("</$format_map{$end_tag}>\n", __LINE__));
     1477            push(@lines, &debug("</BLOCKQUOTE>\n", __LINE__))
     1478              if $end_tag =~ /example/i;
     1479            push(@lines, &debug("</FONT>\n", __LINE__))
     1480               if $end_tag =~ /smallexample/i;
    9111481            push(@lines, &html_debug("\n", __LINE__));
    912         } elsif ($end_tag eq 'table' ||
    913                  $end_tag eq 'ftable' ||
    914                  $end_tag eq 'vtable' ||
    915                  $end_tag eq 'multitable') {
    916             shift(@tables);
     1482        } elsif ($end_tag =~ /^(|f|v|multi)table$/) {
     1483            unless (@tables) {
     1484                warn "$ERROR \@end $end_tag without \@*table\n";
     1485                next;
     1486            }
     1487            ($table_type, $in_table) = split($;, shift(@tables));
     1488            unless ($1 eq $table_type) {
     1489                warn "$ERROR \@end $end_tag without matching \@$end_tag\n";
     1490                next;
     1491            }
     1492            if ($table_type eq "multi") {
     1493                push(@lines, "</TR></TABLE>\n");
     1494                &html_pop_if('TR');
     1495            } else {
     1496                push(@lines, "</DL>\n");
     1497                &html_pop_if('DD');
     1498            }
     1499            &html_pop_if();
    9171500            if (@tables) {
    9181501                ($table_type, $in_table) = split($;, $tables[0]);
     
    9201503                $in_table = 0;
    9211504            }
    922             if ($end_tag eq 'multitable') {
    923                 push(@lines, "</TABLE>\n");
    924                 &html_pop_if('TABLE');
    925             } else {
    926             push(@lines, "</DL>\n");
    927             &html_pop_if('DD');
    928             }
    929             &html_pop_if();
    9301505        } elsif (defined($def_map{$end_tag})) {
    9311506            push(@lines, &debug("</DL>\n", __LINE__));
     
    9331508            &html_pop_if();
    9341509            push(@lines, $_); # must keep it for pass 2
    935         }
     1510        } 
    9361511        next;
    9371512    }
     
    9441519    $dont_html = 0;
    9451520    # substitution (unsupported things)
    946     # s/^\@center\s+//g;                # fixme: use <center> or <div align=center>?
    9471521    s/^\@exdent\s+//g;
    9481522    s/\@noindent\s+//g;
     
    9561530    #
    9571531    if ($tag) {
    958         if (defined($sec2level{$tag}) && $sec2level{$tag} > 0) {
     1532      if (defined($sec2level{$tag}) && $sec2level{$tag} > 0) {
    9591533            if (/^\@$tag\s+(.+)$/) {
    9601534                $name = $1;
    9611535                $name =~ s/\s+$//;
    9621536                $level = $sec2level{$tag};
    963 #               print "+++==>$tag<\n";
    964                 if ($number_sections && $tag !~ /heading$/) {
    965                     $name = &update_sec_num($tag, $level) . "  $name";
    966                     push(@left_index, $name);
    967                 }
    968 #               $name = &update_sec_num($tag, $level) . "  $name"
    969 #                   if $number_sections && $tag !~ /heading$/;
    970 #                   if $number_sections && $tag !~ /^unnumbered/;
    9711537                if ($tag =~ /heading$/) {
    9721538                    push(@lines, &html_debug("\n", __LINE__));
     
    9751541                        # even though we are not in the body level. So, we convert it to a
    9761542                        # nice, bold, line by itself.
    977                         $_ = &debug("\n\n<P><STRONG>$name</STRONG></P>\n\n", __LINE__);
     1543                        $_ = &debug("\n\n<P><STRONG>$name</STRONG>\n\n", __LINE__);
    9781544                    } else {
    9791545                        $_ = &debug("<H$level>$name</H$level>\n", __LINE__);
     
    9811547                    }
    9821548                    print "# heading, section $name, level $level\n"
    983                         if $debug & $DEBUG_TOC;
     1549                        if $T2H_DEBUG & $DEBUG_TOC;
    9841550                } else {
    985                     if ($split_chapter) {
    986                         unless ($toplevel) {
    987                             # first time we see a "section"
    988                             unless ($level == 1) {
    989                                 warn "$ERROR The first section found is not of level 1: $_";
    990                                 warn "$ERROR I'll split on sections of level $level...\n";
    991                             }
    992                             $toplevel = $level;
    993                         }
    994                         if ($level == $toplevel) {
    995                             &next_doc;
    996                             push(@lines, $SPLITTAG) if $split_num++;
    997                             push(@sections, $name);
    998                         }
     1551                $node = $name unless $node; 
     1552                $name = &update_sec_num($tag, $level) . " $name"
     1553                    if $T2H_NUMBER_SECTIONS && $tag !~ /^unnumbered/;
     1554                  if (defined($toplevel))
     1555                  {
     1556                    push @lines, ($level==$toplevel ? $CHAPTEREND : $SECTIONEND);
     1557                  }
     1558                  else
     1559                  {
     1560                    # first time we see a "section"
     1561                    unless ($level == 1)
     1562                    {
     1563                      warn "$ERROR The first section found is not of level 1: $_";
    9991564                    }
    1000                     $sec_num++;
    1001                     $docid = "SEC$sec_num";
    1002                     $tocid = "TOC$sec_num";
     1565                    $toplevel = $level;
     1566                  }
     1567                  push(@sections, $name);
     1568                  next_doc() if ($T2H_SPLIT eq 'section' ||
     1569                                 ($T2H_SPLIT && $level == $toplevel));
     1570                  $sec_num++;
     1571                  $docid = "SEC$sec_num";
     1572                  $tocid = "TOC$sec_num";
    10031573                    # check biblio and glossary
    1004                     $in_bibliography = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*bibliography$/i);
    1005                     $in_glossary = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*glossary$/i);
     1574                  $in_bibliography = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*bibliography$/i);
     1575                  $in_glossary = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*glossary$/i);
    10061576                    # check node
    1007                     if ($node) {
    1008                         if ($node2sec{$node}) {
    1009                             warn "$ERROR Duplicate node found: $node\n";
    1010                         } else {
     1577                    if ($node2sec{$node}) {
     1578                      warn "$ERROR Duplicate node found: $node\n";
     1579                    } else {
    10111580                            $node2sec{$node} = $name;
     1581                            warn "$ERROR Duplicate section found: $name\n"
     1582                              if ($sec2node{$name});
     1583                            $sec2node{$name} = $node;
    10121584                            $node2href{$node} = "$docu_doc#$docid";
     1585                            $node2next{$node} = $node_next;
     1586                            $node2prev{$node} = $node_prev;
     1587                            $node2up{$node} = $node_up;
    10131588                            print "# node $node, section $name, level $level\n"
    1014                                 if $debug & $DEBUG_TOC;
     1589                                if $T2H_DEBUG & $DEBUG_TOC;
    10151590                        }
    10161591                        $node = '';
    1017                     } else {
    1018                         print "# no node, section $name, level $level\n"
    1019                             if $debug & $DEBUG_TOC;
    1020                     }
     1592                        $node_next = '';
     1593                        $node_prev = '';
     1594                        $node_next = '';
    10211595                    # update TOC
    10221596                    while ($level > $curlevel) {
     
    10281602                        push(@toc_lines, "</UL>\n");
    10291603                    }
    1030                     $_ = "<LI>" . &anchor($tocid, "$docu_doc#$docid", '', $name, 1);
    1031                     push(@toc_lines, &substitute_style($_));
     1604                    $_ = &t2h_anchor($tocid, "$docu_doc#$docid", $name, 1);
     1605                    $_ = &substitute_style($_);
     1606                    push(@stoc_lines, "$_<BR>\n") if ($level == 1);
     1607                    push(@toc_lines, "<LI>" . $_ ."</LI>");
    10321608                    # update DOC
    10331609                    push(@lines, &html_debug("\n", __LINE__));
    10341610                    &html_reset;
    1035                     $_ =  "<H$level>".&anchor($docid, "$docu_toc#$tocid", '', $name)."</H$level>\n";
     1611#                   $_ =  "<H$level>".&t2h_anchor($docid, '', $name)."</H$level>\n";
     1612                    $_ =  "<H$level> $name </H$level>\n";                   
    10361613                    $_ = &debug($_, __LINE__);
    10371614                    push(@lines, &html_debug("\n", __LINE__));
     
    10611638                    next;
    10621639                }
    1063                 $id = 'IDX' . ++$idx_num;
     1640                $id = ($T2H_SECTION_IDX ? $docid : 'IDX' . ++$idx_num);
    10641641                $index = $1 . 'index';
    10651642                $what = &substitute_style($');
    10661643                $what =~ s/\s+$//;
    10671644                print "# found $index for '$what' id $id\n"
    1068                     if $debug & $DEBUG_INDEX;
     1645                    if $T2H_DEBUG & $DEBUG_INDEX;
    10691646                eval(<<EOC);
    10701647                if (defined(\$$index\{\$what\})) {
     
    10771654                # dirty hack to see if I can put an invisible anchor...
    10781655                #
    1079                 if ($html_element eq 'P' ||
     1656                unless ($T2H_SECTION_IDX) {
     1657                if (
     1658                    $html_element eq 'P' ||
    10801659                    $html_element eq 'LI' ||
    10811660                    $html_element eq 'DT' ||
     
    10861665                    $html_element eq 'PRE' ||
    10871666                    $html_element eq 'SAMP') {
    1088                     push(@lines, &anchor($id, '', '', $invisible_mark, !$in_pre));
     1667                    push(@lines, &t2h_anchor($id, '', $T2H_INVISIBLE_MARK, !$in_pre));
    10891668                } elsif ($html_element eq 'body') {
    10901669                    push(@lines, &debug("<P>\n", __LINE__));
    1091                     push(@lines, &anchor($id, '', '', $invisible_mark, !$in_pre));
     1670                    push(@lines, &t2h_anchor($id, '', $T2H_INVISIBLE_MARK, !$in_pre));
    10921671                    &html_push('P');
    10931672                } elsif ($html_element eq 'DL' ||
    10941673                         $html_element eq 'UL' ||
    10951674                         $html_element eq 'OL' ) {
    1096                     $deferred_ref .= &anchor($id, '', '', $invisible_mark, !$in_pre) . " ";
     1675                    $deferred_ref .= &t2h_anchor($id, '', $T2H_INVISIBLE_MARK, !$in_pre) . " ";
    10971676                }
     1677              }
    10981678                next;
    10991679            }
    11001680            # list item
    1101             if (/^\@itemx?\s+/) {
     1681            if (/^\s*\@itemx?\s+/) {
    11021682                $what = $';
    11031683                $what =~ s/\s+$//;
     
    11071687                        $bib2href{$what} = "$docu_doc#$id";
    11081688                        print "# found bibliography for '$what' id $id\n"
    1109                             if $debug & $DEBUG_BIB;
    1110                         $what = &anchor($id, '', '', $what);
     1689                            if $T2H_DEBUG & $DEBUG_BIB;
     1690                        $what = &t2h_anchor($id, '', $what);
    11111691                    }
    1112                 } elsif ($in_glossary && $use_glossary) {
     1692                } elsif ($in_glossary && $T2H_USE_GLOSSARY) {
    11131693                    $id = 'GLOSS' . ++$gloss_num;
    11141694                    $entry = $what;
     
    11161696                    $gloss2href{$entry} = "$docu_doc#$id";
    11171697                    print "# found glossary for '$entry' id $id\n"
    1118                         if $debug & $DEBUG_GLOSS;
    1119                     $what = &anchor($id, '', '', $what);
     1698                        if $T2H_DEBUG & $DEBUG_GLOSS;
     1699                    $what = &t2h_anchor($id, '', $what);
    11201700                }
    11211701                &html_pop_if('P');
     
    11321712                        unshift(@input_spool, "\@${table_type}index $what\n");
    11331713                    }
    1134                 } elsif ($html_element eq 'TABLE' || $html_element eq 'TR') {
    1135                     # Add <br> at ends of rows for non-tables browsers.
    1136                     push(@lines, "<BR>\n") if $html_element eq 'TR';
    1137                     push(@lines, "<TR>$what");
    1138                     &html_push('TR') unless $html_element eq 'TR';
     1714                } elsif ($html_element eq 'TABLE') {
     1715                    push(@lines, &debug("<TR><TD>$what</TD>\n", __LINE__));
     1716                    &html_push('TR');
     1717                } elsif ($html_element eq 'TR') {
     1718                    push(@lines, &debug("</TR>\n", __LINE__));
     1719                    push(@lines, &debug("<TR><TD>$what</TD>\n", __LINE__));
    11391720                } else {
    11401721                    push(@lines, &debug("<LI>$what\n", __LINE__));
     
    11471728                }
    11481729                next;
     1730            } elsif (/^\@tab\s+(.*)$/) {
     1731                push(@lines, "<TD>$1</TD>\n");
     1732                next;
    11491733            }
    11501734        }
     
    11541738        next if $#lines >= 0 && $lines[$#lines] eq "\n";
    11551739        if ($html_element eq 'P') {
    1156             push(@lines, "\n");
    1157             $_ = &debug("</P>\n", __LINE__);
    1158             &html_pop;
    1159         }
    1160     } elsif ($html_element eq 'body' || $html_element eq 'BLOCKQUOTE') {
    1161         push(@lines, "<P>\n");
    1162         &html_push('P');
    1163         $_ = &debug($_, __LINE__);
    1164     }
     1740            push (@lines, &debug("</P><P>\n", __LINE__));
     1741        }
     1742#       else
     1743#       {
     1744#         push(@lines, "<P></P>\n");
     1745#         $_ = &debug("<P></P>\n", __LINE__);
     1746#       }
     1747        elsif ($html_element eq 'body' || $html_element eq 'BLOCKQUOTE' || $html_element eq 'DD')
     1748        {
     1749          &html_push('P');
     1750          push(@lines, &debug("<P>\n", __LINE__));
     1751        }
     1752      }
    11651753    # otherwise
    11661754    push(@lines, $_);
     1755
     1756    push(@lines, &debug("</center>\n", __LINE__))  if ($tag eq 'center');
    11671757}
    11681758
     
    11741764}
    11751765
    1176 print "# end of pass 1\n" if $verbose;
     1766print "# end of pass 1\n" if $T2H_VERBOSE;
    11771767
    11781768#+++############################################################################
     
    11851775@lines3 = ();                           # whole document (3rd pass)
    11861776$in_menu = 0;                           # am I inside a menu
    1187 $in_top = 1;
    11881777
    11891778while (@lines) {
     
    11961785        next;
    11971786    }
    1198     if ($in_top && $_ eq "$TOPTAG") {
    1199         $in_top = 0;
    1200         while(@lines2) {
    1201             $_ = shift(@lines2);
    1202             if (/\@(\w+)\ /) {
    1203                 ($before, $style, $after) = ($`, $1, $');
    1204                 if (defined($style_l_map{$style})) {
    1205                     $_ = $after;
    1206                     $text = '';
    1207                     $after = '';
    1208                     $failed = 1;
    1209                     while (@lines2) {
    1210                         if (/\n/) {
    1211                             $text .= $`;
    1212                             $after = $';
    1213                             $failed = 0;
    1214                             last;
    1215                         } else {
    1216                             $text .= $_;
    1217                             $_ = shift(@lines2);
    1218                         }
    1219                     }
    1220                     if ($failed) {
    1221                         die "* Bad syntax (\@$style) after: $before\n";
    1222                     } else {
    1223                         $text = &apply_l_style($style, $text);
    1224                         $_ = "$before$text$after\n";
    1225                     }
    1226                 }
    1227             }
    1228             push(@top_lines, $_);
    1229         }
    1230         #@top_lines = @lines2;  # Contents of the top node.
    1231         @lines2 = ();           # Don't use them in place.
    1232         next;
    1233     }
    12341787    #
    12351788    # menu
    12361789    #
    1237     $in_menu = 1, push(@lines2, &debug("<UL>\n", __LINE__)), next if /^\@menu\b/;
    1238     $in_menu = 0, push(@lines2, &debug("</UL>\n", __LINE__)), next if /^\@end\s+menu\b/;
     1790    if (/^\@menu\b/)
     1791    {
     1792      $in_menu = 1;
     1793      $T2H_NUMBER_SECTIONS ?
     1794        push(@lines2, &debug("<BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> \n", __LINE__)) :
     1795          push(@lines2, &debug("<UL>\n", __LINE__));
     1796      next;
     1797    }
     1798    if (/^\@end\s+menu\b/)
     1799    {
     1800      $in_menu = 0;
     1801      $T2H_NUMBER_SECTIONS ?
     1802        push(@lines2, &debug("</TABLE></BLOCKQUOTE>\n", __LINE__)) :
     1803          push(@lines2, &debug("</UL>\n", __LINE__));
     1804      next;
     1805    }
    12391806    if ($in_menu) {
    12401807        if (/^\*\s+($NODERE)::/o) {
     
    12561823    # printindex
    12571824    #
    1258     if (/^\@printindex\s+(\w\w)\b/) {
    1259         local($index, *ary, @keys, $key, $letter, $last_letter, @refs);
     1825    # obachman: replace ^\@printindex by \@printindex, otherwise
     1826    # generation in debug mode fails
     1827    if (/\@printindex\s+(\w\w)\b/) {
     1828        local($index, *ary, @keys, $key, $letter, $last_letter, @refs, $fhidx);
    12601829        if ($predefined_index{$1}) {
    12611830            $index = $predefined_index{$1} . 'index';
    12621831        } else {
    12631832            $index = $1 . 'index';
     1833        }
     1834        # check for index summary
     1835        $letter = $1;
     1836        if ($letter =~ /$T2H_IDX_SUMMARY/)
     1837        {
     1838          open(FHIDX, "> $docu_rdir$docu_name" . "_$letter.idx")
     1839            || die "Can't open > $docu_rdir$docu_name" . "_$letter.idx for writing: $!\n";
     1840          $fhidx = \*FHIDX;
     1841          print "# writing index summary in $docu_rdir$docu_name" . "_$letter.idx..." if $T2H_VERBOSE;
    12641842        }
    12651843        eval("*ary = *$index");
     
    12741852            $key2alpha{$key} = $_;
    12751853            print "# index $key sorted as $_\n"
    1276                 if $key ne $_ && $debug & $DEBUG_INDEX;
    1277         }
     1854                if $key ne $_ && $T2H_DEBUG & $DEBUG_INDEX;
     1855        }
     1856        push(@lines2, "Jump to:\n");
     1857        $last_letter = undef;
     1858        foreach $key (sort byalpha @keys) {
     1859            $letter = substr($key2alpha{$key}, 0, 1);
     1860            $letter = substr($key2alpha{$key}, 0, 2) if $letter eq $;;
     1861            if (!defined($last_letter) || $letter ne $last_letter) {
     1862                push(@lines2, "-\n") if defined($last_letter);
     1863                push(@lines2, "<A HREF=\"#$index\_$letter\">" . &protect_html($letter) . "</A>\n");
     1864                $last_letter = $letter;
     1865            }
     1866        }
     1867        push(@lines2, "<P>\n");
    12781868        $last_letter = undef;
    12791869        foreach $key (sort byalpha @keys) {
     
    12821872            if (!defined($last_letter) || $letter ne $last_letter) {
    12831873                push(@lines2, "</DIR>\n") if defined($last_letter);
    1284                 push(@lines2, "<H2>" . &protect_html($letter) . "</H2>\n");
     1874                push(@lines2, "<H2><A NAME=\"$index\_$letter\">" . &protect_html($letter) . "</A></H2>\n");
    12851875                push(@lines2, "<DIR>\n");
    12861876                $last_letter = $letter;
     
    12881878            @refs = ();
    12891879            foreach (split(/$;/, $ary{$key})) {
    1290                 push(@refs, &anchor('', $_, '', $key, 0));
     1880                push(@refs, &t2h_anchor('', $_, $key, 0));
    12911881            }
    12921882            push(@lines2, "<LI>" . join(", ", @refs) . "\n");
     1883            if ($fhidx)
     1884            {
     1885              ($letter) = split(/$;/, $ary{$key});
     1886              $key = unprotect_html($key);
     1887              print $fhidx "$key\t$letter\n";
     1888            }
    12931889        }
    12941890        push(@lines2, "</DIR>\n") if defined($last_letter);
     1891        if ($fhidx)
     1892        {
     1893          print "\n" if $T2H_VERBOSE;
     1894          close($fhidx);
     1895        }
    12951896        next;
    12961897    }
     
    13061907        ($type, $nodes, $full) = ($1, $2, $3);
    13071908        ($before, $after) = ($`, $');
    1308         $ref_where = "Section";
    13091909        if (! $full && $after) {
    13101910            warn "$ERROR Bad xref (no ending } on line): $_";
     
    13491949        &normalise_node($node);
    13501950        $sec = $node2sec{$node};
    1351         $_ = $sec;
    1352         if (/^[A-Z]/) {
    1353             $ref_where = "Appendix";
    1354         }
     1951        $href = $node2href{$node};
    13551952        if (@args == 5) { # reference to another manual
    13561953            $sec = $args[2] || $node;
    13571954            $man = $args[4] || $args[3];
    1358             $_ = "${before}${type}$ref_where `$sec' in \@cite{$man}$after";
     1955            $_ = "${before}${type}section `$sec' in \@cite{$man}$after";
    13591956        } elsif ($type =~ /Info/) { # inforef
    13601957            warn "$ERROR Wrong number of arguments: $_" unless @args == 3;
    13611958            ($nn, $_, $in) = @args;
    13621959            $_ = "${before}${type} file `$in', node `$nn'$after";
    1363         } elsif ($sec) {
    1364             $href = $node2href{$node};
    1365             $_ = "${before}${type}" . &anchor('', $href, '', "$ref_where $sec") . $after;
    1366         } else {
     1960        } elsif ($sec && $href && ! $T2H_SHORT_REF) {
     1961            $_ = "${before}${type}section " .
     1962              &t2h_anchor('', $href, $sec) . $after;
     1963        }
     1964        elsif ($href && $T2H_SHORT_REF)
     1965        {
     1966          $_ = "${before}${type} " . &t2h_anchor('', $href, $node) . $after;
     1967        }
     1968        else {
    13671969            warn "$ERROR Undefined node ($node): $_";
    13681970            $_ = "$before$;0xref{$nodes}$after";
    13691971        }
    13701972    }
     1973   
     1974    if (/^\@image\s*{/) {
     1975      s/\@image\s*{//;
     1976      my (@args) = split (/,/);
     1977      my $base = $args[0];
     1978      my $image;
     1979      if (-r "$base.jpg") {
     1980        $image = "$base.jpg";
     1981      } elsif (-r "$base.png") {
     1982        $image = "$base.png";
     1983      } elsif (-r "$base.gif") {
     1984        $image = "$base.gif";
     1985      } else {
     1986        warn "$ERROR no image file for $base: $_";
     1987      }
     1988      $_ = "<IMG SRC=\"$image\" ALT=\"$base\">";
     1989    }
     1990
    13711991    #
    13721992    # try to guess bibliography references or glossary terms
     
    13791999                $href = $bib2href{$what};
    13802000                if (defined($href) && $post !~ /^[^<]*<\/A>/) {
    1381                     $done .= $pre . &anchor('', $href, '', $what);
     2001                    $done .= $pre . &t2h_anchor('', $href, $what);
    13822002                } else {
    13832003                    $done .= "$pre$what";
     
    13872007            $_ = $done . $_;
    13882008        }
    1389         if ($use_glossary) {
     2009        if ($T2H_USE_GLOSSARY) {
    13902010            $done = '';
    13912011            while (/\b\w+\b/) {
     
    13952015                $href = $gloss2href{$entry};
    13962016                if (defined($href) && $post !~ /^[^<]*<\/A>/) {
    1397                     $done .= $pre . &anchor('', $href, '', $what);
     2017                    $done .= $pre . &t2h_anchor('', $href, $what);
    13982018                } else {
    13992019                    $done .= "$pre$what";
     
    14072027    push(@lines2, $_);
    14082028}
    1409 print "# end of pass 2\n" if $verbose;
     2029print "# end of pass 2\n" if $T2H_VERBOSE;
    14102030
    14112031#
     
    14532073            }
    14542074        }
    1455         if (/\@(\w+)\ /) {
    1456             ($before, $style, $after) = ($`, $1, $');
    1457             if (defined($style_l_map{$style})) {
    1458                 $_ = $after;
    1459                 $text = '';
    1460                 $after = '';
    1461                 $failed = 1;
    1462                 while (@lines2) {
    1463                     if (/\n/) {
    1464                         $text .= $`;
    1465                         $after = $';
    1466                         $failed = 0;
    1467                         last;
    1468                     } else {
    1469                         $text .= $_;
    1470                         $_ = shift(@lines2);
    1471                     }
    1472                 }
    1473                 if ($failed) {
    1474                     die "* Bad syntax (\@$style) after: $before\n";
    1475                 } else {
    1476                     $text = &apply_l_style($style, $text);
    1477                     $_ = "$before$text$after";
    1478                 }
    1479             }
    1480         }
    14812075    }
    14822076    # otherwise
    14832077    push(@lines3, $_);
    14842078}
    1485 print "# end of pass 3\n" if $verbose;
    1486 
     2079print "# end of pass 3\n" if $T2H_VERBOSE;
     2080       
    14872081#+++############################################################################
    14882082#                                                                              #
     
    14942088@doc_lines = ();                        # final document
    14952089$end_of_para = 0;                       # true if last line is <P>
    1496 
     2090       
    14972091while (@lines3) {
    14982092    $_ = shift(@lines3);
     
    15322126            $footid = "FOOT$foot_num";
    15332127            $foot = "($foot_num)";
    1534             push(@foot_lines, "<H3>" . &anchor($footid, "$d#$docid", '', $foot) . "</H3>\n");
     2128            push(@foot_lines, "<H3>" . &t2h_anchor($footid, "$d#$docid", $foot) . "</H3>\n");
    15352129            $text = "<P>$text" unless $text =~ /^\s*<P>/;
    15362130            push(@foot_lines, "$text\n");
    1537             $_ = $before . &anchor($docid, "$docu_foot#$footid", '', $foot) . $after;
     2131            $_ = $before . &t2h_anchor($docid, "$docu_foot#$footid", $foot) . $after;
    15382132        }
    15392133    }
     
    15492143    push(@doc_lines, $_);
    15502144}
    1551 print "# end of pass 4\n" if $verbose;
    1552 
    1553 push(@menu_lines, "<BODY BACKGROUND=\"$IMG_LEFT\">\n");
    1554 push(@menu_lines, "<A HREF=\"http://www.mathematik.uni-kl.de/~zca/Singular\" TARGET=\"_parent\">");
    1555 push(@menu_lines, "<IMG SRC=\"images/singular-small.jpg\"></A><P>\n");
    1556 #push(@menu_lines, "<BODY BACKGROUND=\"/rock.gif\" TEXT=\"yellow\"");
    1557 #push(@menu_lines, " LINK=#FFFFFF ALINK=#FF00FF VLINK=\"#00FF00\">\n");
    1558 #push(@menu_lines, "<NOBR>\n");
    1559 push(@menu_lines, "<OL>\n");
    1560 foreach (@left_index) {
    1561     $entry = $_;
    1562     @part = split(/\ /);
    1563     $name = join(' ', @part[1..$#part]);
    1564     if (!/^[A-Z0-9]\./) {
    1565         &left_menu_entry($part[0], $name);
    1566     }
    1567 }
    1568 push(@menu_lines, "</OL>\n");
    1569 print "# end of pass 5\n" if $verbose;
     2145       
     2146print "# end of pass 4\n" if $T2H_VERBOSE;
    15702147
    15712148#+++############################################################################
    15722149#                                                                              #
    1573 # Pass 6: print things                                                         #
     2150# Pass 5: print things                                                         #
    15742151#                                                                              #
    15752152#---############################################################################
    15762153
    1577 $header = <<EOT;
    1578 <!-- This HTML file has been created by $THISPROG
    1579      from $docu on $TODAY -->
    1580 EOT
    1581 
    1582 $full_title = $value{'_title'} || $value{'_settitle'} || "Untitled Document";
    1583 $title = $value{'_settitle'} || $full_title;
    1584 $_ = &substitute_style($full_title);
    1585 &unprotect_texi;
    1586 s/\n$//; # rmv last \n (if any)
    1587 $full_title = "<H1>" . join("</H1>\n<H1>", split(/\n/, $_)) . "</H1>\n";
    1588 
    1589 #
    1590 # print ToC
    1591 #
    1592 # ... unless using menus instead.  Make the TOC lines empty rather than
    1593 # null so we get a ToC page with the top node (including menu).
    1594 @toc_lines = ("") if $show_menu;
    1595 
    1596 if (!$monolithic && @toc_lines) {
    1597     if (open(FILE, "> $docu_toc")) {
    1598         print "# creating $docu_toc...\n" if $verbose;
    1599         &print_header("$title - Table of Contents", "", 0);
    1600         # &print_toplevel_header("$title - Table of Contents");
    1601         &print_ruler;
    1602         &print (*top_lines, FILE); # Contents of the top node before the TOC.
    1603         &print(*toc_lines, FILE);
    1604         &print_toplevel_footer;
    1605         close(FILE);
    1606     } else {
    1607         warn "$ERROR Can't write to $docu_toc: $!\n";
    1608     }
    1609 }
    1610 
    1611 #
    1612 # print footnotes
    1613 #
    1614 if (!$monolithic && @foot_lines) {
    1615     if (open(FILE, "> $docu_foot")) {
    1616         print "# creating $docu_foot...\n" if $verbose;
    1617         &print_toplevel_header("$title - Footnotes");
    1618         &print_ruler;
    1619         &print(*foot_lines, FILE);
    1620         &print_toplevel_footer;
    1621         close(FILE);
    1622     } else {
    1623         warn "$ERROR Can't write to $docu_foot: $!\n";
    1624     }
    1625 }
    1626 
    1627 #
    1628 #
    1629 #
    1630 if (!$monolithic && $make_entry_page) {
    1631     if(open(FILE, "> $docu_main")) {
    1632         &print_header("$title - $docu_name", "", 1);
    1633         print "# creating $docu_main...\n" if $verbose;
    1634         #&print_frame($docu_name . "_1.html");
    1635         &print_frame($docu_toc);
    1636         &print_toplevel_footer;
    1637         close(FILE);
    1638     } else {
    1639         warn "$ERROR Can't write to $docu_main: $!\n";
    1640     }
    1641 }
    1642 
    1643 #
    1644 #
    1645 #
    1646 if (!$monolithic && $make_menu_page && @menu_lines) {
    1647     if(open(FILE, "> $docu_left")) {
    1648         &print_header("$title - $docu_left", "", 1);
    1649         print "# creating $docu_left...\n" if $verbose;
    1650         &print(*menu_lines, FILE);
    1651         &print_footer;
    1652         close(FILE);
    1653     } else {
    1654         warn "$ERROR Can't write to $docu_main: $!\n";
    1655     }
    1656 }
    1657 
    1658 #
    1659 # print document
    1660 #
    1661 if ($split_chapter || $split_node) { # split
    1662     $doc_num = 0;
    1663     $last_num = scalar(@sections);
    1664     $first_doc = &doc_name(1);
    1665     $last_doc = &doc_name($last_num);
    1666     while (@sections) {
    1667         $section = shift(@sections);
    1668         &next_doc;
    1669         if (open(FILE, "> $docu_doc")) {
    1670             print "# creating $docu_doc...\n" if $verbose;
    1671             $prev_doc = ($doc_num == 1 ? undef : &doc_name($doc_num - 1));
    1672             $next_doc = ($doc_num == $last_num ? undef : &doc_name($doc_num + 1));
    1673             $links = ($next_doc ? "<link href=\"$next_doc\" rel=Next>\n" : "");
    1674             $links .= ($prev_doc ? "<link href=\"$prev_doc\" rel=Previous>\n" : "");
    1675             $links .= "<link href=\"$docu_toc\" rel=ToC>\n";
    1676             # fixme: try rel=Index too?
    1677             &print_header("$title - $section", $links, 0);
    1678 
    1679             #$navigation = "<p>Go to the ";
    1680             $navigation = "<p>";
    1681             if ($IMG_FIRST_ACTIVE ne "") {
    1682                 $navigation .= ($prev_doc ? &anchor('', $first_doc, '',
    1683                              $IMG_FIRST_ACTIVE) : $IMG_FIRST_PASSIVE);
    1684                 $navigation .= " ";
    1685             }
    1686             $navigation .= ($prev_doc ? &anchor('', $prev_doc, '', $IMG_PREV_ACTIVE) : $IMG_PREV_PASSIVE);
    1687             $navigation .= " ";
    1688             $navigation .= ($next_doc ? &anchor('', $next_doc, '', $IMG_NEXT_ACTIVE) : $IMG_NEXT_PASSIVE);
    1689             if ($IMG_LAST_ACTIVE ne "") {
    1690                 $navigation .= " ";
    1691                 $navigation .= ($next_doc ? &anchor('', $last_doc, '',
    1692                              $IMG_LAST_ACTIVE) : $IMG_LAST_PASSIVE);
    1693             }
    1694             #$navigation .= " section, " . &anchor('', $docu_toc, '', "<IMG SRC=\"toc-b.gif\">") . ".\n";
    1695             $navigation .= " " . &anchor('', $docu_toc, '', $IMG_TOC) . "\n";
    1696             print FILE $navigation;
    1697             &print_ruler;
    1698             # find corresponding lines
    1699             @tmp_lines = ();
    1700             while (@doc_lines) {
    1701                 $_ = shift(@doc_lines);
    1702                 last if ($_ eq $SPLITTAG);
    1703                 push(@tmp_lines, $_);
    1704             }
    1705             &print(*tmp_lines, FILE);
    1706             &print_ruler;
    1707             print FILE $navigation;
    1708             &print_footer;
    1709             close(FILE);
    1710         } else {
    1711             warn "$ERROR Can't write to $docu_doc: $!\n";
    1712         }
    1713     }
    1714 } else { # not split
    1715     if (open(FILE, "> $docu_doc")) {
    1716         print "# creating $docu_doc...\n" if $verbose;
    1717         if ($monolithic || !@toc_lines) {
    1718             &print_toplevel_header($title);
    1719         } else {
    1720             &print_header($title, "", 0);
    1721             print FILE $full_title;
    1722         }
    1723         if ($monolithic && @toc_lines) {
    1724             &print_ruler;
    1725             print FILE "<H1>Table of Contents</H1>\n";
    1726             &print(*toc_lines, FILE);
    1727         }
    1728         &print_ruler;
    1729         &print(*doc_lines, FILE);
    1730         if ($monolithic && @foot_lines) {
    1731             &print_ruler;
    1732             print FILE "<H1>Footnotes</H1>\n";
    1733             &print(*foot_lines, FILE);
    1734         }
    1735         if ($monolithic || !@toc_lines) {
    1736             &print_toplevel_footer;
    1737         } else {
    1738             &print_footer;
    1739         }
    1740         close(FILE);
    1741     } else {
    1742         warn "$ERROR Can't write to $docu_doc: $!\n";
    1743     }
    1744 }
    1745 
    1746 print "# that's all folks\n" if $verbose;
     2154$T2H_L2H = &l2h_FinishToLatex if ($T2H_L2H);
     2155$T2H_L2H = &l2h_ToHtml        if ($T2H_L2H);
     2156$T2H_L2H = &l2h_InitFromHtml  if ($T2H_L2H);
     2157
     2158# prepare %T2H_THISDOC
     2159$T2H_THISDOC{fulltitle} = $value{'_title'} || $value{'_settitle'} || "Untitled Document";
     2160$T2H_THISDOC{title} = $value{'_settitle'} || $T2H_THISDOC{fulltitle};
     2161$T2H_THISDOC{author} = $value{'_author'};
     2162$T2H_THISDOC{subtitle} = $value{'_subtitle'};
     2163for $key (keys %T2H_THISDOC)
     2164{
     2165  $_ = &substitute_style($T2H_THISDOC{$key});
     2166  &unprotect_texi;
     2167  s/\s*$//;
     2168  $T2H_THISDOC{$key} = $_;
     2169}
     2170
     2171# if no sections, then simply print docuemnt as is
     2172unless (@sections)
     2173{
     2174  print "# Writing content into $docu_top_file \n" if $T2H_VERBOSE;
     2175  open(FILE, "> $docu_doc_file")
     2176    || die "$ERROR: Can't open $docu_doc_file for writing: $!\n";
     2177
     2178  t2h_print_page_head(\*FILE);
     2179  $T2H_THIS_SECTION = \@doc_lines;
     2180  t2h_print_lines(\*FILE);
     2181  t2h_print_page_foot(\*FILE);
     2182  close(FILE);
     2183  goto Finish;
     2184}
     2185
     2186# initialize $T2H_HREF, $T2H_NAME
     2187%T2H_HREF =
     2188  (
     2189   'First' ,   sec_href($sections[0]),
     2190   'Last',     sec_href($sections[$#sections]),
     2191   'About',     $docu_about. '#SEC_About',
     2192  );
     2193
     2194# prepare TOC, OVERVIEW, TOP
     2195$T2H_TOC = \@toc_lines;
     2196$T2H_OVERVIEW = \@stoc_lines;
     2197if ($has_top)
     2198{
     2199  while (1)
     2200  {
     2201    $_ = shift @doc_lines;
     2202    last if /$TOPEND/;
     2203    push @$T2H_TOP, $_;
     2204  }
     2205  $T2H_HREF{'Top'} = $docu_top . '#SEC_Top';
     2206}
     2207else
     2208{
     2209  $T2H_HREF{'Top'} = $T2H_HREF{First};
     2210}
     2211
     2212$node2href{Top} = $T2H_HREF{Top};
     2213$T2H_HREF{Contents} = $docu_toc.'#SEC_Contents' if @toc_lines;
     2214$T2H_HREF{Overview} = $docu_stoc.'#SEC_OVERVIEW' if @stoc_lines;
     2215$T2H_HREF{Index} = $node2href{'Index'};
     2216
     2217%T2H_NAME =
     2218  (
     2219   'First',   clean_name($sec2node{$sections[0]}),
     2220   'Last',    clean_name($sec2node{$sections[$#sections]}),
     2221   'About',    'About this document',
     2222   'Contents', 'Table of Contents',
     2223   'Overview', 'Overview (Short Table of Contents)',
     2224   'Index' ,   '',
     2225   'Top',      ''
     2226  );
     2227
     2228#############################################################################
     2229# print Top
     2230#
     2231open(FILE, "> $docu_top_file")
     2232  || die "$ERROR: Can't open $docu_top_file for writing: $!\n";
     2233if ($T2H_TOP)
     2234{
     2235  print "# Creating Top in $docu_top_file ...\n" if $T2H_VERBOSE;
     2236  t2h_print_page_head(\*FILE) unless ($T2H_SPLIT);
     2237  $T2H_THIS_SECTION = $T2H_TOP;
     2238  $T2H_HREF{This} = $T2H_HREF{Top};
     2239  $T2H_NAME{This} = $T2H_NAME{Top};
     2240  t2h_print_Top(\*FILE);
     2241 
     2242}
     2243close(FILE) if $T2H_SPLIT;
     2244
     2245#############################################################################
     2246# Print sections
     2247#
     2248$T2H_NODE{Forward} = $sec2node{$sections[0]};
     2249$T2H_NAME{Forward} = &clean_name($sec2node{$sections[0]});
     2250$T2H_HREF{Forward} = sec_href($sections[0]);
     2251$T2H_NODE{This} = 'Top';
     2252$T2H_NAME{This} = $T2H_NAME{Top};
     2253$T2H_HREF{This} = $T2H_HREF{Top};
     2254if ($T2H_SPLIT)
     2255{
     2256  print "# writing " . scalar(@sections) .
     2257    " sections in $docu_rdir$docu_name"."_[1.." .
     2258      ($T2H_SPLIT eq 'section' ? scalar(@sections) : scalar(@$T2H_OVERVIEW) ) .
     2259        "]" 
     2260          if $T2H_VERBOSE;
     2261  $previous = ($T2H_SPLIT eq 'chapter' ? $CHAPTEREND : $SECTIONEND);
     2262  undef $FH;
     2263  $doc_num = 0;
     2264}
     2265else
     2266{
     2267  print "# writing " . scalar(@sections) . " sections in $docu_top_file ..."
     2268    if $T2H_VERBOSE;
     2269  $FH = \*FILE;
     2270  $previous = '';
     2271}
     2272
     2273$counter = 0;
     2274# loop through sections
     2275while ($section = shift(@sections))
     2276{
     2277  if ($T2H_SPLIT && ($T2H_SPLIT eq 'section' || $previous eq $CHAPTEREND))
     2278  { # open new page
     2279    if ($FH)
     2280    { #close previous page
     2281      t2h_print_page_foot($FH);
     2282      close($FH);
     2283    }
     2284    &next_doc;
     2285    open(FILE, "> $docu_rdir$docu_doc") ||
     2286      die "$ERROR: Can't open $docu_rdir$docu_doc for writing: $!\n";
     2287    $FH = \*FILE;
     2288    t2h_print_page_head($FH);
     2289  }
     2290  $T2H_NAME{Back} = $T2H_NAME{This};
     2291  $T2H_HREF{Back} = $T2H_HREF{This};
     2292  $T2H_NODE{Back} = $T2H_NODE{This};
     2293  $T2H_NAME{This} = $T2H_NAME{Forward};
     2294  $T2H_HREF{This} = $T2H_HREF{Forward};
     2295  $T2H_NODE{This} = $T2H_NODE{Forward};
     2296  if ($sections[0])
     2297  {
     2298    $T2H_NODE{Forward} = $sec2node{$sections[0]};
     2299    $T2H_NAME{Forward} = &clean_name($T2H_NODE{Forward});
     2300    $T2H_HREF{Forward} = sec_href($sections[0]);
     2301  }
     2302  else
     2303  {
     2304    undef $T2H_HREF{Forward}, $T2H_NODE{Forward}, $T2H_NAME{Forward};
     2305  }
     2306
     2307  $node = $node2up{$T2H_NODE{This}};
     2308  $T2H_HREF{Up} = $node2href{$node};
     2309  if ($T2H_HREF{Up} eq $T2H_HREF{This} || ! $T2H_HREF{Up})
     2310  {
     2311    $T2H_NAME{Up} = $T2H_NAME{Top};
     2312    $T2H_HREF{Up} = $T2H_HREF{Top};
     2313    $T2H_NODE{Up} = 'Up';
     2314  }
     2315  else
     2316  {
     2317    $T2H_NAME{Up} = &clean_name($node);
     2318    $T2H_NODE{Up} = $node;
     2319  }
     2320
     2321  $node = $T2H_NODE{This};
     2322  $node = $node2prev{$node};
     2323  $T2H_NAME{Prev} = &clean_name($node);
     2324  $T2H_HREF{Prev} = $node2href{$node};
     2325  $T2H_NODE{Prev} = $node;
     2326
     2327  $node = $T2H_NODE{This};
     2328  if ($node2up{$node} && $node2up{$node} ne 'Top'&&
     2329      ($node2prev{$node} eq $T2H_NODE{Back} || ! $node2prev{$node}))
     2330  {
     2331    $node = $node2up{$node};
     2332    while ($node && $node ne $node2up{$node} && ! $node2prev{$node})
     2333    {
     2334      $node = $node2up{$node};
     2335    }
     2336    $node = $node2prev{$node}
     2337      unless $node2up{$node} eq 'Top' || ! $node2up{$node};
     2338  }
     2339  else
     2340  {
     2341    $node = $node2prev{$node};
     2342  }
     2343  $T2H_NAME{FastBack} = &clean_name($node);
     2344  $T2H_HREF{FastBack} = $node2href{$node};
     2345  $T2H_NODE{FastBack} = $node;
     2346 
     2347  $node = $T2H_NODE{This};
     2348  $node = $node2next{$node};
     2349  $T2H_NAME{Next} = &clean_name($node);
     2350  $T2H_HREF{Next} = $node2href{$node};
     2351  $T2H_NODE{Next} = $node;
     2352
     2353  $node = $T2H_NODE{This};
     2354  if ($node2up{$node} && $node2up{$node} ne 'Top'&&
     2355      ($node2next{$node} eq $T2H_NODE{Forward} || ! $node2next{$node}))
     2356  {
     2357    $node = $node2up{$node};
     2358    while ($node && $node ne $node2up{$node} && ! $node2next{$node})
     2359    {
     2360      $node = $node2up{$node};
     2361    }
     2362  }
     2363  $node = $node2next{$node};
     2364  $T2H_NAME{FastForward} = &clean_name($node);
     2365  $T2H_HREF{FastForward} = $node2href{$node};
     2366  $T2H_NODE{FastForward} = $node;
     2367
     2368  $T2H_THIS_SECTION = [];
     2369  while (@doc_lines) {
     2370    $_ = shift(@doc_lines);
     2371    last if ($_ eq $SECTIONEND || $_ eq $CHAPTEREND);
     2372    push(@$T2H_THIS_SECTION, $_);
     2373  }
     2374  $previous = $_;
     2375  t2h_print_label($FH);
     2376  t2h_print_section($FH);
     2377
     2378  if ($T2H_VERBOSE)
     2379  {
     2380    $counter++;
     2381    print "." if $counter =~ /00$/;
     2382  }
     2383}
     2384if ($T2H_SPLIT)
     2385{
     2386  t2h_print_page_foot($FH);
     2387  close($FH);
     2388}
     2389print "\n" if $T2H_VERBOSE;
     2390
     2391#############################################################################
     2392# Print ToC, Overview, Footnotes
     2393#
     2394undef $T2H_HREF{Prev};
     2395undef $T2H_HREF{Next};
     2396undef $T2H_HREF{Back};
     2397undef $T2H_HREF{Forward};
     2398undef $T2H_HREF{Up};
     2399
     2400if (@foot_lines)
     2401{
     2402  print "# writing Footnotes in $docu_foot_file...\n" if $T2H_VERBOSE;
     2403  open (FILE, "> $docu_foot_file") || die "$ERROR: Can't open $docu_foot_file for writing: $!\n"
     2404      if $T2H_SPLIT;
     2405  $T2H_HREF{This} = $docu_foot;
     2406  $T2H_NAME{This} = 'Footnotes';
     2407  $T2H_THIS_SECTION = \@foot_lines;
     2408  t2h_print_footnotes(\*FILE);
     2409  close(FILE) if $T2H_SPLIT;
     2410}
     2411
     2412if (@toc_lines)
     2413{
     2414  print "# writing Toc in $docu_toc_file...\n" if $T2H_VERBOSE;
     2415  open (FILE, "> $docu_toc_file") || die "$ERROR: Can't open $docu_toc_file for writing: $!\n"
     2416      if $T2H_SPLIT;
     2417  $T2H_HREF{This} = $T2H_HREF{Contents};
     2418  $T2H_NAME{This} = $T2H_NAME{Contents};
     2419  $T2H_THIS_SECTION = \@toc_lines;
     2420  t2h_print_Toc(\*FILE);
     2421  close(FILE) if $T2H_SPLIT;
     2422}
     2423
     2424if (@stoc_lines)
     2425{
     2426  print "# writing Overview in $docu_stoc_file...\n" if $T2H_VERBOSE;
     2427  open (FILE, "> $docu_stoc_file") || die "$ERROR: Can't open $docu_stoc_file for writing: $!\n"
     2428      if $T2H_SPLIT;
     2429 
     2430  $T2H_HREF{This} = $T2H_HREF{Overview};
     2431  $T2H_NAME{This} = $T2H_NAME{Overview};
     2432  $T2H_THIS_SECTION = \@stoc_lines;
     2433  t2h_print_Overview(\*FILE);
     2434  close(FILE) if $T2H_SPLIT;
     2435}
     2436
     2437if ($about_body = t2h_about_body())
     2438{
     2439  print "# writing About in $docu_about_file...\n" if $T2H_VERBOSE;
     2440  open (FILE, "> $docu_about_file") || die "$ERROR: Can't open $docu_about_file for writing: $!\n"
     2441      if $T2H_SPLIT;
     2442 
     2443  $T2H_HREF{This} = $T2H_HREF{About};
     2444  $T2H_NAME{This} = $T2H_NAME{About};
     2445  $T2H_THIS_SECTION = [$about_body];
     2446  t2h_print_About(\*FILE);
     2447  close(FILE) if $T2H_SPLIT;
     2448}
     2449
     2450unless ($T2H_SPLIT)
     2451{
     2452  t2h_print_page_foot(\*FILE);
     2453  close (FILE);
     2454}
     2455 
     2456Finish:
     2457&l2h_FinishFromHtml if ($T2H_L2H);
     2458&l2h_Finish if($T2H_L2H);
     2459print "# that's all folks\n" if $T2H_VERBOSE;
     2460
     2461exit(0);
    17472462
    17482463#+++############################################################################
     
    17522467#---############################################################################
    17532468
     2469sub clean_name
     2470{
     2471  local ($_);
     2472  $_ = &remove_style($_[0]);
     2473  &unprotect_texi;
     2474  return $_;
     2475}
     2476
    17542477sub update_sec_num {
    17552478    local($name, $level) = @_;
     2479    my $ret;
    17562480
    17572481    $level--; # here we start at 0
    1758     if (($name =~ /^appendix/) || ($section_type)) {
     2482    if ($name =~ /^appendix/ || defined(@appendix_sec_num)) {
    17592483        # appendix style
    1760         $section_type = 1;
    17612484        if (defined(@appendix_sec_num)) {
    17622485            &incr_sec_num($level, @appendix_sec_num);
     
    17642487            @appendix_sec_num = ('A', 0, 0, 0);
    17652488        }
    1766         return(join('.', @appendix_sec_num[0..$level]));
     2489        $ret = join('.', @appendix_sec_num[0..$level]);
    17672490    } else {
    17682491        # normal style
    1769         $section_type = 0;
    1770         if (defined(@normal_sec_num)) {
    1771             &incr_sec_num($level, @normal_sec_num);
    1772         } else {
    1773             @normal_sec_num = (1, 0, 0, 0);
    1774         }
    1775         return(join('.', @normal_sec_num[0..$level]));
    1776     }
     2492        if (defined(@normal_sec_num))
     2493        {
     2494          &incr_sec_num($level, @normal_sec_num);
     2495        }
     2496        else
     2497        {
     2498          @normal_sec_num = (1, 0, 0, 0);
     2499        }
     2500        $ret = join('.', @normal_sec_num[0..$level]);
     2501    }
     2502   
     2503    $ret .= "." if $level == 0;
     2504    return $ret;
    17772505}
    17782506
     
    17922520        if (/\@(\*|\.|\:|\@|\{|\})/) {
    17932521            $seen{$&}++;
    1794             $context{$&} .= "> $_" if $verbose;
     2522            $context{$&} .= "> $_" if $T2H_VERBOSE;
    17952523            $_ = "$`XX$'";
    17962524            redo;
     
    18002528            if ($before =~ /\b[\w-]+$/ && $after =~ /^[\w-.]*\b/) { # e-mail address
    18012529                $seen{'e-mail address'}++;
    1802                 $context{'e-mail address'} .= "> $_" if $verbose;
     2530                $context{'e-mail address'} .= "> $_" if $T2H_VERBOSE;
    18032531            } else {
    18042532                $seen{$match}++;
    1805                 $context{$match} .= "> $_" if $verbose;
     2533                $context{$match} .= "> $_" if $T2H_VERBOSE;
    18062534            }
    18072535            $match =~ s/^\@/X/;
     
    18122540   
    18132541    foreach (sort(keys(%seen))) {
    1814         if ($verbose) {
     2542        if ($T2H_VERBOSE) {
    18152543            print "$_\n";
    18162544            print $context{$_};
     
    18672595}
    18682596
     2597# used in pass 1 for l2h use &next_line
     2598sub string_until {
     2599    local($tag) = @_;
     2600    local($_, $string);
     2601
     2602    while ($_ = &next_line) {
     2603        return $string if /^\@end\s+$tag\s*$/;
     2604#       $_ =~ s/hbox/mbox/g;
     2605        $string = $string.$_;
     2606    }
     2607    die "* Failed to find '$tag' after: " . $lines[$#lines];
     2608}
     2609
    18692610#
    18702611# HTML stacking to have a better HTML output
     
    19112652    local($what, $line) = @_;
    19122653    return("<!-- $line @html_stack, $html_element -->$what")
    1913         if $debug & $DEBUG_HTML;
     2654        if $T2H_DEBUG & $DEBUG_HTML;
    19142655    return($what);
    19152656}
     
    19192660    local($what, $line) = @_;
    19202661    return("<!-- $line -->$what")
    1921         if $debug & $DEBUG_HTML;
     2662        if $T2H_DEBUG & $DEBUG_HTML;
    19222663    return($what);
    19232664}
     
    19292670}
    19302671
    1931 sub left_menu_entry {
    1932     local($secnum, $entry) = @_;
    1933     local($_);
    1934     local($href, $descr, $oltype,$value);
    1935 
    1936     $_ = $secnum;
    1937     $value = $secnum;
    1938     if (/[A-Z]/) {
    1939         $oltype = "<LI TYPE=A";
    1940         $value = $append2num{$secnum};
    1941     } else {
    1942         $oltype = "<LI";
    1943     }
    1944     $_ = $entry;
    1945     print "===>($secnum): $entry\n";
    1946     #s/^[0-9A-Z.]+ //;
    1947     $_ = $entry;
    1948     &normalise_node($_);
    1949     $href = $node2href{$_};
    1950     if ($href) {
    1951         $descr =~ s/^\s+//;
    1952         $descr = ": $descr" if $descr;
    1953         push(@menu_lines, "$oltype VALUE=$value>" . &anchor('', $href, "Main", $entry) . "$descr\n");
    1954         push(@menu_lines, "<P>\n");
    1955     } else {
    1956         warn "$ERROR Undefined node ($node): $_";
    1957     }
    1958 }
    1959 
    19602672sub menu_entry {
    19612673    local($entry, $node, $descr) = @_;
     
    19662678    if ($href) {
    19672679        $descr =~ s/^\s+//;
    1968         $descr = ": $descr" if $descr;
    1969         push(@lines2, "<LI>" . &anchor('', $href, '', $entry) . "$descr\n");
     2680        if ($T2H_NUMBER_SECTIONS)
     2681        {
     2682          $entry = $node2sec{$entry} if ! $descr && $node2sec{$entry};
     2683          push(@lines2,
     2684               '<TR><TD ALIGN="left">' .
     2685               &t2h_anchor('', $href, $entry) .
     2686               '</TD><TD ALIGN="left">' . $descr . "</TD><TR>\n");
     2687        }
     2688        else
     2689        {
     2690          push(@lines2, "<LI>" . &t2h_anchor('', $href, $entry) . ": $descr\n");
     2691        }
    19702692    } else {
    19712693        warn "$ERROR Undefined node ($node): $_";
     
    19732695}
    19742696
     2697sub do_ctrl { "^$_[0]" }
     2698
    19752699sub do_email {
    1976     my($address,$text);
    1977     ($address,$text) = split(/,/, "$_[0]");
    1978     $text =~ s/(^\s+)|(\s+$)//; # trim leading and trailing white space
    1979     $text = $address unless $text;
    1980     &anchor('', "mailto:${address}", '', "<TT>${text}</TT>")
    1981 }
    1982 
    1983 sub do_image {
    1984     my($base,$width,$height,$image);
    1985     ($base,$width,$height) = split(/,/,"$_[0]");
    1986     if ( -f "${base}.jpg" ) {
    1987         $image = "${base}.jpg";
    1988     } elsif ( -f "${base}.gif" ) {
    1989         $image = "${base}.gif";
    1990     } else {
    1991         $image = $base;
    1992         warn "$ERROR image not found for ($base): $_";
    1993     }
    1994     "<BR><IMG SRC=\"${image}\"><BR>";
     2700    local($addr, $text) = split(/,\s*/, $_[0]);
     2701
     2702    $text = $addr unless $text;
     2703    &t2h_anchor('', "mailto:$addr", $text);
     2704}
     2705
     2706sub do_sc
     2707{
     2708  # l2h does this much better
     2709  return &l2h_ToLatex("{\\sc ".&unprotect_html($_[0])."}") if ($T2H_L2H);
     2710  return "\U$_[0]\E";
     2711}
     2712
     2713sub do_math
     2714{
     2715  return &l2h_ToLatex("\$".&unprotect_html($_[0])."\$") if ($T2H_L2H);
     2716  return "<EM>".$text."</EM>";
    19952717}
    19962718
    19972719sub do_uref {
    1998   my($href,$text);
    1999   ($href,$text) = split(/,/,"$_[0]");
    2000   $text =~ s/(^\s+)|(\s+$)//;   # trim leading and trailing white space
    2001   $text = $href unless $text;
    2002 # args to anchor() are: ($name, $href, $text, $newline)
    2003   &anchor('', "$href", '', "<TT>$text</TT>")
    2004 }
    2005 
    2006 sub do_url {
    2007     my($address,$text);
    2008     ($address,$text) = split(/,/, "$_[0]");
    2009     $text =~ s/(^\s+)|(\s+$)//; # trim leading and trailing white space
    2010     $text = $address unless $text;
    2011     $address =~ s/&#173;//g;
    2012     &anchor('', "${address}", '_parent', "<TT>${text}</TT>")
    2013 }
    2014 
    2015 sub do_ctrl { "^$_[0]" }
    2016 
    2017 sub do_sc { "\U$_[0]\E" }
     2720    local($url, $text, $only_text) = split(/,\s*/, $_[0]);
     2721
     2722    $text = $only_text if $only_text;
     2723    $text = $url unless $text;
     2724    &t2h_anchor('', $url, $text);
     2725}
     2726
     2727sub do_url { &t2h_anchor('', $_[0], $_[0]) }
    20182728
    20192729sub apply_style {
     
    20222732
    20232733    $style = $style_map{$texi_style};
    2024     if (defined($style)) { # known style
    2025         if ($style =~ /^\"/) { # add quotes
    2026             $style = $';
    2027             $text = "\`$text\'";
    2028         }
    2029         if ($style =~ /^\&/) { # custom
    2030             $style = $';
    2031             $text = &$style($text);
    2032         } elsif ($style) { # good style
    2033             $text = "<$style>$text</$style>";
    2034         } else { # no style
    2035         }
    2036     } else { # unknown style
    2037         $text = undef;
    2038     }
    2039     return($text);
    2040 }
    2041 
    2042 sub apply_l_style {
    2043     local($texi_style, $text) = @_;
    2044     local($style);
    2045 
    2046     $style = $style_l_map{$texi_style};
    20472734    if (defined($style)) { # known style
    20482735        if ($style =~ /^\"/) { # add quotes
     
    20932780}
    20942781
    2095 sub anchor {
    2096     local($name, $href, $target, $text, $newline) = @_;
     2782sub t2h_anchor {
     2783    local($name, $href, $text, $newline) = @_;
    20972784    local($result);
    20982785
     
    21002787    $result .= " NAME=\"$name\"" if $name;
    21012788    $result .= " HREF=\"$href\"" if $href;
    2102     $result .= " TARGET=\"$target\"" if $target;
    21032789    $result .= ">$text</A>";
    21042790    $result .= "\n" if $newline;
     
    21092795    local(@MoY, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);
    21102796
    2111     @MoY = ('January', 'Febuary', 'March', 'April', 'May', 'June',
     2797    @MoY = ('January', 'February', 'March', 'April', 'May', 'June',
    21122798            'July', 'August', 'September', 'October', 'November', 'December');
    21132799    ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
    21142800    $year += ($year < 70) ? 2000 : 1900;
    2115     return("$mday $MoY[$mon] $year");
    2116 }
    2117 
    2118 sub doc_name {
     2801    # obachman: Let's do it as the Americans do
     2802    return("$MoY[$mon], $mday  $year");
     2803}
     2804
     2805sub doc_href {
    21192806    local($num) = @_;
    21202807
    2121     return("${docu_name}_$num.html");
     2808    return("${docu_name}_$num.$docu_ext");
     2809}
     2810
     2811sub sec_href
     2812{
     2813  return $node2href{$sec2node{$_[0]}};
    21222814}
    21232815
    21242816sub next_doc {
    2125     $docu_doc = &doc_name(++$doc_num);
    2126 }
    2127 
    2128 sub print {
    2129     local(*lines, $fh) = @_;
     2817    $docu_doc = &doc_href(++$doc_num);
     2818}
     2819
     2820sub t2h_print_lines {
     2821    my ($fh, $lines) = @_;
    21302822    local($_);
    2131 
    2132     while (@lines) {
    2133         $_ = shift(@lines);
     2823    $lines = $T2H_THIS_SECTION unless $lines;
     2824    my $cnt = 0;
     2825    for (@$lines)
     2826    {
     2827        $_ = l2h_FromHtml($_) if ($T2H_L2H);
    21342828        if (/^$PROTECTTAG/o) {
    21352829            $_ = $tag2pro{$_};
     
    21382832        }
    21392833        print $fh $_;
    2140     }
    2141 }
    2142 
    2143 sub print_ruler {
    2144     print FILE "<P><HR><P>\n";
    2145 }
    2146 
    2147 sub print_frame {
    2148     print FILE <<EOT;
    2149 <FRAMESET COLS="20%,*" BORDER=0>
    2150 <FRAME SRC="$docu_left" NAME="Links">
    2151 <FRAME SRC="$_[0]" NAME="Main">
    2152 </FRAMESET>
    2153 
    2154 EOT
    2155 }
    2156 
    2157 sub print_header {
    2158     local($_);
    2159 
    2160     $links = $_[1];
    2161     $is_frame = $_[2];
    2162     # clean the title
    2163     $_ = &remove_style($_[0]);
    2164     &unprotect_texi;
    2165     # print the header
    2166     if ($doctype eq 'html2') {
    2167         print FILE $html2_doctype; # Wrong if any multitable used
    2168     } elsif ($doctype) {
    2169         print FILE $doctype;
    2170     }
    2171     print FILE <<EOT;
    2172 <HTML>
    2173 <HEAD>
    2174 $header
    2175 <TITLE>$_</TITLE>
    2176 $links
    2177 </HEAD>
    2178 EOT
    2179     if(!$is_frame) { print FILE "<BODY background=\"$IMG_RIGHT\">\n"; }
    2180 }
    2181 
    2182 sub print_toplevel_header {
    2183     local($_);
    2184 
    2185     &print_header ($_[0], "", 0);
    2186     print FILE $full_title;
    2187     if ($value{'_subtitle'}) {
    2188         $value{'_subtitle'} =~ s/\n+$//;
    2189         foreach (split(/\n/, $value{'_subtitle'})) {
    2190             $_ = &substitute_style($_);
    2191             &unprotect_texi;
    2192             print FILE "<H2>$_</H2>\n";
    2193         }
    2194     }
    2195     if ($value{'_author'}) {
    2196         $value{'_author'} =~ s/\n+$//;
    2197         foreach (split(/\n/, $value{'_author'})) {
    2198             $_ = &substitute_style($_);
    2199             &unprotect_texi;
    2200 #           s/[\w.-]+\@[\w.-]+/<A HREF="mailto:$&">$&<\/A>/g;
    2201             print FILE "<ADDRESS>$_</ADDRESS>\n";
    2202         }
    2203     }
    2204     print FILE "<P>\n";
    2205 }
    2206 
    2207 sub print_footer {
    2208     print FILE <<EOT;
    2209 </BODY>
    2210 </HTML>
    2211 EOT
    2212 }
    2213 
    2214 sub print_toplevel_footer {
    2215     &print_ruler;
    2216     print FILE <<EOT;
    2217 <H6>This document was generated on $TODAY using the
    2218 <A HREF=\"$HOMEPAGE\" TARGET=\"_parent\">texi2html</A>
    2219 translator version 1.51a.</H6>
    2220 <H6>Modified by the Singular-Team 19.6.1998</H6>
    2221 EOT
    2222     &print_footer;
     2834        $cnt += split(/\W*\s+\W*/);
     2835    }
     2836    return $cnt;
    22232837}
    22242838
     
    22652879}
    22662880
     2881sub t2h_print_label
     2882{
     2883    my $fh = shift;
     2884    my $href = shift || $T2H_HREF{This};
     2885    $href =~ s/.*#(.*)$/$1/;
     2886    print $fh qq{<A NAME="$href"></A>\n};
     2887}
     2888
    22672889##############################################################################
    22682890
     
    22752897.nr % 0                 \" start at page 1
    22762898'; __END__ ############# From here on it's a standard manual page ############
    2277 .TH TEXI2HTML 1 "08/12/97"
     2899.TH TEXI2HTML 1 "01/05/98"
    22782900.AT 3
    22792901.SH NAME
    22802902texi2html \- a Texinfo to HTML converter
    22812903.SH SYNOPSIS
    2282 .B texi2html [OPTION]... FILE
     2904.B texi2html [options] file
    22832905.PP
    2284 .B texi2html -check [-verbose] FILE...
     2906.B texi2html -check [-verbose] files
    22852907.SH DESCRIPTION
    22862908.I Texi2html
     
    22952917.PP
    22962918.I Texi2html
     2919may furthermore use latex2html to generate HTML (code and/or images) for @math
     2920and @iftex tags (see the
     2921.B \-l2h
     2922option).
     2923.PP
     2924.I Texi2html
    22972925creates several files depending on the contents of the Texinfo file and on
    22982926the chosen options (see FILES).
     
    23012929.I texi2html
    23022930are closer to TeX than to Info, that's why
    2303 .I texi2html
    2304 converts @iftex sections and not @ifinfo ones by default. You can reverse
    2305 this with the \-expandinfo option.
    23062931.SH OPTIONS
    23072932.TP 12
     
    23122937to find the Texinfo commands that have been left in the HTML file.
    23132938.TP
    2314 .B \-expandinfo
    2315 Expand @ifinfo sections, not @iftex ones.
     2939.B \-expand info|tex|none
     2940Expand @ifinfo, or @iftex, or sections (default: info)
    23162941.TP
    23172942.B \-glossary
     
    23202945.TP
    23212946.B \-invisible \fIname\fP
    2322 Use \fIname\fP to create invisible destination anchors for index links. This is a workaround
    2323 for a known bug of many WWW browsers, including xmosaic.
     2947Use \fIname\fP to create invisible destination anchors for index links
     2948(you can for instance use the invisible.xbm file shipped with this program).
     2949This is a workaround for a known bug of many WWW browsers, including netscape.
    23242950.TP
    23252951.B \-I \fIdir\fP
     
    23412967.B \-split_node
    23422968Split the output into several HTML files (one per node).
     2969.TP
     2970.B \-l2h
     2971Use latex2html for content of @math and @tex tags. Content must be such that
     2972both, latex and tex, can translate it correctly. I.e., no tex-only constructs
     2973must be used.
     2974.TP
     2975.B \-l2h_latex2html \fIprog\fP 
     2976Use \fIprog\fP as latex2html program (default \fIlatex2html\fP).
     2977Program must be executable.
     2978.TP
     2979.B \-l2h_init \fIfile\fP 
     2980Use \fIfile\fP as latex2html init file. \fIfile\fP should be used to specify in which way latex2html handles mathematical expressions and formulas.
     2981
     2982Note that latex2html locates 
     2983(and uses) init-files in the following order (provided they exist):
     2984(1) global init file (usually in latex2html source dir)
     2985(2) $HOME/.latex2html_init
     2986(3) ./.latex2html_init
     2987(4) init file given on command line. 
     2988.TP
     2989.B \-l2h_dir \fIdir\fP
     2990Use \fIdir\fP as tmp dir for latex2html. This directory (resp. its path)
     2991must not contain a dot  (i.e., a ".").
     2992.TP
     2993.B \-l2h_clean
     2994remove all intermediate files generated by latex2html (prevents caching!) 
     2995.TP
     2996.B \-l2h_skip
     2997Do not really run latex2html. Use (kept) files of previous runs, instead.
    23432998.TP
    23442999.B \-usage
     
    23633018.B foo_foot.html
    23643019The footnotes (if any).
     3020.TP
     3021.B foo_l2h_img*
     3022Images generated by latex2html (if any).
    23653023.PP
    23663024When used with the
     
    23683026option, it creates several files (one per chapter or node), named
    23693027.B foo_n.html
    2370 (n being the indice of the chapter or node), instead of the single
     3028(n being the index of the chapter or node), instead of the single
    23713029.B foo.html
    23723030file.
     
    23813039.SH ADDITIONAL COMMANDS
    23823040.I texi2html
    2383 implements the following non-Texinfo commands:
     3041implements the following non-Texinfo commands (maybe they are in Texinfo now...):
    23843042.TP 16
    2385 .B @ifhtml
     3043.B @html
    23863044This indicates the start of an HTML section, this section will passed through
    2387 without any modofication.
     3045without any modification.
    23883046.TP
    2389 .B @end ifhtml
    2390 This indcates the end of an HTML section.
     3047.B @end html
     3048This indicates the end of an HTML section.
    23913049.SH VERSION
    2392 This is \fItexi2html\fP version 1.54, 1998-01-17
     3050This is \fItexi2html\fP version 1.56k, 1999-02-20.
    23933051.PP
    2394 The latest version of \fItexi2html\fP can be found at
    2395 ftp://ftp.cs.umb.edu/pub/tex/texi2html
     3052The latest version of \fItexi2html\fP and \fIlatex22html\fPcan be found in WWW, cf. URLs
     3053http://wwwinfo.cern.ch/dis/texi2html/
     3054.br
     3055http://texinfo.org/texi2html/
     3056.br
     3057http://www-dsed.llnl.gov/files/programs/unix/latex2html
     3058.br
    23963059.SH AUTHOR
    2397 The main author is Lionel Cons, CERN CN/DCI/UWS.
    2398 This version is maintained at ftp://ftp.cs.umb.edu/pub/tex/texi2html
    2399 by kb@cs.umb.edu.
     3060The main author is Lionel Cons, CERN IT/DIS/OSE, Lionel.Cons@cern.ch.
    24003061Many other people around the net contributed to this program.
    24013062.SH COPYRIGHT
     
    24123073World Wide Web (WWW).
    24133074.SH BUGS
    2414 This program does not understand all Texinfo commands (yet).
     3075This program does not understand all Texinfo commands (yet). A row of
     3076a  mutlicolumn table has to be in one line.
    24153077.PP
    24163078TeX specific commands (normally enclosed in @iftex) will be
    2417 passed u
     3079passed over unmodified, unless latex2html is enabled.
     3080.ex
Note: See TracChangeset for help on using the changeset viewer.