texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp Texinfo/Parser.pm t/20preformatted.t...


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Parser.pm t/20preformatted.t...
Date: Sun, 30 Jan 2011 17:23:38 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/01/30 17:23:37

Modified files:
        tp/Texinfo     : Parser.pm 
        tp/t           : 20preformatted.t 
Added files:
        tp/t/results/preformatted: caption_in_example.pl 
                                   titlefont_in_example.pl 

Log message:
        Restart preformatted after being stopped by a command with braces.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.183&r2=1.184
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/20preformatted.t?cvsroot=texinfo&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/preformatted/caption_in_example.pl?cvsroot=texinfo&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/preformatted/titlefont_in_example.pl?cvsroot=texinfo&rev=1.1

Patches:
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.183
retrieving revision 1.184
diff -u -b -r1.183 -r1.184
--- Texinfo/Parser.pm   30 Jan 2011 17:00:47 -0000      1.183
+++ Texinfo/Parser.pm   30 Jan 2011 17:23:37 -0000      1.184
@@ -475,7 +475,7 @@
 }
 
 my %close_preformatted_commands = %close_paragraph_commands;
-foreach my $no_close_preformatted('center', 'insertcopying', 'sp') {
+foreach my $no_close_preformatted('sp') {
   delete $close_preformatted_commands{$no_close_preformatted};
 }
 
@@ -1954,6 +1954,7 @@
          $current->{'parent'}->{'extra'}->{'original_def_cmdname'}), 
$line_nr); 
     }
     $current = $current->{'parent'}->{'parent'};
+    $current = $self->_begin_preformatted($current);
 
   # other block command lines
   } elsif ($current->{'type'}
@@ -3532,6 +3533,7 @@
               # Remove empty arguments, as far as possible
               _remove_empty_content_arguments($current);
             }
+            my $closed_command = $current->{'parent'}->{'cmdname'};
             print STDERR "CLOSING address@hidden>{'parent'}->{'cmdname'}\n" if 
($self->{'DEBUG'});
             delete $current->{'parent'}->{'remaining_args'};
             if ($current->{'parent'}->{'cmdname'} eq 'anchor') {
@@ -3551,6 +3553,8 @@
                   'text' => '' };                          
             }
             $current = $current->{'parent'}->{'parent'};
