/[texi2html]/texi2html/texi2html.pl
ViewVC logotype

Diff of /texi2html/texi2html.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.149 by pertusus, Wed Aug 24 14:33:20 2005 UTC revision 1.150 by pertusus, Sun Aug 28 08:39:55 2005 UTC
# Line 440  $complex_format_map Line 440  $complex_format_map
440  %accent_letters  %accent_letters
441  %unicode_accents  %unicode_accents
442  %special_accents  %special_accents
443    @command_handler_init
444    @command_handler_process
445    @command_handler_finish
446    %command_handler
447  );  );
448    
449  $I = \&Texi2HTML::I18n::get_string;  $I = \&Texi2HTML::I18n::get_string;
# Line 1157  foreach my $special ('footnote', 'ref', Line 1161  foreach my $special ('footnote', 'ref',
1161  my @raw_regions = ('html', 'verbatim', 'tex', 'xml', 'docbook');  my @raw_regions = ('html', 'verbatim', 'tex', 'xml', 'docbook');
1162    
1163  # special raw formats which are expanded between second and third pass  # special raw formats which are expanded between second and third pass
1164  # and are replaced by specific commands. Currently used for tex. It takes  # and are replaced by specific commands. It takes precedence over
1165  # precedence over raw_regions.  # raw_regions.
1166  # Currently there is no integrated handling of such regions. The collecting  #FIXME it is not modifiable by the user!
 # of special sections is generic, they are collected by init_special during  
 # the second phase, so calling a user function reference should be trivial.  
 # then init_special would remember which @-command is associated with  
 # which user defined function and add a mangled @-command like  
 # @t2h_special_command_nr  
 # remark: this is not problematic, the only gotcha is that it shouldn't  
 # intersect with user undefined @-commands (nor with texinfo commands!).  
 # However the replacement is done by matching @tex_(\d+). Maybe a generic  
 # interface would be to have the @-commands names set by init_special  
 # in a hash and expand them by calling the correponding function.  
1167  my @special_regions = ();  my @special_regions = ();
1168    
 # the handling of @math is ad-hoc, it should be more generic. More  
 # precisely this is a special command. The special commands should be  
 # collect by init_special and handled like special regions.    
   
 # there should be more hooks for user defined functions, at least  
 # one after the first pass with all the possible information (file  
 # names), between the pass 2 and 3, that mark that all the special  
 # regions have been collected, and one after the pass 3 for cleaning.  
 # This is currently what is done with Latex2HTML.  
   
