texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

texinfo/tp Texinfo/Convert/HTML.pm Texinfo/Conv...


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Convert/HTML.pm Texinfo/Conv...
Date: Sun, 14 Aug 2011 23:04:01 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/08/14 23:04:01

Modified files:
        tp/Texinfo/Convert: HTML.pm Plaintext.pm 
        tp/t/results/paragraph: commands_in_flushright.pl 

Log message:
        @float formatting isn't modified when in preformatted or alignement 
command.
        
        Sanitize the stacks in HTML.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.130&r2=1.131
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.151&r2=1.152
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/paragraph/commands_in_flushright.pl?cvsroot=texinfo&r1=1.1&r2=1.2

Patches:
Index: Texinfo/Convert/HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -b -r1.130 -r1.131
--- Texinfo/Convert/HTML.pm     14 Aug 2011 20:23:03 -0000      1.130
+++ Texinfo/Convert/HTML.pm     14 Aug 2011 23:04:01 -0000      1.131
@@ -95,61 +95,67 @@
   $format_context_commands{$misc_context_command} = 1;
 }
 
+my %composition_context_commands = (%preformatted_commands, %root_commands,
+  %menu_commands, %align_commands);
+$composition_context_commands{'float'} = 1;
+
 # FIXME allow customization?
 my %upper_case_commands = ( 'sc' => 1 );
 
 sub in_math($)
 {
   my $self = shift;
-  return $self->{'document_context'}->[-1]->{'context'}->[-1]->{'math'};
+  return $self->{'document_context'}->[-1]->{'math'};
 }
 
 sub in_preformatted($)
 {
   my $self = shift;
-  return $self->{'document_context'}->[-1]->{'preformatted_context'}->[-1];
+  my $context = 
$self->{'document_context'}->[-1]->{'composition_context'}->[-1];
+  return ($preformatted_commands{$context} 
+         or ($menu_commands{$context} and $self->get_conf('SIMPLE_MENU')));;
 }
 
 sub in_upper_case($)
 {
   my $self = shift;
-  return $self->{'document_context'}->[-1]->{'context'}->[-1]->{'upper_case'};
+  return 
$self->{'document_context'}->[-1]->{'formatting_context'}->[-1]->{'upper_case'};
 }
 
 sub in_space_protected($)
 {
   my $self = shift;
-  return 
$self->{'document_context'}->[-1]->{'context'}->[-1]->{'space_protected'};
+  return 
$self->{'document_context'}->[-1]->{'formatting_context'}->[-1]->{'space_protected'};
 }
 
 sub in_code($)
 {
   my $self = shift;
-  return $self->{'document_context'}->[-1]->{'context'}->[-1]->{'code'};
+  return $self->{'document_context'}->[-1]->{'code'};
 }
 
 sub in_string($)
 {
   my $self = shift;
-  return $self->{'document_context'}->[-1]->{'context'}->[-1]->{'string'};
+  return $self->{'document_context'}->[-1]->{'string'};
 }
 
 sub in_verbatim($)
 {
   my $self = shift;
-  return $self->{'document_context'}->[-1]->{'context'}->[-1]->{'verbatim'};
+  return $self->{'document_context'}->[-1]->{'verbatim'};
 }
 
 sub paragraph_number($)
 {
   my $self = shift;
-  return 
$self->{'document_context'}->[-1]->{'context'}->[-1]->{'paragraph_number'};
+  return 
$self->{'document_context'}->[-1]->{'formatting_context'}->[-1]->{'paragraph_number'};
 }
 
 sub preformatted_number($)
 {
   my $self = shift;
-  return 
$self->{'document_context'}->[-1]->{'context'}->[-1]->{'preformatted_number'};
+  return 
$self->{'document_context'}->[-1]->{'formatting_context'}->[-1]->{'preformatted_number'};
 }
 
 sub top_format($)
@@ -173,7 +179,7 @@
 sub align($)
 {  
   my $self = shift;
-  return $self->{'document_context'}->[-1]->{'context'}->[-1]->{'align'}->[-1];
+  return $self->{'document_context'}->[-1]->{'composition_context'}->[-1];
 }
 
 sub _get_target($$)
@@ -3302,25 +3308,6 @@
 $default_types_conversion{'definfoenclose_command'} 
   = \&_convert_definfoenclose_type;
 