+            $current = $self->_begin_preformatted ($current)
+               if ($close_preformatted_commands{$closed_command});
           # footnote caption closing, when there is a paragraph inside.
           } elsif ($context_brace_commands{$self->{'context_stack'}->[-1]}) {
              # closing the context under broader situations
@@ -3564,7 +3568,10 @@
                die "BUG: def_context $context_command 
"._print_current($current) 
                  if ($context_command ne $current->{'parent'}->{'cmdname'});
                print STDERR "CLOSING address@hidden>{'parent'}->{'cmdname'}\n" 
if ($self->{'DEBUG'});
+              my $closed_command = $current->{'parent'}->{'cmdname'};
                $current = $current->{'parent'}->{'parent'};
+              $current = $self->_begin_preformatted ($current)
+                 if ($close_preformatted_commands{$closed_command});
             }
           } else {
             $self->line_error (sprintf($self->__("Misplaced %c"),

Index: t/20preformatted.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/20preformatted.t,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- t/20preformatted.t  30 Jan 2011 17:00:48 -0000      1.3
+++ t/20preformatted.t  30 Jan 2011 17:23:37 -0000      1.4
@@ -26,7 +26,32 @@
 @example
 @end example text after end example nested in example
 @end example
-']
+'],
+['def_in_example',
+'@example
address@hidden name arg
+in defun
address@hidden defun
address@hidden example
+'],
+['caption_in_example',
+'@float float
+
address@hidden
+in example 
+
address@hidden
+
+After caption
address@hidden example
address@hidden float
+'],
+['titlefont_in_example',
+'@example
address@hidden
+Text.
address@hidden example
+'],
 );
 
 my @test_invalid = (

Index: t/results/preformatted/caption_in_example.pl
===================================================================
RCS file: t/results/preformatted/caption_in_example.pl
diff -N t/results/preformatted/caption_in_example.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ t/results/preformatted/caption_in_example.pl        30 Jan 2011 17:23:37 
-0000      1.1
@@ -0,0 +1,254 @@
+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{'caption_in_example'} = {
+  'contents' => [
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'parent' => {},
+              'text' => ' ',
+              'type' => 'empty_spaces_after_command'
+            },
+            {
+              'parent' => {},
+              'text' => 'float'
+            },
+            {
+              'parent' => {},
+              'text' => '
+',
+              'type' => 'space_at_end_block_command'
+            }
+          ],
+          'parent' => {},
+          'type' => 'block_line_arg'
+        }
+      ],
+      'cmdname' => 'float',
+      'contents' => [
+        {
+          'parent' => {},
+          'text' => '
+',
+          'type' => 'empty_line'
+        },
+        {
+          'cmdname' => 'example',
+          'contents' => [
+            {
+              'parent' => {},
+              'text' => '
+',
+              'type' => 'empty_line_after_command'
+            },
+            {
+              'contents' => [
+                {
+                  'parent' => {},
+                  'text' => 'in example 
+'
+                },
+                {
+                  'parent' => {},
+                  'text' => '
+',
+                  'type' => 'empty_line'
+                }
+              ],
+              'parent' => {},
+              'type' => 'preformatted'
+            },
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'contents' => [
+                        {
+                          'parent' => {},
+                          'text' => 'caption'
+                        }
+                      ],
+                      'parent' => {},
+                      'type' => 'paragraph'
+                    }
+                  ],
+                  'parent' => {},
+                  'type' => 'brace_command_context'
+                }
+              ],
+              'cmdname' => 'caption',
+              'contents' => [],
+              'extra' => {
+                'float' => {}
+              },
+              'line_nr' => {
+                'file_name' => '',
+                'line_nr' => 6,
+                'macro' => ''
+              },
+              'parent' => {}
+            },
+            {
+              'contents' => [
+                {
+                  'parent' => {},
+                  'text' => '
+'
+                },
+                {
+                  'parent' => {},
+                  'text' => '
+',
+                  'type' => 'empty_line'
+                },
+                {
+                  'parent' => {},
+                  'text' => 'After caption
+'
+                }
+              ],
+              'parent' => {},
+              'type' => 'preformatted'
+            }
+          ],
+          'parent' => {}
+        },
+        {
+          'parent' => {},
+          'text' => '
+',
+          'type' => 'empty_line_after_command'
+        }
+      ],
+      'extra' => {
+        'block_command_line_contents' => [
+          [
+            {}
+          ]
+        ],
+        'caption' => {},
+        'type' => {
+          'content' => [
+            {}
+          ],
+          'normalized' => 'float'
+        }
+      },
+      'line_nr' => {
+        'file_name' => '',
+        'line_nr' => 1,
+        'macro' => ''
+      },
+      'parent' => {}
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'empty_line_after_command'
+    }
+  ],
+  'type' => 'text_root'
+};
+$result_trees{'caption_in_example'}{'contents'}[0]{'args'}[0]{'contents'}[0]{'parent'}
 = $result_trees{'caption_in_example'}{'contents'}[0]{'args'}[0];
+$result_trees{'caption_in_example'}{'contents'}[0]{'args'}[0]{'contents'}[1]{'parent'}
 = $result_trees{'caption_in_example'}{'contents'}[0]{'args'}[0];
+$result_trees{'caption_in_example'}{'contents'}[0]{'args'}[0]{'contents'}[2]{'parent'}
 = $result_trees{'caption_in_example'}{'contents'}[0]{'args'}[0];