1169  # regions expanded or not depending on the value of this hash  # regions expanded or not depending on the value of this hash
1170  my %text_macros = (  my %text_macros = (
1171       'iftex' => 0,       'iftex' => 0,
# Line 2310  if (@ARGV > 1) Line 2294  if (@ARGV > 1)
2294  $T2H_DEBUG = $Texi2HTML::Config::DEBUG;  $T2H_DEBUG = $Texi2HTML::Config::DEBUG;
2295  $T2H_VERBOSE = $Texi2HTML::Config::VERBOSE;  $T2H_VERBOSE = $Texi2HTML::Config::VERBOSE;
2296    
2297    $Texi2HTML::LaTeX2HTML::debug = 0;
2298    $Texi2HTML::LaTeX2HTML::debug = 1 if ($T2H_DEBUG & $DEBUG_L2H);
2299    
2300    
2301  #+++############################################################################  #+++############################################################################
2302  #                                                                              #  #                                                                              #
2303  # evaluation of cmd line options  # evaluation of cmd line options
# Line 2672  $Texi2HTML::THISDOC{'filename'}->{'stoc' Line 2660  $Texi2HTML::THISDOC{'filename'}->{'stoc'
2660  $Texi2HTML::THISDOC{'filename'}->{'about'} = $docu_about;  $Texi2HTML::THISDOC{'filename'}->{'about'} = $docu_about;
2661  $Texi2HTML::THISDOC{'filename'}->{'top'} = $docu_top;  $Texi2HTML::THISDOC{'filename'}->{'top'} = $docu_top;
2662  $Texi2HTML::THISDOC{'filename'}->{'toc'} = $docu_toc;  $Texi2HTML::THISDOC{'filename'}->{'toc'} = $docu_toc;
2663    # FIXME document that
2664    $Texi2HTML::THISDOC{'out_dir'} = $docu_rdir;
2665    $Texi2HTML::THISDOC{'file_base_name'} = $docu_name;
2666    
2667    
2668  my $docu_doc_file = "$docu_rdir$docu_doc";  my $docu_doc_file = "$docu_rdir$docu_doc";
2669  my $docu_toc_file  = "$docu_rdir$docu_toc";  my $docu_toc_file  = "$docu_rdir$docu_toc";
# Line 2985  my ($l2h_name, $l2h_latex_file, $l2h_cac Line 2977  my ($l2h_name, $l2h_latex_file, $l2h_cac
2977  # holds the status of latex2html operations. If 0 it means that there was  # holds the status of latex2html operations. If 0 it means that there was
2978  # an error  # an error
2979  my $status = 0;  my $status = 0;
2980    
2981  my $debug;  my $debug;
2982  my $docu_rdir;  my $docu_rdir;
2983    my $docu_name;
2984    
2985  #if ($Texi2HTML::Config::L2H)  #if ($Texi2HTML::Config::L2H)
2986  sub init($$$)  sub init
2987  {  {
2988      my $docu_name = shift;  #    $debug = shift;
2989      $docu_rdir = shift;      $docu_name = $Texi2HTML::THISDOC{'file_base_name'};
2990      $debug = shift;      $docu_rdir = $Texi2HTML::THISDOC{'out_dir'};
2991      $l2h_name =  "${docu_name}_l2h";      $l2h_name =  "${docu_name}_l2h";
2992      $l2h_latex_file = "$docu_rdir${l2h_name}.tex";      $l2h_latex_file = "$docu_rdir${l2h_name}.tex";
2993      $l2h_cache_file = "${docu_rdir}l2h_cache.pm";      $l2h_cache_file = "${docu_rdir}l2h_cache.pm";
# Line 3030  my $l2h_latex_count = 0;     # number of Line 3024  my $l2h_latex_count = 0;     # number of
3024  my $l2h_to_latex_count = 0;  # total number of latex texts processed  my $l2h_to_latex_count = 0;  # total number of latex texts processed
3025  my $l2h_cached_count = 0;    # number of cached latex text  my $l2h_cached_count = 0;    # number of cached latex text
3026  my %l2h_cache = ();            my %l2h_cache = ();          
3027    
3028    my %global_count = ();
3029  #$Texi2HTML::Config::L2H = l2h_InitToLatex() if ($Texi2HTML::Config::L2H);  #$Texi2HTML::Config::L2H = l2h_InitToLatex() if ($Texi2HTML::Config::L2H);
3030    
3031  # return used latex 1, if l2h could be initalized properly, 0 otherwise  # return used latex 1, if l2h could be initalized properly, 0 otherwise
# Line 3059  sub init_to_latex() Line 3055  sub init_to_latex()
3055  #sub l2h_ToLatex  #sub l2h_ToLatex
3056  sub to_latex  sub to_latex
3057  {  {
3058      my($text) = @_;      my $command = shift;
3059      my($count);      my $text = shift;
3060        my $counter = shift;
3061        if ($command eq 'tex')
3062        {
3063            $text .= ' ';
3064        }
3065        elsif ($command eq 'math')
3066        {
3067            $text = "\$".$text."\$";
3068        }
3069      $l2h_to_latex_count++;      $l2h_to_latex_count++;
3070      $text =~ s/(\s*)$//;      $text =~ s/(\s*)$//;
3071      # try whether we can cache it      # try whether we can cache it
# Line 3072  sub to_latex Line 3077  sub to_latex
3077          return $cached_text;          return $cached_text;
3078      }      }
3079      # try whether we have text already on things to do      # try whether we have text already on things to do
3080      unless ($count = $l2h_to_latex{$text})      my $count = $l2h_to_latex{$text};
3081        unless ($count)
3082      {      {
3083          $count = $l2h_latex_count;          $count = $l2h_latex_count;
3084          $l2h_latex_count++;          $l2h_latex_count++;
# Line 3091  sub to_latex Line 3097  sub to_latex
3097              print L2H_LATEX "\\end{rawhtml}\n";              print L2H_LATEX "\\end{rawhtml}\n";
3098          }          }
3099      }      }
3100      return "\@tex_${count} ";      $global_count{"${command}_$counter"} = $count;
3101        #return "\@tex_${count} ";
3102        return 1;
3103  }  }
3104    
3105  # print closing into latex file and close it  # print closing into latex file and close it
# Line 3282  sub from_html($) Line 3290  sub from_html($)
3290      return $to_do.$done;      return $to_do.$done;
3291  }  }
3292    
3293  sub do_tex($)  sub do_tex($$$$)
3294  {  {
3295      my $count = shift;      my $style = shift;
3296        my $counter = shift;
3297        my $count = $global_count{"${style}_$counter"};
3298      my $result = '';      my $result = '';
3299      $result = "<!-- l2h_begin $l2h_name $count -->"      $result = "<!-- l2h_begin $l2h_name $count -->"
3300              #if ($T2H_DEBUG & $DEBUG_L2H);              #if ($T2H_DEBUG & $DEBUG_L2H);
# Line 3646  sub preserve_command($$) Line 3656  sub preserve_command($$)
3656          $text .= $1;          $text .= $1;
3657      }      }
3658      $line = '' if (!defined($line));      $line = '' if (!defined($line));
3659      return ($line, "\@$macro" . $text, $args);      return ($line, $text, $args);
3660  }  }
3661    
3662  #+++###########################################################################  #+++###########################################################################
# Line 3672  sub initialise_state_structure($) Line 3682  sub initialise_state_structure($)
3682                                      # to be used                                      # to be used
3683      $state->{'menu'} = 0;           # number of opened menus      $state->{'menu'} = 0;           # number of opened menus
3684      $state->{'detailmenu'} = 0;     # number of opened detailed menus            $state->{'detailmenu'} = 0;     # number of opened detailed menus      
3685      $state->{'level'} = 0;          # current sectionning level      $state->{'sectionning_base'} = 0;         # current base sectionning level
3686      $state->{'table_stack'} = [ "no table" ]; # a stack of opened tables/lists      $state->{'table_stack'} = [ "no table" ]; # a stack of opened tables/lists
3687      delete ($state->{'region_lines'}) unless (defined($state->{'region_lines'}));      delete ($state->{'region_lines'}) unless (defined($state->{'region_lines'}));
3688  }  }
# Line 3699  my $element_index;          # element wi Line 3709  my $element_index;          # element wi
3709  my $element_chapter_index;  # chapter with first index  my $element_chapter_index;  # chapter with first index
3710  my $element_first;          # first element  my $element_first;          # first element
3711  my $element_last;           # last element  my $element_last;           # last element
3712    my %special_commands;       # hash for the commands specially handled
3713                                # by the user
3714    
3715  # This is a virtual element used to have the right hrefs for index entries  # This is a virtual element used to have the right hrefs for index entries
3716  # and anchors in footnotes  # and anchors in footnotes
# Line 3751  sub pass_structure() Line 3763  sub pass_structure()
3763              #              #
3764              if ($tag and $tag eq 'node' or defined($sec2level{$tag}) or $tag eq 'printindex' or $tag eq 'float')              if ($tag and $tag eq 'node' or defined($sec2level{$tag}) or $tag eq 'printindex' or $tag eq 'float')
3765              {              {
3766                  $_ = substitute_texi_line($_); #usefull if there is an anchor ???                  $_ = substitute_texi_line($_);
3767                  if (@stack and $tag eq 'node' or defined($sec2level{$tag}) or                  if (@stack and $tag eq 'node' or defined($sec2level{$tag}) or
3768  $tag eq 'float')  $tag eq 'float')
3769                  {# in pass structure node and float shouldn't appear in formats                  {# in pass structure node and float shouldn't appear in formats
# Line 4072  sub misc_command_structure($$$$) Line 4084  sub misc_command_structure($$$$)
4084          {          {
4085              $sec2level{$sec} = $level + 1;              $sec2level{$sec} = $level + 1;
4086          }          }
4087          $state->{'level'}--;          $state->{'sectionning_base'}--;
4088      }      }
4089      elsif ($macro eq 'raisesections')      elsif ($macro eq 'raisesections')
4090      {      {
# Line 4081  sub misc_command_structure($$$$) Line 4093  sub misc_command_structure($$$$)
4093          {          {
4094              $sec2level{$sec} = $level - 1;              $sec2level{$sec} = $level - 1;
4095          }          }
4096          $state->{'level'}++;          $state->{'sectionning_base'}++;
4097      }      }
4098      elsif ($macro eq 'contents')      elsif ($macro eq 'contents')
4099      {      {
# Line 4098  sub misc_command_structure($$$$) Line 4110  sub misc_command_structure($$$$)
4110      elsif ($macro eq 'novalidate')      elsif ($macro eq 'novalidate')
4111      {      {
4112          $novalidate = 1;          $novalidate = 1;
4113            $Texi2HTML::THISDOC{$macro} = 1;
4114      }      }
4115      elsif (grep {$_ eq $macro} ('settitle','setfilename','shortitle','shorttitlepage')      elsif (grep {$_ eq $macro} ('settitle','setfilename','shortitle','shorttitlepage')
4116               and ($line =~ /^\s+(.*)$/))               and ($line =~ /^\s+(.*)$/))
# Line 4132  sub misc_command_structure($$$$) Line 4145  sub misc_command_structure($$$$)
4145                  {                  {
4146                      $index_properties->{$prefix_to}->{'from'}->{$prefix_from} = 1;                      $index_properties->{$prefix_to}->{'from'}->{$prefix_from} = 1;
4147                  }                  }
4148                    push @{$Texi2HTML::THISDOC{$macro}}, [$prefix_from,$prefix_to];
4149              }              }
4150          }          }
4151          else          else
# Line 4146  sub misc_command_structure($$$$) Line 4160  sub misc_command_structure($$$$)
4160              my $name = $1;              my $name = $1;
4161              $index_properties->{$name}->{'name'} = $name;              $index_properties->{$name}->{'name'} = $name;
4162              $index_properties->{$name}->{'code'} = 1 if $macro eq 'defcodeindex';              $index_properties->{$name}->{'code'} = 1 if $macro eq 'defcodeindex';
4163                push @{$Texi2HTML::THISDOC{$macro}}, $name;
4164          }          }
4165          else          else
4166          {# FIXME makeinfo don't warn and even accepts index with empty name          {# FIXME makeinfo don't warn and even accepts index with empty name
# Line 4158  sub misc_command_structure($$$$) Line 4173  sub misc_command_structure($$$$)
4173          {          {
4174              my $lang = $1;              my $lang = $1;
4175              set_document_language($lang, 0, $line_nr) if (!$cmd_line_lang && $lang);              set_document_language($lang, 0, $line_nr) if (!$cmd_line_lang && $lang);
4176                # warning, this is not the language of te document but the one that
4177                # appear in the texinfo...
4178                $Texi2HTML::THISDOC{$macro} = $lang;
4179          }          }
4180      }      }
4181      elsif ($macro eq 'kbdinputstyle')      elsif ($macro eq 'kbdinputstyle')
# Line 4302  sub misc_command_text($$$$$$) Line 4320  sub misc_command_text($$$$$$)
4320      my $text = shift;      my $text = shift;
4321      my $line_nr = shift;      my $line_nr = shift;
4322      my ($skipped, $remaining, $args);      my ($skipped, $remaining, $args);
4323        # if it is true the command args are kept so the user can modify how
4324        # they are skipped and handle them as unknown @-commands
4325      my $keep = $Texi2HTML::Config::misc_command{$macro}->{'keep'};      my $keep = $Texi2HTML::Config::misc_command{$macro}->{'keep'};
4326    
4327      if ($macro eq 'detailmenu')      if ($macro eq 'detailmenu')
# Line 4361  sub misc_command_text($$$$$$) Line 4381  sub misc_command_text($$$$$$)
4381      }      }
4382      elsif ($macro eq 'need')      elsif ($macro eq 'need')
4383      {      {
4384          unless (($line =~ /\s+([0-9]+(\.[0-9]*)?)[^\w\-]/) or          unless (($line =~ /^\s+([0-9]+(\.[0-9]*)?)[^\w\-]/) or
4385                   ($line =~ /\s+(\.[0-9]+)[^\w\-]/))                   ($line =~ /^\s+(\.[0-9]+)[^\w\-]/))
4386          {          {
4387              echo_warn ("Bad \@$macro", $line_nr);              echo_warn ("Bad \@$macro", $line_nr);
4388          }          }
4389      }      }
4390      ($remaining, $skipped, $args) = preserve_command($line, $macro);      ($remaining, $skipped, $args) = preserve_command($line, $macro);
4391      if ($keep)      return ($skipped) if ($keep);
     {  
         $remaining = $args . $remaining;  
     }  
