texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp Texinfo/Convert/Plaintext.pm t/10men...


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Convert/Plaintext.pm t/10men...
Date: Sat, 05 Feb 2011 12:34:47 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/02/05 12:34:47

Modified files:
        tp/Texinfo/Convert: Plaintext.pm 
        tp/t           : 10menu.t 
Added files:
        tp/t/results/menu: dash_in_menu.pl 

Log message:
        Don't modify dash and quotes in menu, except in node names.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.64&r2=1.65
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/10menu.t?cvsroot=texinfo&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/menu/dash_in_menu.pl?cvsroot=texinfo&rev=1.1

Patches:
Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -b -r1.64 -r1.65
--- Texinfo/Convert/Plaintext.pm        4 Feb 2011 23:45:33 -0000       1.64
+++ Texinfo/Convert/Plaintext.pm        5 Feb 2011 12:34:46 -0000       1.65
@@ -582,15 +582,18 @@
     die "Unknown container type $type\n";
   }
 
-  if ($self->{'context'}->[-1] eq 'flush') {
+  if ($flush_commands{$self->{'context'}->[-1]}) {
     $container->set_space_protection(undef, 1, 1);
   }
 
   my $formatter = {'container' => $container, 'upper_case' => 0,
                    'code' => 0, 'w' => 0,
                    'frenchspacing_stack' => [$self->{'frenchspacing'}]};
-  $formatter->{'preformatted'} = 1
-    if ($type eq 'unfilled');
+
+  if ($preformatted_context_commands{$self->{'context'}->[-1]}
+      and ! $menu_commands{$self->{'context'}->[-1]}) {
+    $formatter->{'preformatted'} = 1;
+  }
   return $formatter;
 }
 
@@ -608,6 +611,7 @@
   return $text;
 }
 
+# not used
 sub convert_unfilled($$;$)
 {
   my $self = shift;
@@ -774,7 +778,8 @@
       $result .= $self->_convert($footnote->{'root'}->{'args'}->[0]); 
       $result .= $self->_add_newline_if_needed();
       
-      pop @{$self->{'context'}};
+      my $old_context = pop @{$self->{'context'}};
+      die if ($old_context ne 'footnote');
       pop @{$self->{'format_context'}};
       pop @{$self->{'formatters'}};
     }
@@ -784,19 +789,6 @@
   return $result;
 }
 
