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

Diff of /texi2html/texi2html.pl

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

revision 1.150 by pertusus, Sun Aug 28 08:39:55 2005 UTC revision 1.151 by pertusus, Mon Nov 14 11:13:58 2005 UTC
# Line 1160  foreach my $special ('footnote', 'ref', Line 1160  foreach my $special ('footnote', 'ref',
1160  # raw formats which are expanded especially  # raw formats which are expanded especially
1161  my @raw_regions = ('html', 'verbatim', 'tex', 'xml', 'docbook');  my @raw_regions = ('html', 'verbatim', 'tex', 'xml', 'docbook');
1162    
 # special raw formats which are expanded between second and third pass  
 # and are replaced by specific commands. It takes precedence over  
 # raw_regions.  
 #FIXME it is not modifiable by the user!  
 my @special_regions = ();  
   
1163  # regions expanded or not depending on the value of this hash  # regions expanded or not depending on the value of this hash
1164  my %text_macros = (  my %text_macros = (
1165       'iftex' => 0,       'iftex' => 0,
# Line 2308  $Texi2HTML::LaTeX2HTML::debug = 1 if ($T Line 2302  $Texi2HTML::LaTeX2HTML::debug = 1 if ($T
2302  push (@Texi2HTML::Config::EXPAND, $Texi2HTML::Config::EXPAND) if ($Texi2HTML::Config::EXPAND);  push (@Texi2HTML::Config::EXPAND, $Texi2HTML::Config::EXPAND) if ($Texi2HTML::Config::EXPAND);
2303    
2304  unshift @texi2html_config_dirs, @Texi2HTML::Config::CONF_DIRS;  unshift @texi2html_config_dirs, @Texi2HTML::Config::CONF_DIRS;
2305  # correct %text_macros and @special_regions based on command line and init  # correct %text_macros based on command line and init
2306  # variables  # variables
2307  $text_macros{'menu'} = 1 if ($Texi2HTML::Config::SHOW_MENU);  $text_macros{'menu'} = 1 if ($Texi2HTML::Config::SHOW_MENU);
2308    
 push @special_regions, 'tex' if ($Texi2HTML::Config::L2H);  
   
2309  foreach my $expanded (@Texi2HTML::Config::EXPAND)  foreach my $expanded (@Texi2HTML::Config::EXPAND)
2310  {  {
2311      $text_macros{"if$expanded"} = 1 if (exists($text_macros{"if$expanded"}));      $text_macros{"if$expanded"} = 1 if (exists($text_macros{"if$expanded"}));
2312      next unless (exists($text_macros{$expanded}));      next unless (exists($text_macros{$expanded}));
2313      if (grep {$_ eq $expanded} @special_regions)      if (grep {$_ eq $expanded} @raw_regions)
     {  
          $text_macros{$expanded} = 'special';  
     }  
     elsif (grep {$_ eq $expanded} @raw_regions)  
2314      {      {
2315           $text_macros{$expanded} = 'raw';           $text_macros{$expanded} = 'raw';
2316      }      }
# Line 3750  sub pass_structure() Line 3738  sub pass_structure()
3738          }          }
3739          $line_nr = shift (@lines_numbers);          $line_nr = shift (@lines_numbers);
3740          #print STDERR "PASS_STRUCTURE: $_";          #print STDERR "PASS_STRUCTURE: $_";
3741          if (!$state->{'raw'} and !$state->{'special'} and !$state->{'verb'})          if (!$state->{'raw'} and !$state->{'verb'})
3742          {          {
3743              my $tag = '';              my $tag = '';
3744              if (/^\s*\@(\w+)\b/)              if (/^\s*\@(\w+)\b/)
# Line 7326  sub do_text_macro($$$$$) Line 7314  sub do_text_macro($$$$$)
7314      my $value;      my $value;
7315      #print STDERR "do_text_macro $type\n";      #print STDERR "do_text_macro $type\n";
7316    
7317      if ($text_macros{$type} eq 'raw' or $text_macros{$type} eq 'special')      if ($text_macros{$type} eq 'raw')
7318      {      {
7319          $state->{'raw'} = $type;          $state->{'raw'} = $type;
7320          #print STDERR "RAW\n";          #print STDERR "RAW\n";
# Line 9339  sub scan_structure($$$$;$) Line 9327  sub scan_structure($$$$;$)
9327      local $_ = $line;      local $_ = $line;
9328      #print STDERR "SCAN_STRUCTURE: $line";      #print STDERR "SCAN_STRUCTURE: $line";
9329      #dump_stack ($text, $stack, $state);      #dump_stack ($text, $stack, $state);
9330      if (!$state->{'raw'} and !$state->{'special'} and (!exists($state->{'region_lines'})))      if (!$state->{'raw'} and (!exists($state->{'region_lines'})))
9331      {      {
9332          if (!$state->{'verb'} and $state->{'menu'} and /^\*/o)          if (!$state->{'verb'} and $state->{'menu'} and /^\*/o)
9333          {          {
# Line 9398  sub scan_structure($$$$;$) Line 9386  sub scan_structure($$$$;$)
9386          #          #
9387          # see more examples in formatting directory          # see more examples in formatting directory
9388    
9389          if ($state->{'raw'} or $state->{'special'})          if ($state->{'raw'})
9390          {          {
9391              my $tag = $state->{'raw'};              my $tag = $state->{'raw'};
             $tag = $state->{'special'} unless $tag;  
9392              ################# debug              ################# debug
9393              if (! @$stack or ($stack->[-1]->{'style'} ne $tag))              if (! @$stack or ($stack->[-1]->{'style'} ne $tag))
9394              {              {
# Line 9414  sub scan_structure($$$$;$) Line 9401  sub scan_structure($$$$;$)
9401              if (s/^(.*?)\@end\s$tag$// or s/^(.*?)\@end\s$tag\s//)              if (s/^(.*?)\@end\s$tag$// or s/^(.*?)\@end\s$tag\s//)
9402              {              {
9403                  add_prev ($text, $stack, $1);                  add_prev ($text, $stack, $1);
9404                    delete $state->{'raw'};
9405                  my $style = pop @$stack;                  my $style = pop @$stack;
9406                  if ($state->{'special'})                  if (defined($Texi2HTML::Config::command_handler{$tag}))
9407                  { # replace the special region by what init_special give                  { # replace the special region by what init_special give
                     delete $state->{'special'};  
9408                      if ($style->{'text'} !~ /^\s*$/)                      if ($style->{'text'} !~ /^\s*$/)
9409                      {                      {
9410                          add_prev ($text, $stack, init_special($style->{'style'}, $style->{'text'}));                          add_prev ($text, $stack, init_special($style->{'style'}, $style->{'text'}));
# Line 9428  sub scan_structure($$$$;$) Line 9415  sub scan_structure($$$$;$)
9415                  {                  {
9416                      my $after_macro = '';                      my $after_macro = '';
9417                      $after_macro = ' ' unless (/^\s*$/);                      $after_macro = ' ' unless (/^\s*$/);
9418                      add_prev ($text, $stack, $style->{'text'} . "\@end $state->{'raw'}" . $after_macro);                      add_prev ($text, $stack, $style->{'text'} . "\@end $tag" . $after_macro);
                     delete $state->{'raw'};  
9419                  }                  }
9420                  unless (no_line($_))                  unless (no_line($_))
9421                  {                  {
# Line 9440  sub scan_structure($$$$;$) Line 9426  sub scan_structure($$$$;$)
9426              else              else
9427              {              {
9428                  add_prev ($text, $stack, $_);                  add_prev ($text, $stack, $_);
9429                  last unless ($state->{'special'});                  return if (defined($Texi2HTML::Config::command_handler{$tag}));
9430                  return;                  last;
9431              }              }
9432          }          }
9433                    
# Line 9570  sub scan_structure($$$$;$) Line 9556  sub scan_structure($$$$;$)
9556              elsif (defined($text_macros{$macro}))              elsif (defined($text_macros{$macro}))
9557              {              {
9558                      #print STDERR "TEXT_MACRO: $macro\n";                      #print STDERR "TEXT_MACRO: $macro\n";
9559                  if ($text_macros{$macro} eq 'special')                  if ($text_macros{$macro} eq 'raw')
                 {  
                      $state->{'special'} = $macro;  
                 }  
                 elsif ($text_macros{$macro} eq 'raw')  
9560                  {                  {
9561                      $state->{'raw'} = $macro;                      $state->{'raw'} = $macro;
9562                      #print STDERR "RAW\n";                      #print STDERR "RAW\n";
# Line 9607  sub scan_structure($$$$;$) Line 9589  sub scan_structure($$$$;$)
9589                  }                  }
9590                  # if it is a raw formatting command or a menu command                  # if it is a raw formatting command or a menu command
9591                  # we must keep it for later                  # we must keep it for later
9592                  my $macro_kept;                  my $macro_kept;
9593                  if ($state->{'raw'} or ($macro eq 'menu'))                  if (($state->{'raw'} and (!defined($Texi2HTML::Config::command_handler{$macro}))) or ($macro eq 'menu'))
9594                  {                  {
9595                      add_prev($text, $stack, "\@$macro");                      add_prev($text, $stack, "\@$macro");
9596                      $macro_kept = 1;                      $macro_kept = 1;
9597                  }                  }
9598                  if ($state->{'raw'} or $state->{'special'})                  if ($state->{'raw'})
9599                  {                  {
9600                      push @$stack, { 'style' => $macro, 'text' => '' };                      push @$stack, { 'style' => $macro, 'text' => '' };
9601                  }                  }
# Line 11352  sub do_simple($$$;$$$$) Line 11334  sub do_simple($$$;$$$$)
11334          if (defined($Texi2HTML::Config::command_handler{$style}) and          if (defined($Texi2HTML::Config::command_handler{$style}) and
11335            defined($Texi2HTML::Config::command_handler{$style}->{'expand'}))            defined($Texi2HTML::Config::command_handler{$style}->{'expand'}))
11336          {          {
11337               if ($count != $special_commands{$style}->{'count'})               my $struct_count = 1+ $special_commands{$style}->{'max'} - $special_commands{$style}->{'count'};
11338               {               if (($count != $struct_count) and $T2H_DEBUG)
                   print STDERR "Bug? count in \@special and structure differ\n";  
              }  
              else  
11339               {               {
11340                    $special_commands{$style}->{'count'}--;                      print STDERR "count $count in \@special $style and structure $struct_count differ\n";
11341               }               }
11342                 $special_commands{$style}->{'count'}--;  
11343          }          }
11344          my $result = $Texi2HTML::Config::command_handler{$style}->{'expand'}          my $result = $Texi2HTML::Config::command_handler{$style}->{'expand'}
11345                ($style,$count,$state,$text);                ($style,$count,$state,$text);
# Line 12087  if ($T2H_DEBUG & $DEBUG_TEXI) Line 12067  if ($T2H_DEBUG & $DEBUG_TEXI)
12067      }      }
12068  }  }
12069  exit(0) if ($Texi2HTML::Config::DUMP_TEXI or defined($Texi2HTML::Config::MACRO_EXPAND));  exit(0) if ($Texi2HTML::Config::DUMP_TEXI or defined($Texi2HTML::Config::MACRO_EXPAND));
12070    
12071    foreach my $style (keys(%special_commands))
12072    {
12073      $special_commands{$style}->{'max'} = $special_commands{$style}->{'count'};
12074    }
12075    
12076  rearrange_elements();  rearrange_elements();
12077  do_names();  do_names();
12078  if (@{$region_lines{'documentdescription'}} and (!defined($Texi2HTML::Config::DOCUMENT_DESCRIPTION)))  if (@{$region_lines{'documentdescription'}} and (!defined($Texi2HTML::Config::DOCUMENT_DESCRIPTION)))
# Line 12119  pass_text(); Line 12105  pass_text();
12105  foreach my $special (keys(%special_commands))  foreach my $special (keys(%special_commands))
12106  {  {
12107      my $count = $special_commands{$special}->{'count'};      my $count = $special_commands{$special}->{'count'};
12108      if ($count != 0)      if (($count != 0) and $T2H_VERBOSE)
12109      {      {
12110           echo_warn ("Still $count special \@$special not processed\n");           echo_warn ("$count special \@$special were not processed.\n");
12111      }      }
12112  }  }
12113  if ($Texi2HTML::Config::IDX_SUMMARY)  if ($Texi2HTML::Config::IDX_SUMMARY)

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

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