texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp Texinfo/Parser.pm Texinfo/Convert/Pl...


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Parser.pm Texinfo/Convert/Pl...
Date: Sat, 04 Dec 2010 17:59:19 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        10/12/04 17:59:19

Modified files:
        tp/Texinfo     : Parser.pm 
        tp/Texinfo/Convert: Plaintext.pm 
        tp/t           : 02coverage.t test_utils.pl 
Added files:
        tp/t/results/coverage: insertcopying.pl 

Log message:
        Give global command information, give the parser to the converter, and
        use the information to handle @listoffloats.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.160&r2=1.161
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/02coverage.t?cvsroot=texinfo&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/test_utils.pl?cvsroot=texinfo&r1=1.57&r2=1.58
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/coverage/insertcopying.pl?cvsroot=texinfo&rev=1.1

Patches:
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.160
retrieving revision 1.161
diff -u -b -r1.160 -r1.161
--- Texinfo/Parser.pm   4 Dec 2010 14:54:06 -0000       1.160
+++ Texinfo/Parser.pm   4 Dec 2010 17:59:19 -0000       1.161
@@ -66,6 +66,7 @@
   errors
   indices_information
   floats_information
+  global_commands_information
   gdt
 ) ] );
 
@@ -782,6 +783,12 @@
   return $self->{'floats'};
 }
 
+sub global_commands_information ($)
+{
+  my $self = shift;
+  return $self->{'extra'};
+}
+
 # Following are the internal subsections.  The most important are
 # _parse_texi:  the main parser loop.
 # _end_line:    called at an end of line.  Opening if @include lines is 

Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- Texinfo/Convert/Plaintext.pm        4 Dec 2010 13:19:38 -0000       1.23
+++ Texinfo/Convert/Plaintext.pm        4 Dec 2010 17:59:19 -0000       1.24
@@ -164,7 +164,8 @@
 }
 
 # FIXME pass raw formats handled (or not handled)