-sub in_flushright($)
-{
-  my $self = shift;
-  my $index = -1;
-  $index--
-    while (!$flush_commands{$self->{'format_context'}->[$index]->{'cmdname'}});
-  if ($self->{'format_context'}->[$index]->{'cmdname'} eq 'flushright') {
-    return 1;
-  } else {
-    return 0;
-  }
-}
-
 sub flushright_index ($)
 {
   my $self = shift;
@@ -1400,7 +1392,8 @@
       if ($root->{'args'}) {
         $result .= $self->_convert($root->{'args'}->[0]);
       }
-      pop @{$self->{'context'}};
+      my $old_context = pop @{$self->{'context'}};
+      die if ($old_context ne 'math');
       return $result;
     } elsif ($command eq 'titlefont') {
       push @{$self->{'count_context'}}, {'lines' => 0, 'bytes' => 0};
@@ -1428,9 +1421,9 @@
       # cartouche group and raggedright -> nothing on format stack
 
       if ($preformatted_context_commands{$root->{'cmdname'}}) {
-        push @{$self->{'context'}}, 'preformatted';
+        push @{$self->{'context'}}, $root->{'cmdname'};
       } elsif ($flush_commands{$root->{'cmdname'}}) {
-        push @{$self->{'context'}}, 'flush';
+        push @{$self->{'context'}}, $root->{'cmdname'};
       }
       if ($format_context_commands{$root->{'cmdname'}}) {
         push @{$self->{'format_context'}}, 
@@ -1442,7 +1435,11 @@
              };
         $self->{'format_context'}->[-1]->{'indent_level'}++
            if ($indented_commands{$root->{'cmdname'}});
-        if ($self->{'context'}->[-1] eq 'preformatted'
+        # reopen a preformatted container, if the command opening the 
+        # preformatted context is not a classical preformatted 
+        # command (ie if it is menu, verbatim and not example and the 
+        # like) or it is inside any other which opend a context.
+        if ($preformatted_context_commands{$self->{'context'}->[-1]}
             and ! $preformatted_commands{$root->{'cmdname'}}) {
           $preformatted = $self->new_formatter('unfilled');
           push @{$self->{'formatters'}}, $preformatted;
@@ -1683,7 +1680,8 @@
             # FIXME should there be some indentation?
             my ($caption_text) = $self->_convert({'contents' => 
$caption->{'args'}->[0]->{'contents'},
                         'type' => $caption->{'cmdname'}.'_listoffloats'});
-            pop @{$self->{'context'}};
+            my $old_context = pop @{$self->{'context'}};
+            die if ($old_context ne 'listoffloats');
             while ($caption_text =~ 
s/^\s*(\p{Unicode::EastAsianWidth::InFullwidth}\s*|\S+\s*)//) {
               my $new_word = $1;
               $new_word =~ s/\n//g;
@@ -1797,7 +1795,7 @@
       $paragraph = $self->new_formatter('paragraph', $conf);
       push @{$self->{'formatters'}}, $paragraph;
       $self->{'format_context'}->[-1]->{'paragraph_count'}++;
-      if ($self->{'context'}->[-1] eq 'flush' and $self->in_flushright()) {
+      if ($self->{'context'}->[-1] eq 'flushright') {
         push @{$self->{'count_context'}}, {'lines' => 0, 'bytes' => 0,
                                                    'locations' => []};
       }
@@ -1807,7 +1805,7 @@
       delete $self->{'format_context'}->[-1]->{'counter'};
       $self->{'empty_lines_count'}++;
       if ($self->{'empty_lines_count'} <= 1
-          or $self->{'context'}->[-1] eq 'preformatted') {
+          or $preformatted_context_commands{$self->{'context'}->[-1]}) {
         $result = "\n";
         $self->_add_text_count($result);
         $self->_add_lines_count(1);
@@ -1863,9 +1861,15 @@
         print STDERR "     --> $result" if ($self->{'DEBUG'});
       }
     } elsif ($root->{'type'} eq 'menu_entry') {
+      # FIXME node name should be in code.
       foreach my $arg (@{$root->{'args'}}) {
+        if ($arg->{'type'} eq 'menu_entry_node') {
+          $result .= $self->_convert({'type' => 'code',
+                                      'contents' => $arg->{'contents'}});
+        } else {
         $result .= $self->_convert($arg);
       }
+      }
       $result = $self->ensure_end_of_line($result);
     } elsif ($root->{'type'} eq 'frenchspacing') {
       push @{$formatter->{'frenchspacing_stack'}}, 'on';
@@ -1877,7 +1881,6 @@
       $formatter->{'container'}->set_space_protection(undef,
         undef,undef,1);
     } elsif ($root->{'type'} eq 'bracketed') {
-      #and $self->{'context'}->[-1] eq 'math') {
       $result .= $self->_count_added($formatter->{'container'}, 
                    $formatter->{'container'}->add_text('{'));
     }
@@ -1890,7 +1893,7 @@
       my $content = shift @contents;
       my $text = $self->_convert($content);
       $self->{'empty_lines_count'} = 0 
-        if ($self->{'context'}->[-1] eq 'preformatted' and $text ne '');
+        if ($preformatted_context_commands{$self->{'context'}->[-1]} and $text 
ne '');
       $result .= $text;
     }
     pop @{$self->{'current_contents'}};
@@ -2032,7 +2035,7 @@
   if ($paragraph) {
     $result .= $self->_count_added($paragraph->{'container'},
                                    $paragraph->{'container'}->end());
-    if ($self->{'context'}->[-1] eq 'flush' and $self->in_flushright()) {
+    if ($self->{'context'}->[-1] eq 'flushright') {
       $result = $self->_align_environment ($result, 
         $self->{'format_context'}->[$self->flushright_index]->{'max'}, 
'right');
     }
@@ -2133,10 +2136,15 @@
     pop @{$self->{'formatters'}};
   }
 
-  if ($root->{'cmdname'} and 
-       ($preformatted_context_commands{$root->{'cmdname'}} 
-        or $flush_commands{$root->{'cmdname'}})) {
-    pop @{$self->{'context'}};
+  if ($root->{'cmdname'}) {
+    if ($preformatted_context_commands{$root->{'cmdname'}}) {
+      my $old_context = pop @{$self->{'context'}};
+      die if (!$preformatted_context_commands{$old_context});
+    }
+    elsif ($flush_commands{$root->{'cmdname'}}) {
+      my $old_context = pop @{$self->{'context'}};
+      die if (! $flush_commands{$old_context});
+    }
   }
 
   pop @{$self->{'format_context'}} 

Index: t/10menu.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/10menu.t,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- t/10menu.t  30 Jan 2011 17:41:16 -0000      1.8
+++ t/10menu.t  5 Feb 2011 12:34:47 -0000       1.9
@@ -97,6 +97,14 @@
 menu comment.
 
 @end menu
+'],
+['dash_in_menu',
+'
address@hidden
+* entry---in: (manual)n---ode.         description --- in.
+
+comment --- in.
address@hidden menu
 ']
 );
 

Index: t/results/menu/dash_in_menu.pl
===================================================================
RCS file: t/results/menu/dash_in_menu.pl
diff -N t/results/menu/dash_in_menu.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ t/results/menu/dash_in_menu.pl      5 Feb 2011 12:34:47 -0000       1.1
@@ -0,0 +1,198 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
+   %result_indices %result_sectioning %result_nodes %result_menus
+   %result_floats %result_converted %result_converted_errors);
+
+$result_trees{'dash_in_menu'} = {
+  'contents' => [
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'empty_line'
+    },
+    {
+      'cmdname' => 'menu',
+      'contents' => [
+        {
+          'parent' => {},
+          'text' => '
+',
+          'type' => 'empty_line_after_command'
+        },
+        {
+          'args' => [
+            {
+              'parent' => {},
+              'text' => '* ',
+              'type' => 'menu_entry_leading_text'
+            },
+            {
+              'contents' => [
+                {
+                  'parent' => {},
+                  'text' => 'entry---in'
+                }
+              ],
+              'parent' => {},
+              'type' => 'menu_entry_name'
+            },
+            {
+              'parent' => {},
+              'text' => ': ',
+              'type' => 'menu_entry_separator'
+            },
+            {
+              'contents' => [
+                {
+                  'parent' => {},
+                  'text' => '(manual)n---ode'
+                }
+              ],
+              'parent' => {},
+              'type' => 'menu_entry_node'
+            },
+            {
+              'parent' => {},
+              'text' => '.         ',
+              'type' => 'menu_entry_separator'
+            },
+            {
+              'contents' => [
+                {
+                  'parent' => {},
+                  'text' => 'description --- in.
+'
+                }
+              ],
+              'parent' => {},
+              'type' => 'menu_entry_description'
+            }
+          ],
+          'extra' => {
+            'menu_entry_node' => {
+              'manual_content' => [
+                {
+                  'parent' => {},
+                  'text' => 'manual'
+                }
+              ],
+              'node_content' => [
+                {
+                  'parent' => {},
+                  'text' => 'n---ode'
+                }
+              ],
+              'normalized' => 'n_002d_002d_002dode'
+            }
+          },
+          'line_nr' => {
+            'file_name' => '',
+            'line_nr' => 3,
+            'macro' => ''
+          },
+          'parent' => {},
+          'type' => 'menu_entry'
+        },
+        {
+          'parent' => {},
+          'text' => '
+',
+          'type' => 'after_description_line'
+        },
+        {
+          'contents' => [
+            {
+              'contents' => [
+                {
+                  'parent' => {},
+                  'text' => 'comment --- in.
+'
+                }
+              ],
+              'parent' => {},
+              'type' => 'preformatted'
+            }
+          ],
+          'parent' => {},
+          'type' => 'menu_comment'
+        }
+      ],
+      'parent' => {}
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'empty_line_after_command'
+    }
+  ],
+  'type' => 'text_root'
+};
+$result_trees{'dash_in_menu'}{'contents'}[0]{'parent'} = 
$result_trees{'dash_in_menu'};
+$result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[0]{'parent'} = 
$result_trees{'dash_in_menu'}{'contents'}[1];
+$result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1]{'args'}[0]{'parent'}
 = $result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1];
+$result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1]{'args'}[1]{'contents'}[0]{'parent'}
 = $result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1]{'args'}[1];