4392      return $remaining if ($remaining ne '');      return $remaining if ($remaining ne '');
4393      return undef;      return undef;
4394  }  }
# Line 6195  print STDERR "!!$key\n" if (!defined($Te Line 6212  print STDERR "!!$key\n" if (!defined($Te
6212      $Texi2HTML::THISDOC{'copying'} = $copying_comment;      $Texi2HTML::THISDOC{'copying'} = $copying_comment;
6213      $Texi2HTML::THISDOC{'toc_file'} = '';      $Texi2HTML::THISDOC{'toc_file'} = '';
6214      $Texi2HTML::THISDOC{'toc_file'} = $docu_toc if ($Texi2HTML::Config::SPLIT);      $Texi2HTML::THISDOC{'toc_file'} = $docu_toc if ($Texi2HTML::Config::SPLIT);
     $Texi2HTML::THISDOC{'file_base_name'} = $docu_name;  
6215      $Texi2HTML::THISDOC{'destination_directory'} = $docu_rdir;      $Texi2HTML::THISDOC{'destination_directory'} = $docu_rdir;
6216      $Texi2HTML::THISDOC{'authors'} = [] if (!defined($Texi2HTML::THISDOC{'authors'}));      $Texi2HTML::THISDOC{'authors'} = [] if (!defined($Texi2HTML::THISDOC{'authors'}));
6217      $Texi2HTML::THISDOC{'subtitles'} = [] if (!defined($Texi2HTML::THISDOC{'subtitles'}));      $Texi2HTML::THISDOC{'subtitles'} = [] if (!defined($Texi2HTML::THISDOC{'subtitles'}));
# Line 7134  sub normalise_node($) Line 7150  sub normalise_node($)
7150    
7151  sub do_math($;$)  sub do_math($;$)
7152  {  {
7153      #return l2h_ToLatex("\$".$_[0]."\$");      #return Texi2HTML::LaTeX2HTML::to_latex("\$".$_[0]."\$");
7154      return Texi2HTML::LaTeX2HTML::to_latex("\$".$_[0]."\$");      return Texi2HTML::LaTeX2HTML::to_latex('math',$_[0]);
7155  }  }
7156    
7157  sub do_anchor_label($$$$)  sub do_anchor_label($$$$)
# Line 7393  sub do_text_macro($$$$$) Line 7409  sub do_text_macro($$$$$)
7409      return ($line, $text);      return ($line, $text);
7410  }  }
7411    
7412  # do regions handled specially, currently only tex, going throug latex2html  # do regions handled specially, currently only tex, going through latex2html
7413  sub init_special($$)  sub init_special($$)
7414  {  {
7415      my $style = shift;      my $style = shift;
7416      my $text = shift;      my $text = shift;
7417      if ($style eq 'tex')      if (defined($Texi2HTML::Config::command_handler{$style}) and
7418           defined($Texi2HTML::Config::command_handler{$style}->{'init'}))
7419      {      {
7420            $special_commands{$style}->{'count'} = 0 if (!defined($special_commands{$style}));
7421            if ($Texi2HTML::Config::command_handler{$style}->{'init'}($style,$text,
7422                   $special_commands{$style}->{'count'} +1))
7423            {
7424                $special_commands{$style}->{'count'}++;  
7425                return "\@special_${style}_".$special_commands{$style}->{'count'}."{}";
7426            }
7427            return '';
7428        }
7429    #    if ($style eq 'tex')
7430    #    {
7431          # add space to the end -- tex(i2dvi) does this, as well          # add space to the end -- tex(i2dvi) does this, as well
7432          #return (l2h_ToLatex($text . " "));          #return (l2h_ToLatex($text . " "));
7433          return (Texi2HTML::LaTeX2HTML::to_latex($text . " "));  #        return (Texi2HTML::LaTeX2HTML::to_latex($style,$text));
7434      }  #    }
7435        
7436  }  }
7437    
7438  sub do_insertcopying($)  sub do_insertcopying($)
# Line 8937  sub scan_texi($$$$;$) Line 8966  sub scan_texi($$$$;$)
8966              {# ARG_EXPANSION              {# ARG_EXPANSION
8967                   my ($line, $args);                   my ($line, $args);
8968                   ($_, $line, $args) = preserve_command($_, $macro);                   ($_, $line, $args) = preserve_command($_, $macro);
8969                   add_prev ($text, $stack, $line) unless $state->{'ignored'};                   add_prev ($text, $stack, "\@$macro" . $line) unless $state->{'ignored'};
8970              }              }
8971              # pertusus: it seems that value substitution are performed after              # pertusus: it seems that value substitution are performed after
8972              # macro argument expansions: if we have              # macro argument expansions: if we have
# Line 9508  sub scan_structure($$$$;$) Line 9537  sub scan_structure($$$$;$)
9537                   my $line;                   my $line;
9538                   ($_, $line) = misc_command_structure($_, $macro, $state,                   ($_, $line) = misc_command_structure($_, $macro, $state,
9539                         $line_nr);                         $line_nr);
9540                   add_prev ($text, $stack, $line);                   add_prev ($text, $stack, "\@$macro".$line);
9541                   next;                   next;
9542              }              }
9543    
# Line 9689  sub scan_structure($$$$;$) Line 9718  sub scan_structure($$$$;$)
9718                              $state->{'place'} = $state->{'footnote_place'};                              $state->{'place'} = $state->{'footnote_place'};
9719                          }                          }
9720                      }                      }
9721                      elsif ($style->{'style'} eq 'math' and $Texi2HTML::Config::L2H)                      #elsif ($style->{'style'} eq 'math' and $Texi2HTML::Config::L2H)
9722                      {                      #{
9723                          add_prev ($text, $stack, do_math($style->{'text'}));                      #    add_prev ($text, $stack, do_math($style->{'text'}));
9724                          next;                      #    next;
9725                      }                      #}
9726                      elsif ($style->{'style'} eq 'caption' or $style->{'style'}                      elsif ($style->{'style'} eq 'caption' or $style->{'style'}
9727  eq 'shortcaption' and $state->{'float'})  eq 'shortcaption' and $state->{'float'})
9728                      {                      {
# Line 9704  eq 'shortcaption' and $state->{'float'}) Line 9733  eq 'shortcaption' and $state->{'float'})
9733                      {                      {
9734                          $state->{'element'}->{'titlefont'} = $style->{'text'} unless ((exists($state->{'region_lines'}) and ($state->{'region_lines'}->{'format'} eq 'titlepage')) or defined($state->{'element'}->{'titlefont'})) ;                          $state->{'element'}->{'titlefont'} = $style->{'text'} unless ((exists($state->{'region_lines'}) and ($state->{'region_lines'}->{'format'} eq 'titlepage')) or defined($state->{'element'}->{'titlefont'})) ;
9735                      }                      }
9736                      if ($style->{'style'})                      if (defined($Texi2HTML::Config::command_handler{$style->{'style'}}))
9737                        {
9738                             $result = init_special($style->{'style'},$style->{'text'});
9739                        }
9740                        elsif ($style->{'style'})
9741                      {                      {
9742                           $result = '@' . $style->{'style'} . '{' . $style->{'text'} . '}';                           $result = '@' . $style->{'style'} . '{' . $style->{'text'} . '}';
9743                      }                      }
# Line 10126  sub scan_line($$$$;$) Line 10159  sub scan_line($$$$;$)
10159              add_prev($text, $stack, do_text($1, $state));              add_prev($text, $stack, do_text($1, $state));
10160              my $macro = $2;              my $macro = $2;
10161              #print STDERR "MACRO $macro\n";              #print STDERR "MACRO $macro\n";
10162                #print STDERR "LINE $_";
10163              #dump_stack ($text, $stack, $state);              #dump_stack ($text, $stack, $state);
10164              # This is a macro added by close_stack to mark paragraph end              # This is a macro added by close_stack to mark paragraph end
10165              if ($macro eq 'end_paragraph')              if ($macro eq 'end_paragraph')
# Line 10174  sub scan_line($$$$;$) Line 10208  sub scan_line($$$$;$)
10208                      ($_, $line, $args) = preserve_command($_, $macro);                      ($_, $line, $args) = preserve_command($_, $macro);
10209                      if ($state->{'keep_texi'})                      if ($state->{'keep_texi'})
10210                      {                      {
10211                          add_prev($text, $stack, $line);                          add_prev($text, $stack, "\@$macro". $line);
10212                      }                      }
10213                      next;                      next;
10214                  }                  }
# Line 10347  sub scan_line($$$$;$) Line 10381  sub scan_line($$$$;$)
10381              }              }
10382              # the following macros are not modified but just ignored              # the following macros are not modified but just ignored
10383              # if we are removing texi              # if we are removing texi
10384              if ($macro =~ /^tex_(\d+)$/o)  #            if ($macro =~ /^tex_(\d+)$/o)
10385              {  #            {
10386                  add_prev($text, $stack, Texi2HTML::LaTeX2HTML::do_tex($1));  #                add_prev($text, $stack, Texi2HTML::LaTeX2HTML::do_tex($1));
10387                  next;  #                next;
10388              }  #            }
10389              if ($state->{'remove_texi'})              if ($state->{'remove_texi'})
10390              {              {
10391                   if ((($macro =~ /^(\w+?)index$/) and ($1 ne 'print')) or                   if ((($macro =~ /^(\w+?)index$/) and ($1 ne 'print')) or
# Line 11219  sub do_simple($$$;$$$$) Line 11253  sub do_simple($$$;$$$$)
11253      my $line_nr = shift;      my $line_nr = shift;
11254      my $no_open = shift;      my $no_open = shift;
11255      my $no_close = shift;      my $no_close = shift;
     my $result;  
11256            
11257      my $arg_nr = 0;      my $arg_nr = 0;
11258      $arg_nr = @$args - 1 if (defined($args));      $arg_nr = @$args - 1 if (defined($args));
# Line 11253  sub do_simple($$$;$$$$) Line 11286  sub do_simple($$$;$$$$)
11286      }      }
11287      if (defined($things_map_ref->{$macro}))      if (defined($things_map_ref->{$macro}))
11288      {      {
11289            my $result;
11290          if ($state->{'keep_texi'})          if ($state->{'keep_texi'})
11291          {          {
11292               $result = "\@$macro" . '{}';               $result = "\@$macro" . '{}';
# Line 11276  sub do_simple($$$;$$$$) Line 11310  sub do_simple($$$;$$$$)
11310      {      {
11311          if ($state->{'keep_texi'})          if ($state->{'keep_texi'})
11312          {          {
11313               $result = "\@$macro" . '{' . $text . '}';               return "\@$macro" . '{' . $text . '}';
11314          }          }
11315          else          else
11316          {          {
11317               my $style;               my $style;
11318                 my $result;
11319               if ($state->{'remove_texi'})               if ($state->{'remove_texi'})
11320               {               {
11321  #print STDERR "REMOVE $macro, $style_map_texi_ref->{$macro}, fun $style_map_texi_ref->{$macro}->{'function'} remove cmd " . \&Texi2HTML::Config::t2h_remove_command . " ascii acc " . \&t2h_default_ascii_accent;  #print STDERR "REMOVE $macro, $style_map_texi_ref->{$macro}, fun $style_map_texi_ref->{$macro}->{'function'} remove cmd " . \&Texi2HTML::Config::t2h_remove_command . " ascii acc " . \&t2h_default_ascii_accent;
# Line 11302  sub do_simple($$$;$$$$) Line 11337  sub do_simple($$$;$$$$)
11337               {               {
11338                    close_arg($macro,$arg_nr, $state);                    close_arg($macro,$arg_nr, $state);
11339               }               }
11340                 return $result;
11341            }
11342        }
11343        elsif ($macro =~ /^special_(\w+)_(\d+)$/o)
11344        {
11345            my $style = $1;
11346            my $count = $2;
11347            print STDERR "Bug? text in \@$macro not empty.\n" if ($text ne '');  
11348            if ($state->{'keep_texi'})
11349            {# text should be empty
11350                 return "\@$macro" . '{' . $text . '}';
11351            }
11352            if (defined($Texi2HTML::Config::command_handler{$style}) and
11353              defined($Texi2HTML::Config::command_handler{$style}->{'expand'}))
11354            {
11355                 if ($count != $special_commands{$style}->{'count'})
11356                 {
11357                      print STDERR "Bug? count in \@special and structure differ\n";
11358                 }
11359                 else
11360                 {
11361                      $special_commands{$style}->{'count'}--;  
11362                 }
11363          }          }
11364            my $result = $Texi2HTML::Config::command_handler{$style}->{'expand'}
11365                  ($style,$count,$state,$text);
11366            $result = '' if (!defined($result));
11367          return $result;          return $result;
11368      }      }
11369      # Unknown macro      # Unknown macro
11370      $result = '';      my $result = '';
11371      my ($done, $result_text, $message) = &$Texi2HTML::Config::unknown_style($macro, $text);      my ($done, $result_text, $message) = &$Texi2HTML::Config::unknown_style($macro, $text,$state);
11372      if ($done)      if ($done)
11373      {      {
11374           echo_warn($message, $line_nr) if (defined($message));           echo_warn($message, $line_nr) if (defined($message));
# Line 11338  sub do_unknown($$$$$$) Line 11399  sub do_unknown($$$$$$)
11399      my $stack = shift;      my $stack = shift;
11400      my $state = shift;      my $state = shift;
11401      my $line_nr = shift;      my $line_nr = shift;
11402      my ($result_line, $result, $result_text, $message) = &$Texi2HTML::Config::unknown($macro, $line);      #print STDERR "do_unknown: $macro ::: $line";
11403        my ($result_line, $result, $result_text, $message) = &$Texi2HTML::Config::unknown($macro, $line,$stack,$state);
11404      if ($result)      if ($result)
11405      {      {
11406           add_prev ($text, $stack, $result_text) if (defined($result_text));           add_prev ($text, $stack, $result_text) if (defined($result_text));
# Line 11883  sub substitute_text($@) Line 11945  sub substitute_text($@)
11945      return $result . $text;      return $result . $text;
11946  }  }
11947    
11948    # this function does the second pass formatting. It is not obvious that
11949    # it is usefull as in that pass the collected things
11950  sub substitute_texi_line($)  sub substitute_texi_line($)
11951  {  {
11952      my $text = shift;        my $text = shift;  
# Line 11985  else Line 12049  else
12049  }  }
12050            
12051  open_file($docu, $texi_line_number);  open_file($docu, $texi_line_number);
12052  Texi2HTML::LaTeX2HTML::init($docu_name, $docu_rdir, $T2H_DEBUG & $DEBUG_L2H)  #Texi2HTML::LaTeX2HTML::init() if ($Texi2HTML::Config::L2H);
12053   if ($Texi2HTML::Config::L2H);  if ($Texi2HTML::Config::L2H)
12054    {
12055       push @Texi2HTML::Config::command_handler_init, \&Texi2HTML::LaTeX2HTML::init;
12056       push @Texi2HTML::Config::command_handler_process, \&Texi2HTML::LaTeX2HTML::latex2html;
12057       push @Texi2HTML::Config::command_handler_finish, \&Texi2HTML::LaTeX2HTML::finish;
12058       $Texi2HTML::Config::command_handler{'math'} =
12059         { 'init' => \&Texi2HTML::LaTeX2HTML::to_latex,
12060           'expand' => \&Texi2HTML::LaTeX2HTML::do_tex
12061         };
12062       $Texi2HTML::Config::command_handler{'tex'} =
12063         { 'init' => \&Texi2HTML::LaTeX2HTML::to_latex,
12064           'expand' => \&Texi2HTML::LaTeX2HTML::do_tex
12065         };
12066    }
12067    foreach my $handler(@Texi2HTML::Config::command_handler_init)
12068    {
12069        &$handler;
12070    }
12071  pass_texi();  pass_texi();
12072  dump_texi(\@lines, 'texi', \@lines_numbers) if ($T2H_DEBUG & $DEBUG_TEXI);  dump_texi(\@lines, 'texi', \@lines_numbers) if ($T2H_DEBUG & $DEBUG_TEXI);
12073  if (defined($Texi2HTML::Config::MACRO_EXPAND))  if (defined($Texi2HTML::Config::MACRO_EXPAND))
# Line 12024  if (@{$region_lines{'documentdescription Line 12105  if (@{$region_lines{'documentdescription
12105  if (@{$region_lines{'copying'}})  if (@{$region_lines{'copying'}})
12106  {  {
12107      $copying_comment = &$Texi2HTML::Config::copying_comment($region_lines{'copying'});      $copying_comment = &$Texi2HTML::Config::copying_comment($region_lines{'copying'});
     #$copying_comment = remove_texi(@{$region_lines{'copying'}});  
     #$copying_comment = &$Texi2HTML::Config::comment($copying_comment);  
12108  }  }
12109  &$Texi2HTML::Config::toc_body(\@elements_list);  &$Texi2HTML::Config::toc_body(\@elements_list);
 #&$Texi2HTML::Config::toc_body(\@elements_list, $do_contents, $do_scontents);  
12110  &$Texi2HTML::Config::css_lines(\@css_import_lines, \@css_rule_lines);  &$Texi2HTML::Config::css_lines(\@css_import_lines, \@css_rule_lines);
12111  $sec_num = 0;  $sec_num = 0;
12112  #$Texi2HTML::Config::L2H = l2h_FinishToLatex() if ($Texi2HTML::Config::L2H);  
12113  #$Texi2HTML::Config::L2H = l2h_ToHtml()        if ($Texi2HTML::Config::L2H);  #Texi2HTML::LaTeX2HTML::latex2html();
12114  #$Texi2HTML::Config::L2H = l2h_InitFromHtml()  if ($Texi2HTML::Config::L2H);  foreach my $handler(@Texi2HTML::Config::command_handler_process)
12115  Texi2HTML::LaTeX2HTML::latex2html();  {
12116        &$handler;
12117    }
12118  pass_text();  pass_text();
12119  #do_node_files() if ($Texi2HTML::Config::SPLIT ne 'node' and $Texi2HTML::Config::NODE_FILES);  foreach my $special (keys(%special_commands))
12120    {
12121        my $count = $special_commands{$special}->{'count'};
12122        if ($count != 0)
12123        {
12124             echo_warn ("Still $count special \@$special not processed\n");
12125        }
12126    }
12127  if ($Texi2HTML::Config::IDX_SUMMARY)  if ($Texi2HTML::Config::IDX_SUMMARY)
12128  {  {
12129      foreach my $entry (keys(%$index_properties))      foreach my $entry (keys(%$index_properties))
# Line 12049  if ($Texi2HTML::Config::IDX_SUMMARY) Line 12136  if ($Texi2HTML::Config::IDX_SUMMARY)
12136  do_node_files() if ($Texi2HTML::Config::NODE_FILES);  do_node_files() if ($Texi2HTML::Config::NODE_FILES);
12137  #l2h_FinishFromHtml() if ($Texi2HTML::Config::L2H);  #l2h_FinishFromHtml() if ($Texi2HTML::Config::L2H);
12138  #l2h_Finish() if($Texi2HTML::Config::L2H);  #l2h_Finish() if($Texi2HTML::Config::L2H);
12139  Texi2HTML::LaTeX2HTML::finish();  #Texi2HTML::LaTeX2HTML::finish();
12140    foreach my $handler(@Texi2HTML::Config::command_handler_finish)
12141    {
12142        &$handler;
12143    }
12144  &$Texi2HTML::Config::finish_out();  &$Texi2HTML::Config::finish_out();
12145  print STDERR "# that's all folks\n" if $T2H_VERBOSE;  print STDERR "# that's all folks\n" if $T2H_VERBOSE;
12146    

Legend:
Removed from v.1.149  
changed lines
  Added in v.1.150

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26