-foreach my $ignored_block_commands ('ignore', 'macro', 'rmacro') {
+foreach my $ignored_block_commands ('ignore', 'macro', 'rmacro', 'copying',
+  'documentdescription', 'titlepage') {
   $ignored_commands{$ignored_block_commands} = 1;
 }
 
@@ -260,6 +261,10 @@
     $name = ref($converter);
   }
   if (defined($conf)) {
+    if ($conf->{'parser'}) {
+      $converter->{'parser'} = $conf->{'parser'};
+      delete $conf->{'parser'};
+    }
     foreach my $key (keys(%$conf)) {
       if (!exists($defaults{$key})) {
         warn "$key not a possible configuration in $name\n";
@@ -523,7 +528,6 @@
   # 
   # other commands processed:
   # verbatiminclude
-  # sp
   # insertcopying
   # listoffloats
   # dircategory
@@ -835,7 +839,6 @@
         print STDERR "MULTITABLE_SIZES @$columnsize\n" if ($self->{'debug'});
         $self->{'format_context'}->[-1]->{'columns_size'} = $columnsize;
       } elsif ($root->{'cmdname'} eq 'direntry') {
-        # FIXME main::line_warn(__("address@hidden after first node"), 
$Texi2HTML::THISDOC{'line_nr'}) if (defined($info_default_current_node)); 
         $result .= "START-INFO-DIR-ENTRY\n";
       }
 
@@ -910,8 +913,17 @@
         }
         $cell = 1;
       } elsif ($root->{'cmdname'} eq 'insertcopying') {
-        # FIXME handle insertcopying
+        if (defined($self->{'parser'})) {
+          my $global_commands = 
$self->{'parser'}->global_commands_information();
+          if ($global_commands and $global_commands->{'copying'}) {
+            unshift @{$self->{'current_contents'}->[-1]}, 
+               {'contents' => $global_commands->{'copying'}->{'contents'}};
+          }
+        }
       } elsif ($root->{'cmdname'} eq 'listoffloats') {
+        if (defined($self->{'parser'})) {
+          my $floats = $self->{'parser'}->floats_information();
+        }
         # FIXME handle listoffloats
       } elsif ($root->{'cmdname'} eq 'sp') {
         if ($root->{'extra'}->{'misc_args'}->[0]) {

Index: t/02coverage.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/02coverage.t,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- t/02coverage.t      1 Dec 2010 22:39:44 -0000       1.26
+++ t/02coverage.t      4 Dec 2010 17:59:19 -0000       1.27
@@ -235,7 +235,20 @@
 ['cartouche',
 '@cartouche
 in cartouche.
address@hidden cartouche']
address@hidden cartouche'],
+['insertcopying',
+'@copying
+License.
+
address@hidden 
+You are not allowed.
address@hidden quotation
address@hidden copying
+
+License:
+
address@hidden
+']
 );
 
 my @test_invalid = (

Index: t/test_utils.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/test_utils.pl,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -b -r1.57 -r1.58
--- t/test_utils.pl     1 Dec 2010 22:39:44 -0000       1.57
+++ t/test_utils.pl     4 Dec 2010 17:59:19 -0000       1.58
@@ -170,11 +170,14 @@
 sub filter_floats_keys { [grep {!$avoided_keys_floats{$_}}
    ( sort keys %{$_[0]} )] }
 
-sub convert_to_plaintext($$)
+sub convert_to_plaintext($$$)
 {
   my $self = shift;
   my $tree = shift;
-  my $converter = Texinfo::Convert::Plaintext::converter({'debug' => 
$self->{'debug'}});
+  my $parser = shift;
+  my $converter = 
+     Texinfo::Convert::Plaintext::converter({'debug' => $self->{'debug'},
+                                             'parser' => $parser });
   return $converter->convert($tree);
 }
 
@@ -239,7 +242,7 @@
   my %converted;
   foreach my $format (@tested_formats) {
     if (defined($formats{$format})) {
-      $converted{$format} = &{$formats{$format}}($self, $result);
+      $converted{$format} = &{$formats{$format}}($self, $result, $parser);
       #print STDERR "$format: \n$converted{$format}";
     }
   }

Index: t/results/coverage/insertcopying.pl
===================================================================
RCS file: t/results/coverage/insertcopying.pl
diff -N t/results/coverage/insertcopying.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ t/results/coverage/insertcopying.pl 4 Dec 2010 17:59:19 -0000       1.1
@@ -0,0 +1,156 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
+   %result_indices %result_sectioning %result_nodes %result_menus
+   %result_floats %result_converted);
+
+$result_trees{'insertcopying'} = {
+  'contents' => [
+    {
+      'cmdname' => 'copying',
+      'contents' => [
+        {
+          'parent' => {},
+          'text' => '
+',
+          'type' => 'empty_line_after_command'
+        },
+        {
+          'contents' => [
+            {
+              'parent' => {},
+              'text' => 'License.
+'
+            }
+          ],
+          'parent' => {},
+          'type' => 'paragraph'
+        },
+        {
+          'parent' => {},
+          'text' => '
+',
+          'type' => 'empty_line'
+        },
+        {
+          'cmdname' => 'quotation',
+          'contents' => [
+            {
+              'parent' => {},
+              'text' => ' 
+',
+              'type' => 'empty_line_after_command'
+            },
+            {
+              'contents' => [
+                {
+                  'parent' => {},
+                  'text' => 'You are not allowed.
+'
+                }
+              ],
+              'parent' => {},
+              'type' => 'paragraph'
+            }
+          ],
+          'parent' => {}
+        },
+        {
+          'parent' => {},
+          'text' => '
+',
+          'type' => 'empty_line_after_command'
+        }
+      ],
+      'parent' => {}
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'empty_line_after_command'
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'empty_line'
+    },
+    {
+      'contents' => [
+        {
+          'parent' => {},
+          'text' => 'License:
+'
+        }
+      ],
+      'parent' => {},
+      'type' => 'paragraph'
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'empty_line'
+    },
+    {
+      'cmdname' => 'insertcopying',
+      'parent' => {}
+    },
+    {
+      'parent' => {},
+      'text' => '
+'
+    }
+  ],
+  'type' => 'text_root'
+};
+$result_trees{'insertcopying'}{'contents'}[0]{'contents'}[0]{'parent'} = 
$result_trees{'insertcopying'}{'contents'}[0];
+$result_trees{'insertcopying'}{'contents'}[0]{'contents'}[1]{'contents'}[0]{'parent'}
 = $result_trees{'insertcopying'}{'contents'}[0]{'contents'}[1];
+$result_trees{'insertcopying'}{'contents'}[0]{'contents'}[1]{'parent'} = 
$result_trees{'insertcopying'}{'contents'}[0];
+$result_trees{'insertcopying'}{'contents'}[0]{'contents'}[2]{'parent'} = 
$result_trees{'insertcopying'}{'contents'}[0];
+$result_trees{'insertcopying'}{'contents'}[0]{'contents'}[3]{'contents'}[0]{'parent'}
 = $result_trees{'insertcopying'}{'contents'}[0]{'contents'}[3];
+$result_trees{'insertcopying'}{'contents'}[0]{'contents'}[3]{'contents'}[1]{'contents'}[0]{'parent'}
 = $result_trees{'insertcopying'}{'contents'}[0]{'contents'}[3]{'contents'}[1];
+$result_trees{'insertcopying'}{'contents'}[0]{'contents'}[3]{'contents'}[1]{'parent'}
 = $result_trees{'insertcopying'}{'contents'}[0]{'contents'}[3];
+$result_trees{'insertcopying'}{'contents'}[0]{'contents'}[3]{'parent'} = 
$result_trees{'insertcopying'}{'contents'}[0];
+$result_trees{'insertcopying'}{'contents'}[0]{'contents'}[4]{'parent'} = 
$result_trees{'insertcopying'}{'contents'}[0];
+$result_trees{'insertcopying'}{'contents'}[0]{'parent'} = 
$result_trees{'insertcopying'};
+$result_trees{'insertcopying'}{'contents'}[1]{'parent'} = 
$result_trees{'insertcopying'};
+$result_trees{'insertcopying'}{'contents'}[2]{'parent'} = 
$result_trees{'insertcopying'};
+$result_trees{'insertcopying'}{'contents'}[3]{'contents'}[0]{'parent'} = 
$result_trees{'insertcopying'}{'contents'}[3];
+$result_trees{'insertcopying'}{'contents'}[3]{'parent'} = 
$result_trees{'insertcopying'};
+$result_trees{'insertcopying'}{'contents'}[4]{'parent'} = 
$result_trees{'insertcopying'};
+$result_trees{'insertcopying'}{'contents'}[5]{'parent'} = 
$result_trees{'insertcopying'};
+$result_trees{'insertcopying'}{'contents'}[6]{'parent'} = 
$result_trees{'insertcopying'};
+
+$result_texis{'insertcopying'} = '@copying
+License.
+
address@hidden 
+You are not allowed.
address@hidden quotation
address@hidden copying
+
+License:
+
address@hidden
+';
+
+
+$result_texts{'insertcopying'} = '
+License:
+
+
+';
+
+$result_errors{'insertcopying'} = [];
+
+
+
+$result_converted{'plaintext'}->{'insertcopying'} = '
+License:
+
+   License.
+
+     You are not allowed.
+';
+
+1;



reply via email to

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