texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp Texinfo/Parser.pm t/60macro.t t/resu...


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Parser.pm t/60macro.t t/resu...
Date: Sat, 09 Oct 2010 13:25:54 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        10/10/09 13:25:53

Modified files:
        tp/Texinfo     : Parser.pm 
        tp/t           : 60macro.t 
        tp/t/results/macro: macro_in_ifset_end_in_arg.pl 
Added files:
        tp/t/results/macro: paragraph_and_macro.pl 

Log message:
        Merge empty line with following paragraph.
        Always start an empty line at the beginning of a line.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.51&r2=1.52
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/60macro.t?cvsroot=texinfo&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/macro/macro_in_ifset_end_in_arg.pl?cvsroot=texinfo&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/macro/paragraph_and_macro.pl?cvsroot=texinfo&rev=1.1

Patches:
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- Texinfo/Parser.pm   9 Oct 2010 11:21:28 -0000       1.51
+++ Texinfo/Parser.pm   9 Oct 2010 13:25:53 -0000       1.52
@@ -249,7 +249,7 @@
 $context_brace_commands{'math'} = 'math';
 
 my %no_paragraph_contexts;
-foreach my $no_paragraph_context ('math', 'preformatted', 'menu') {
+foreach my $no_paragraph_context ('math', 'preformatted', 'menu', 'def') {
   $no_paragraph_contexts{$no_paragraph_context} = 1;
 };
 
@@ -711,9 +711,21 @@
 
   if ((!$current->{'type'} or $current->{'type'} eq 'before_item') 
       and !$no_paragraph_contexts{$self->{'context_stack'}->[-1]}) {
+    my $previous_empty_text;
+    die "BUG: contents undef "._print_current($current) 
+       if (!defined($current->{'contents'}));
+    if (@{$current->{'contents'}} 
+         and defined($current->{'contents'}->[-1]->{'text'})
+         and $current->{'contents'}->[-1]->{'text'} !~ /[\S\n]/) {
+      $previous_empty_text = pop @{$current->{'contents'}};
+    }
     push @{$current->{'contents'}}, 
             { 'type' => 'paragraph', 'parent' => $current, 'contents' => [] };
     $current = $current->{'contents'}->[-1];
+    if ($previous_empty_text) {
+      push @{$current->{'contents'}}, $previous_empty_text;
+      $previous_empty_text->{'parent'} = $current;
+    }
     print STDERR "PARAGRAPH\n" if ($self->{'debug'});
     return $current;
   }
@@ -821,21 +833,24 @@
 
   my $paragraph;
 
+  # FIXME put leading spaces in preceding empty_line (which will be aborted
+  #       as an empty line, but still be there) instead of merging?
+  # this would requires also a change in _begin_paragraph.
   if ($text =~ /\S/) {
     _abort_empty_line ($self, $current);
     $paragraph = _begin_paragraph($self, $current);
+    $current = $paragraph if ($paragraph);
   }
 
-  if (!$paragraph and 
-    $current->{'contents'} and @{$current->{'contents'}} and
+  die "BUG: No contents in _merge_text "._print_current($current) 
+          if (!defined($current->{'contents'}));
+  if (@{$current->{'contents'}} and
     exists($current->{'contents'}->[-1]->{'text'}) and 
-#   !$current->{'contents'}->[-1]->{'type'} and 
     $current->{'contents'}->[-1]->{'text'} !~ /\n/) {
     $current->{'contents'}->[-1]->{'text'} .= $text;
     print STDERR "MERGED TEXT: $text|||\n" if ($self->{'debug'});
   }
   else {
-    $current = $paragraph if ($paragraph);
     push @{$current->{'contents'}}, { 'text' => $text, 'parent' => $current };
     print STDERR "NEW TEXT: $text|||\n" if ($self->{'debug'});
   }
@@ -1034,13 +1049,9 @@
 {
   my $self = shift;
   my $current = shift;
-#print STDERR "abort? "._print_current($current);
-#print STDERR "$current->{'contents'}->[-1]";
-#print STDERR "Last content: "._print_current($current->{'contents'}->[-1]);
   if ($current->{'contents'} and @{$current->{'contents'}} 
        and $current->{'contents'}->[-1]->{'type'}
-       and $current->{'contents'}->[-1]->{'type'} eq 'normal_line'
-       and $current->{'contents'}->[-1]->{'text'} !~ /\n/) {
+       and $current->{'contents'}->[-1]->{'type'} eq 'normal_line') {
     print STDERR "ABORT EMPTY\n" if ($self->{'debug'});
     if ($current->{'contents'}->[-1]->{'text'} eq '') {
       pop @{$current->{'contents'}} 
@@ -1289,7 +1300,7 @@
       delete $current->{'HERE !!!!'};
     }
 
-    if (($line !~ /\S/ or $line =~ /^\s*\@/) and not 
+    if (not 
         # raw format or verb
           (($current->{'cmdname'}
            and $block_commands{$current->{'cmdname'}}
@@ -1299,20 +1310,13 @@
            ($current->{'parent'} and $current->{'parent'}->{'cmdname'}
             and $current->{'parent'}->{'cmdname'} eq 'verb')
           )
-        # not in math or preformatted
+        # not in math or preformatted or def line
         and !$no_paragraph_contexts{$self->{'context_stack'}->[-1]}) {
       print STDERR "EMPTY LINE or COMMAND\n" if ($self->{'debug'});
-      if ($line !~ /\S/ and $line =~ /\n/) {
-        $current = _end_paragraph($self, $current, $line_nr);
-      }
-      my $empty_line = $line;
-      if ($line =~ s/^(\s*)\@/\@/) {
-        $empty_line = $1;
-      }
+      $line =~ s/([ \t]*)//;
       push @{$current->{'contents'}}, { 'type' => 'normal_line', 
-                                        'text' => $empty_line,
+                                        'text' => $1,
                                         'parent' => $current };
-      next if ($line !~ /\S/ and $line =~ /\n/);
     } elsif ($line !~ /\S/ and $current->{'type'} 
                and $current->{'type'} eq 'menu_entry_description') {
       # first parent is menu_entry
@@ -1677,7 +1681,8 @@
                   } else {
                     $row->{'special'}->{'cell_number'}++;
                     push @{$row->{'contents'}}, { 'cmdname' => $command,
-                                                'parent' => $row };
+                                                'parent' => $row,
+                                                'contents' => [] };
                     $current = $row->{'contents'}->[-1];
                     print STDERR "TAB\n" if ($self->{'debug'});
                   }
@@ -1688,7 +1693,8 @@
                               'parent' => $parent };
                   push @{$parent->{'contents'}}, $row;
                   push @{$row->{'contents'}}, { 'cmdname' => $command,
-                                                'parent' => $row };
+                                                'parent' => $row,
+                                                'contents' => [] };
                   $current = $row->{'contents'}->[-1];
                 }
               } else {

Index: t/60macro.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/60macro.t,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- t/60macro.t 6 Oct 2010 22:26:12 -0000       1.12
+++ t/60macro.t 9 Oct 2010 13:25:53 -0000       1.13
@@ -176,6 +176,30 @@
 
 @macro2  arg,  comma \,
 '],
+['paragraph_and_macro',
+'@macro empty
address@hidden macro
+
address@hidden space
+   
address@hidden macro
+
address@hidden word
+a word
address@hidden macro
+
address@hidden
+
+  @empty{}  
+
address@hidden text after empty.
+
address@hidden
+
+  @space{}  
+
address@hidden text after space.
+'],
 ['nested_macro_call',
 '@macro machin{}
 (machin)

Index: t/results/macro/macro_in_ifset_end_in_arg.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/macro/macro_in_ifset_end_in_arg.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- t/results/macro/macro_in_ifset_end_in_arg.pl        3 Oct 2010 11:51:37 
-0000       1.1
+++ t/results/macro/macro_in_ifset_end_in_arg.pl        9 Oct 2010 13:25:53 
-0000       1.2
@@ -44,7 +44,8 @@
     {
       'parent' => {},
       'text' => '
-'
+',
+      'type' => 'normal_line'
     },
     {
       'contents' => [

Index: t/results/macro/paragraph_and_macro.pl
===================================================================
RCS file: t/results/macro/paragraph_and_macro.pl
diff -N t/results/macro/paragraph_and_macro.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ t/results/macro/paragraph_and_macro.pl      9 Oct 2010 13:25:53 -0000       
1.1
@@ -0,0 +1,219 @@
+use vars qw(%result_texts %result_trees %result_errors);
+
+$result_trees{'paragraph_and_macro'} = {
+  'contents' => [
+    {
+      'args' => [
+        {
+          'parent' => {},
+          'text' => 'empty',
+          'type' => 'macro_name'
+        }
+      ],
+      'cmdname' => 'macro',
+      'contents' => [],
+      'parent' => {},
+      'special' => {
+        'macro_line' => ' empty
+',
+        'macrobody' => ''
+      }
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'normal_line'
+    },
+    {
+      'args' => [
+        {
+          'parent' => {},
+          'text' => 'space',
+          'type' => 'macro_name'
+        }
+      ],
+      'cmdname' => 'macro',
+      'contents' => [
+        {
+          'parent' => {},
+          'text' => '   
+',
+          'type' => 'raw'
+        }
+      ],
+      'parent' => {},
+      'special' => {
+        'macro_line' => ' space
+',
+        'macrobody' => '   
+'
+      }
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'normal_line'
+    },
+    {
+      'args' => [
+        {
+          'parent' => {},
+          'text' => 'word',
+          'type' => 'macro_name'
+        }
+      ],
+      'cmdname' => 'macro',
+      'contents' => [
+        {
+          'parent' => {},
+          'text' => 'a word
+',
+          'type' => 'raw'
+        }
+      ],
+      'parent' => {},
+      'special' => {
+        'macro_line' => ' word
+',
+        'macrobody' => 'a word
+'
+      }
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'normal_line'
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'normal_line'
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'normal_line'
+    },
+    {
+      'parent' => {},
+      'text' => '    
+',
+      'type' => 'normal_line'
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'normal_line'
+    },
+    {
+      'contents' => [
+        {
+          'parent' => {},
+          'text' => ' text after empty.
+'
+        }
+      ],
+      'parent' => {},
+      'type' => 'paragraph'
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'normal_line'
+    },
+    {
+      'parent' => {},
+      'text' => '   
+',
+      'type' => 'normal_line'
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'normal_line'
+    },
+    {
+      'parent' => {},
+      'text' => '       
+',
+      'type' => 'normal_line'
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'normal_line'
+    },
+    {
+      'contents' => [
+        {
+          'parent' => {},
+          'text' => '    text after space.
+'
+        }
+      ],
+      'parent' => {},
+      'type' => 'paragraph'
+    }
+  ]
+};
+$result_trees{'paragraph_and_macro'}{'contents'}[0]{'args'}[0]{'parent'} = 
$result_trees{'paragraph_and_macro'}{'contents'}[0];
+$result_trees{'paragraph_and_macro'}{'contents'}[0]{'parent'} = 
$result_trees{'paragraph_and_macro'};
+$result_trees{'paragraph_and_macro'}{'contents'}[1]{'parent'} = 
$result_trees{'paragraph_and_macro'};
+$result_trees{'paragraph_and_macro'}{'contents'}[2]{'args'}[0]{'parent'} = 
$result_trees{'paragraph_and_macro'}{'contents'}[2];
+$result_trees{'paragraph_and_macro'}{'contents'}[2]{'contents'}[0]{'parent'} = 
$result_trees{'paragraph_and_macro'}{'contents'}[2];
+$result_trees{'paragraph_and_macro'}{'contents'}[2]{'parent'} = 
$result_trees{'paragraph_and_macro'};
+$result_trees{'paragraph_and_macro'}{'contents'}[3]{'parent'} = 
$result_trees{'paragraph_and_macro'};
+$result_trees{'paragraph_and_macro'}{'contents'}[4]{'args'}[0]{'parent'} = 
$result_trees{'paragraph_and_macro'}{'contents'}[4];
+$result_trees{'paragraph_and_macro'}{'contents'}[4]{'contents'}[0]{'parent'} = 
$result_trees{'paragraph_and_macro'}{'contents'}[4];
+$result_trees{'paragraph_and_macro'}{'contents'}[4]{'parent'} = 
$result_trees{'paragraph_and_macro'};
+$result_trees{'paragraph_and_macro'}{'contents'}[5]{'parent'} = 
$result_trees{'paragraph_and_macro'};
+$result_trees{'paragraph_and_macro'}{'contents'}[6]{'parent'} = 
$result_trees{'paragraph_and_macro'};
+$result_trees{'paragraph_and_macro'}{'contents'}[7]{'parent'} = 
$result_trees{'paragraph_and_macro'};
+$result_trees{'paragraph_and_macro'}{'contents'}[8]{'parent'} = 
$result_trees{'paragraph_and_macro'};
+$result_trees{'paragraph_and_macro'}{'contents'}[9]{'parent'} = 
$result_trees{'paragraph_and_macro'};
+$result_trees{'paragraph_and_macro'}{'contents'}[10]{'contents'}[0]{'parent'} 
= $result_trees{'paragraph_and_macro'}{'contents'}[10];
+$result_trees{'paragraph_and_macro'}{'contents'}[10]{'parent'} = 
$result_trees{'paragraph_and_macro'};
+$result_trees{'paragraph_and_macro'}{'contents'}[11]{'parent'} = 
$result_trees{'paragraph_and_macro'};
+$result_trees{'paragraph_and_macro'}{'contents'}[12]{'parent'} = 
$result_trees{'paragraph_and_macro'};
+$result_trees{'paragraph_and_macro'}{'contents'}[13]{'parent'} = 
$result_trees{'paragraph_and_macro'};
+$result_trees{'paragraph_and_macro'}{'contents'}[14]{'parent'} = 
$result_trees{'paragraph_and_macro'};
+$result_trees{'paragraph_and_macro'}{'contents'}[15]{'parent'} = 
$result_trees{'paragraph_and_macro'};
+$result_trees{'paragraph_and_macro'}{'contents'}[16]{'contents'}[0]{'parent'} 
= $result_trees{'paragraph_and_macro'}{'contents'}[16];
+$result_trees{'paragraph_and_macro'}{'contents'}[16]{'parent'} = 
$result_trees{'paragraph_and_macro'};
+
+$result_texts{'paragraph_and_macro'} = '@macro empty
address@hidden macro
+
address@hidden space
+   
address@hidden macro
+
address@hidden word
+a word
address@hidden macro
+
+
+
+    
+
+ text after empty.
+
+   
+
+       
+
+    text after space.
+';
+
+$result_errors{'paragraph_and_macro'} = [];
+
+



reply via email to

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