-sub _in_preformatted_code($)
-{
-  my $self = shift;
-
-  return 0 if (!$self->in_preformatted());
-
-  my @pre_classes = $self->preformatted_classes_stack();
-  foreach my $class (@pre_classes) {
-    # FIXME maybe with $class eq 'menu-preformatted' override
-    # 'menu-preformatted' with 'menu-comment', removing the 
-    # code style?
-    if ($preformatted_code_commands{$class}
-        or $class eq 'menu-preformatted') {
-      return 1;
-    }
-  }
-  return 0;
-}
-
 sub _convert_text($$$)
 {
   my $self = shift;
@@ -3338,12 +3325,10 @@
   if ($self->get_conf('ENABLE_ENCODING') and 
       !$self->get_conf('ENABLE_ENCODING_USE_ENTITY')
       and $self->{'encoding_name'} and $self->{'encoding_name'} eq 'utf-8') {
-    my $context = {'code' => ($self->in_code() or $self->in_math()), 
-                   'preformatted' => $self->_in_preformatted_code()};
+    my $context = {'code' => ($self->in_code() or $self->in_math())}; 
     $text = Texinfo::Convert::Unicode::unicode_text($self, $text, $command,
                                                          $context);
-  } elsif (!$self->in_code() and !$self->in_math() 
-           and !$self->_in_preformatted_code()) {
+  } elsif (!$self->in_code() and !$self->in_math()) { 
     if ($self->get_conf('USE_ISO')) {
       $text =~ s/---/\&mdash\;/g;
       $text =~ s/--/\&ndash\;/g;
@@ -3911,9 +3896,8 @@
   my $cmdname = shift;
   push @{$self->{'document_context'}},
           {'cmdname' => $cmdname,
-           'context' => [{'cmdname' => $cmdname, 
-                         'align' => ['raggedright']}],
-           'preformatted_context' => [0],
+           'formatting_context' => [{'cmdname' => $cmdname}],
+           'composition_context' => ['raggedright'],
            'formats' => [],
           };
 }
@@ -6227,7 +6211,7 @@
 
   if ($self->get_conf('DEBUG')) {
     $explanation = 'NO EXPLANATION' if (!defined($explanation));
-    print STDERR "ROOT($explanation):$root 
(".join('|',@{$self->{'document_context'}->[-1]->{'context'}})."), ->";
+    print STDERR "ROOT($explanation):$root 
(".join('|',@{$self->{'document_context'}->[-1]->{'formatting_context'}})."), 
->";
     print STDERR " cmd: $root->{'cmdname'}," if ($root->{'cmdname'});
     print STDERR " type: $root->{'type'}" if ($root->{'type'});
     my $text = $root->{'text'}; 
@@ -6322,34 +6306,31 @@
       push @{$self->{'document_context'}->[-1]->{'commands'}}, 
         $root->{'cmdname'}; 
       if (exists($format_context_commands{$command_name})) {
-        push @{$self->{'document_context'}->[-1]->{'context'}}, 
-                       {'cmdname' => $command_name, 'align' => 
['raggedright']};
+        push @{$self->{'document_context'}->[-1]->{'formatting_context'}}, 
+                                              {'cmdname' => $command_name};
       }
       if (exists($block_commands{$command_name})) {
         push @{$self->{'document_context'}->[-1]->{'formats'}}, $command_name;
       }
-      if ($preformatted_commands_context{$command_name}
-          or $command_name eq 'menu' and $self->get_conf('SIMPLE_MENU')) {
-        push @{$self->{'document_context'}->[-1]->{'preformatted_context'}}, 
$command_name;
+      if (exists ($composition_context_commands{$command_name})) {
+        push @{$self->{'document_context'}->[-1]->{'composition_context'}}, 
$command_name;
       }
       if ($pre_class_commands{$command_name}) {
         push @{$self->{'document_context'}->[-1]->{'preformatted_classes'}},
           $pre_class_commands{$command_name};
       }
       if ($command_name eq 'verb' or $command_name eq 'verbatim') {
-        $self->{'document_context'}->[-1]->{'context'}->[-1]->{'verbatim'}++;
+        $self->{'document_context'}->[-1]->{'verbatim'}++;
       }
       if ($code_style_commands{$command_name} or 
           $preformatted_code_commands{$command_name}) {
-        $self->{'document_context'}->[-1]->{'context'}->[-1]->{'code'}++;
+        $self->{'document_context'}->[-1]->{'code'}++;
       } elsif ($upper_case_commands{$command_name}) {
-        $self->{'document_context'}->[-1]->{'context'}->[-1]->{'upper_case'}++;
+        
$self->{'document_context'}->[-1]->{'formatting_context'}->[-1]->{'upper_case'}++;
       } elsif ($command_name eq 'math') {
-        $self->{'document_context'}->[-1]->{'context'}->[-1]->{'math'}++;
+        $self->{'document_context'}->[-1]->{'math'}++;
       } elsif ($command_name eq 'w') {
-        
$self->{'document_context'}->[-1]->{'context'}->[-1]->{'space_protected'}++;
-      } elsif ($align_commands{$root->{'cmdname'}}) {
-        push 
@{$self->{'document_context'}->[-1]->{'context'}->[-1]->{'align'}}, 
$command_name;
+        
$self->{'document_context'}->[-1]->{'formatting_context'}->[-1]->{'space_protected'}++;
       }
       if ($root->{'contents'}) {
         $content_formatted = '';
@@ -6395,18 +6376,18 @@
               if ($arg_type eq 'normal') {
                 $arg_formatted->{'normal'} = $self->_convert($arg, 
$explanation);
               } elsif ($arg_type eq 'code') {
-                
$self->{'document_context'}->[-1]->{'context'}->[-1]->{'code'}++;
+                $self->{'document_context'}->[-1]->{'code'}++;
                 $arg_formatted->{$arg_type} = $self->_convert($arg, 
$explanation);
-                
$self->{'document_context'}->[-1]->{'context'}->[-1]->{'code'}--;
+                $self->{'document_context'}->[-1]->{'code'}--;
               } elsif ($arg_type eq 'string') {
                 $self->_new_document_context($command_type);
-                
$self->{'document_context'}->[-1]->{'context'}->[-1]->{$arg_type}++;
+                $self->{'document_context'}->[-1]->{'string'}++;
                 $arg_formatted->{$arg_type} = $self->_convert($arg, 
$explanation);
                 pop @{$self->{'document_context'}};
               } elsif ($arg_type eq 'codestring') {
                 $self->_new_document_context($command_type);
-                
$self->{'document_context'}->[-1]->{'context'}->[-1]->{'code'}++;
-                
$self->{'document_context'}->[-1]->{'context'}->[-1]->{'string'}++;
+                $self->{'document_context'}->[-1]->{'code'}++;
+                $self->{'document_context'}->[-1]->{'string'}++;
                 $arg_formatted->{$arg_type} = $self->_convert($arg, 
$explanation);
                 pop @{$self->{'document_context'}};
               } elsif ($arg_type eq 'codetext') {
@@ -6431,33 +6412,30 @@
         $result = &{$self->{'commands_conversion'}->{$command_name}}($self,
                 $command_name, $root, $content_formatted);
       }
-      if ($preformatted_commands_context{$command_name}
-          or $command_name eq 'menu' and $self->get_conf('SIMPLE_MENU')) {
-        pop @{$self->{'document_context'}->[-1]->{'preformatted_context'}};
+      if (exists ($composition_context_commands{$command_name})) {
+        pop @{$self->{'document_context'}->[-1]->{'composition_context'}};
       }
       if ($pre_class_commands{$command_name}) {
         pop @{$self->{'document_context'}->[-1]->{'preformatted_classes'}};
       }
       if ($code_style_commands{$command_name} or 
           $preformatted_code_commands{$command_name}) {
-        $self->{'document_context'}->[-1]->{'context'}->[-1]->{'code'}--;
+        $self->{'document_context'}->[-1]->{'code'}--;
       } elsif ($upper_case_commands{$command_name}) {
-        $self->{'document_context'}->[-1]->{'context'}->[-1]->{'upper_case'}--;
+        
$self->{'document_context'}->[-1]->{'formatting_context'}->[-1]->{'upper_case'}--;
       } elsif ($command_name eq 'math') {
-        $self->{'document_context'}->[-1]->{'context'}->[-1]->{'math'}--;
+        $self->{'document_context'}->[-1]->{'math'}--;
       } elsif ($command_name eq 'w') {
-        
$self->{'document_context'}->[-1]->{'context'}->[-1]->{'space_protected'}--;
-      } elsif ($align_commands{$command_name}) {
-        pop @{$self->{'document_context'}->[-1]->{'context'}->[-1]->{'align'}};
+        
$self->{'document_context'}->[-1]->{'formatting_context'}->[-1]->{'space_protected'}--;
       }
       if ($command_name eq 'verb' or $command_name eq 'verbatim') {
-        $self->{'document_context'}->[-1]->{'context'}->[-1]->{'verbatim'}--;
+        $self->{'document_context'}->[-1]->{'verbatim'}--;
       }
       if (exists($block_commands{$command_name})) {
         pop @{$self->{'document_context'}->[-1]->{'formats'}};
       }
       if (exists($format_context_commands{$command_name})) {
-        pop @{$self->{'document_context'}->[-1]->{'context'}};
+        pop @{$self->{'document_context'}->[-1]->{'formatting_context'}};
       }
       pop @{$self->{'document_context'}->[-1]->{'commands'}};
       if (exists($context_brace_commands{$command_name})) {
@@ -6476,13 +6454,13 @@
       $root->{'cmdname'}
         if ($root->{'cmdname'});
     if ($root->{'type'} eq 'paragraph') {
-      
$self->{'document_context'}->[-1]->{'context'}->[-1]->{'paragraph_number'}++;
+      
$self->{'document_context'}->[-1]->{'formatting_context'}->[-1]->{'paragraph_number'}++;
     } elsif ($root->{'type'} eq 'preformatted') {
-      
$self->{'document_context'}->[-1]->{'context'}->[-1]->{'preformatted_number'}++;
+      
$self->{'document_context'}->[-1]->{'formatting_context'}->[-1]->{'preformatted_number'}++;
     } elsif ($root->{'type'} eq '_code') {
-      $self->{'document_context'}->[-1]->{'context'}->[-1]->{'code'}++;
+      $self->{'document_context'}->[-1]->{'code'}++;
     } elsif ($root->{'type'} eq '_string') {
-      $self->{'document_context'}->[-1]->{'context'}->[-1]->{'string'}++;
+      $self->{'document_context'}->[-1]->{'string'}++;
     } elsif ($root->{'type'} eq 'page') {
       $self->{'current_page'} = $root;
       $self->{'current_filename'} = $root->{'filename'};
@@ -6540,9 +6518,9 @@
       $result = $content_formatted;
     }
     if ($root->{'type'} eq '_code') {
-      $self->{'document_context'}->[-1]->{'context'}->[-1]->{'code'}--;
+      $self->{'document_context'}->[-1]->{'code'}--;
     } elsif ($root->{'type'} eq '_string') {
-      $self->{'document_context'}->[-1]->{'context'}->[-1]->{'string'}--;
+      $self->{'document_context'}->[-1]->{'string'}--;
     } elsif ($root->{'type'} eq 'page') {
       delete $self->{'current_page'};
       delete $self->{'current_filename'};

Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.151
retrieving revision 1.152
diff -u -b -r1.151 -r1.152
--- Texinfo/Convert/Plaintext.pm        14 Aug 2011 21:24:19 -0000      1.151
+++ Texinfo/Convert/Plaintext.pm        14 Aug 2011 23:04:01 -0000      1.152
@@ -1605,7 +1605,8 @@
       if ($menu_commands{$root->{'cmdname'}} and 
!$self->get_conf('SHOW_MENU')) {
         return '';
       }
-      if ($self->{'preformatted_context_commands'}->{$root->{'cmdname'}}) {
+      if ($self->{'preformatted_context_commands'}->{$root->{'cmdname'}}
+          or $root->{'cmdname'} eq 'float') {
         push @{$self->{'context'}}, $root->{'cmdname'};
       } elsif ($flush_commands{$root->{'cmdname'}}) {
         push @{$self->{'context'}}, $root->{'cmdname'};
@@ -2426,10 +2427,12 @@
 
   
     # close the contexts and register the cells
-    if ($self->{'preformatted_context_commands'}->{$root->{'cmdname'}}) {
+    if ($self->{'preformatted_context_commands'}->{$root->{'cmdname'}}
+        or $root->{'cmdname'} eq 'float') {
       my $old_context = pop @{$self->{'context'}};
       die "Not a preformatted context: $old_context"
-        if (!$self->{'preformatted_context_commands'}->{$old_context});
+        if (!$self->{'preformatted_context_commands'}->{$old_context}
+            and $old_context ne 'float');
       delete ($self->{'preformatted_context_commands'}->{$root->{'cmdname'}})
        unless ($default_preformatted_context_commands{$root->{'cmdname'}});
     } elsif ($flush_commands{$root->{'cmdname'}}) {

Index: t/results/paragraph/commands_in_flushright.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/paragraph/commands_in_flushright.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- t/results/paragraph/commands_in_flushright.pl       14 Aug 2011 20:23:04 
-0000      1.1
+++ t/results/paragraph/commands_in_flushright.pl       14 Aug 2011 23:04:01 
-0000      1.2
@@ -1794,7 +1794,7 @@
                                                              text col2
                     in multitable
 
-                                                               in float
+in float
 
 label 1:                                                              in 
caption
 
@@ -1813,10 +1813,10 @@
 
 
 $result_converted{'html_text'}->{'commands_in_flushright'} = '
-<p>in group
+<p align="right">in group
 </p>
 <blockquote>
-<p><b>type:</b> in quotation
+<p align="right"><b>type:</b> in quotation
 </p></blockquote>
 
 <ol>
@@ -1828,9 +1828,9 @@
 <dl compact="compact">
 <dt><em>table item</em></dt>
 <dt><em>table itemx</em></dt>
-<dd><p>Table text
+<dd><p align="right">Table text
 </p>
-<p>Text.
+<p align="right">Text.
 </p></dd>
 </dl>
 
@@ -1838,7 +1838,7 @@
 <tr><td width="50%">col1</td><td width="50%">col2</td></tr>
 <tr><td width="50%">text
 
-<p>in multitable
+<p align="right">in multitable
 </p></td><td width="50%">text col2</td></tr>
 </table>
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]