+$result_trees{'caption_in_example'}{'contents'}[0]{'args'}[0]{'parent'} = 
$result_trees{'caption_in_example'}{'contents'}[0];
+$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[0]{'parent'} = 
$result_trees{'caption_in_example'}{'contents'}[0];
+$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[0]{'parent'}
 = $result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1];
+$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[1]{'contents'}[0]{'parent'}
 = 
$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[1];
+$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[1]{'contents'}[1]{'parent'}
 = 
$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[1];
+$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[1]{'parent'}
 = $result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1];
+$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[2]{'args'}[0]{'contents'}[0]{'contents'}[0]{'parent'}
 = 
$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[2]{'args'}[0]{'contents'}[0];
+$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[2]{'args'}[0]{'contents'}[0]{'parent'}
 = 
$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[2]{'args'}[0];
+$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[2]{'args'}[0]{'parent'}
 = 
$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[2];
+$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[2]{'extra'}{'float'}
 = $result_trees{'caption_in_example'}{'contents'}[0];
+$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[2]{'parent'}
 = $result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1];
+$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[3]{'contents'}[0]{'parent'}
 = 
$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[3];
+$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[3]{'contents'}[1]{'parent'}
 = 
$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[3];
+$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[3]{'contents'}[2]{'parent'}
 = 
$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[3];
+$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[3]{'parent'}
 = $result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1];
+$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'parent'} = 
$result_trees{'caption_in_example'}{'contents'}[0];
+$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[2]{'parent'} = 
$result_trees{'caption_in_example'}{'contents'}[0];
+$result_trees{'caption_in_example'}{'contents'}[0]{'extra'}{'block_command_line_contents'}[0][0]
 = $result_trees{'caption_in_example'}{'contents'}[0]{'args'}[0]{'contents'}[1];