+$result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1]{'args'}[1]{'parent'}
 = $result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1];
+$result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1]{'args'}[2]{'parent'}
 = $result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1];
+$result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1]{'args'}[3]{'contents'}[0]{'parent'}
 = $result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1]{'args'}[3];
+$result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1]{'args'}[3]{'parent'}
 = $result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1];
+$result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1]{'args'}[4]{'parent'}
 = $result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1];
+$result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1]{'args'}[5]{'contents'}[0]{'parent'}
 = $result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1]{'args'}[5];
+$result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1]{'args'}[5]{'parent'}
 = $result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1];
+$result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1]{'extra'}{'menu_entry_node'}{'manual_content'}[0]{'parent'}
 = $result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1]{'args'}[3];
+$result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1]{'extra'}{'menu_entry_node'}{'node_content'}[0]{'parent'}
 = $result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1]{'args'}[3];
+$result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[1]{'parent'} = 
$result_trees{'dash_in_menu'}{'contents'}[1];
+$result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[2]{'parent'} = 
$result_trees{'dash_in_menu'}{'contents'}[1];
+$result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[3]{'contents'}[0]{'contents'}[0]{'parent'}
 = $result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[3]{'contents'}[0];
+$result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[3]{'contents'}[0]{'parent'}
 = $result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[3];