+$result_trees{'caption_in_example'}{'contents'}[0]{'extra'}{'caption'} = 
$result_trees{'caption_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[2];
+$result_trees{'caption_in_example'}{'contents'}[0]{'extra'}{'type'}{'content'}[0]
 = $result_trees{'caption_in_example'}{'contents'}[0]{'args'}[0]{'contents'}[1];
+$result_trees{'caption_in_example'}{'contents'}[0]{'parent'} = 
$result_trees{'caption_in_example'};
+$result_trees{'caption_in_example'}{'contents'}[1]{'parent'} = 
$result_trees{'caption_in_example'};
+
+$result_texis{'caption_in_example'} = '@float float
+
address@hidden
+in example 
+
address@hidden
+
+After caption
address@hidden example
address@hidden float
+';
+
+
+$result_texts{'caption_in_example'} = '
+in example 
+
+
+
+After caption
+';
+
+$result_errors{'caption_in_example'} = [
+  {
+    'error_line' => ':6: warning: @caption should be right below 
address@hidden'
+',
+    'file_name' => '',
+    'line_nr' => 6,
+    'macro' => '',
+    'text' => '@caption should be right below address@hidden'',
+    'type' => 'warning'
+  }
+];
+
+
+$result_floats{'caption_in_example'} = {
+  'float' => [
+    {
+      'cmdname' => 'float',
+      'extra' => {
+        'caption' => {
+          'cmdname' => 'caption',
+          'extra' => {
+            'float' => {}
+          }
+        },
+        'type' => {
+          'content' => [
+            {
+              'text' => 'float'
+            }
+          ],
+          'normalized' => 'float'
+        }
+      }
+    }
+  ]
+};
+$result_floats{'caption_in_example'}{'float'}[0]{'extra'}{'caption'}{'extra'}{'float'}
 = $result_floats{'caption_in_example'}{'float'}[0];
+
+
+
+$result_converted{'plaintext'}->{'caption_in_example'} = '
+     in example
+
+
+
+     After caption
+float: caption
+';
+
+1;

Index: t/results/preformatted/titlefont_in_example.pl
===================================================================
RCS file: t/results/preformatted/titlefont_in_example.pl
diff -N t/results/preformatted/titlefont_in_example.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ t/results/preformatted/titlefont_in_example.pl      30 Jan 2011 17:23:37 
-0000      1.1
@@ -0,0 +1,105 @@
+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{'titlefont_in_example'} = {
+  'contents' => [
+    {
+      'cmdname' => 'example',
+      'contents' => [
+        {
+          'parent' => {},
+          'text' => '
+',
+          'type' => 'empty_line_after_command'
+        },
+        {
+          'args' => [
+            {
+              'contents' => [
+                {
+                  'parent' => {},
+                  'text' => 'Title'
+                }
+              ],
+              'parent' => {},
+              'type' => 'brace_command_arg'
+            }
+          ],
+          'cmdname' => 'titlefont',
+          'contents' => [],
+          'extra' => {
+            'brace_command_contents' => [
+              [
+                {}
+              ]
+            ]
+          },
+          'line_nr' => {
+            'file_name' => '',
+            'line_nr' => 2,
+            'macro' => ''
+          },
+          'parent' => {}
+        },
+        {
+          'contents' => [
+            {
+              'parent' => {},
+              'text' => '
+'
+            },
+            {
+              'parent' => {},
+              'text' => 'Text.
+'
+            }
+          ],
+          'parent' => {},
+          'type' => 'preformatted'
+        }
+      ],
+      'parent' => {}
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'empty_line_after_command'
+    }
+  ],
+  'type' => 'text_root'
+};
+$result_trees{'titlefont_in_example'}{'contents'}[0]{'contents'}[0]{'parent'} 
= $result_trees{'titlefont_in_example'}{'contents'}[0];
+$result_trees{'titlefont_in_example'}{'contents'}[0]{'contents'}[1]{'args'}[0]{'contents'}[0]{'parent'}
 = 
$result_trees{'titlefont_in_example'}{'contents'}[0]{'contents'}[1]{'args'}[0];
+$result_trees{'titlefont_in_example'}{'contents'}[0]{'contents'}[1]{'args'}[0]{'parent'}
 = $result_trees{'titlefont_in_example'}{'contents'}[0]{'contents'}[1];
+$result_trees{'titlefont_in_example'}{'contents'}[0]{'contents'}[1]{'extra'}{'brace_command_contents'}[0][0]
 = 
$result_trees{'titlefont_in_example'}{'contents'}[0]{'contents'}[1]{'args'}[0]{'contents'}[0];
+$result_trees{'titlefont_in_example'}{'contents'}[0]{'contents'}[1]{'parent'} 
= $result_trees{'titlefont_in_example'}{'contents'}[0];
+$result_trees{'titlefont_in_example'}{'contents'}[0]{'contents'}[2]{'contents'}[0]{'parent'}
 = $result_trees{'titlefont_in_example'}{'contents'}[0]{'contents'}[2];
+$result_trees{'titlefont_in_example'}{'contents'}[0]{'contents'}[2]{'contents'}[1]{'parent'}
 = $result_trees{'titlefont_in_example'}{'contents'}[0]{'contents'}[2];
+$result_trees{'titlefont_in_example'}{'contents'}[0]{'contents'}[2]{'parent'} 
= $result_trees{'titlefont_in_example'}{'contents'}[0];
+$result_trees{'titlefont_in_example'}{'contents'}[0]{'parent'} = 
$result_trees{'titlefont_in_example'};
+$result_trees{'titlefont_in_example'}{'contents'}[1]{'parent'} = 
$result_trees{'titlefont_in_example'};
+
+$result_texis{'titlefont_in_example'} = '@example
address@hidden
+Text.
address@hidden example
+';
+
+
+$result_texts{'titlefont_in_example'} = 'Title
+Text.
+';
+
+$result_errors{'titlefont_in_example'} = [];
+
+
+
+$result_converted{'plaintext'}->{'titlefont_in_example'} = '     Title
+**********
+
+     Text.
+';
+
+1;



reply via email to

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