+$result_trees{'dash_in_menu'}{'contents'}[1]{'contents'}[3]{'parent'} = 
$result_trees{'dash_in_menu'}{'contents'}[1];
+$result_trees{'dash_in_menu'}{'contents'}[1]{'parent'} = 
$result_trees{'dash_in_menu'};
+$result_trees{'dash_in_menu'}{'contents'}[2]{'parent'} = 
$result_trees{'dash_in_menu'};
+
+$result_texis{'dash_in_menu'} = '
address@hidden
+* entry---in: (manual)n---ode.         description --- in.
+
+comment --- in.
address@hidden menu
+';
+
+
+$result_texts{'dash_in_menu'} = '
+* entry---in: (manual)n---ode.         description --- in.
+
+comment --- in.
+';
+
+$result_errors{'dash_in_menu'} = [
+  {
+    'error_line' => ':2: @menu seen before first @node
+',
+    'file_name' => '',
+    'line_nr' => 2,
+    'macro' => '',
+    'text' => '@menu seen before first @node',
+    'type' => 'error'
+  },
+  {
+    'error_line' => ':2: perhaps your @top node should be wrapped in @ifnottex 
rather than @ifinfo?
+',
+    'file_name' => '',
+    'line_nr' => 2,
+    'macro' => '',
+    'text' => 'perhaps your @top node should be wrapped in @ifnottex rather 
than @ifinfo?',
+    'type' => 'error continuation'
+  }
+];
+
+
+
+$result_converted{'plaintext'}->{'dash_in_menu'} = '
+* Menu:
+
+* entry--in: (manual)n---ode.         description -- in.
+
+comment -- in.
+';
+
+1;



reply via email to

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