texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp TODO Texinfo/Common.pm Texinfo/Conve...


From: Patrice Dumas
Subject: texinfo/tp TODO Texinfo/Common.pm Texinfo/Conve...
Date: Thu, 11 Aug 2011 22:08:51 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/08/11 22:08:51

Modified files:
        tp             : TODO 
        tp/Texinfo     : Common.pm 
        tp/Texinfo/Convert: Converter.pm HTML.pm Plaintext.pm Text.pm 

Log message:
        Handle @verbatiminclude in Text, especially when there is a 'converter'
        defined.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/TODO?cvsroot=texinfo&r1=1.149&r2=1.150
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Common.pm?cvsroot=texinfo&r1=1.53&r2=1.54
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Converter.pm?cvsroot=texinfo&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.121&r2=1.122
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.146&r2=1.147
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Text.pm?cvsroot=texinfo&r1=1.50&r2=1.51

Patches:
Index: TODO
===================================================================
RCS file: /sources/texinfo/texinfo/tp/TODO,v
retrieving revision 1.149
retrieving revision 1.150
diff -u -b -r1.149 -r1.150
--- TODO        8 Aug 2011 01:34:35 -0000       1.149
+++ TODO        11 Aug 2011 22:08:51 -0000      1.150
@@ -135,9 +135,13 @@
 
 test an lone @contents without any sectioning command.
 
-Fix @address@hidden and @sc{@'e} in HTML.  Test with 8bit and utf_, with and 
without
+Test @address@hidden and @sc{@'e} in HTML with 8bit and utf_, with and without
 enable encoding and entities.
 
+Test that some constructs in @copying in comments in HTML are converted
+differently (as there is a 'converter' passed to Texinfo::Text) than when
+there are in a Text expansion context.
+
 construct like 
   @menu @c 
 leads to a menu_comment holding a preformatted which only contains

Index: Texinfo/Common.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Common.pm,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- Texinfo/Common.pm   4 Aug 2011 23:22:27 -0000       1.53
+++ Texinfo/Common.pm   11 Aug 2011 22:08:51 -0000      1.54
@@ -724,6 +724,13 @@
   if ($text =~ m,^(/|\./|\.\./),) {
     $file = $text if (-e $text and -r $text);
   } else {
+    my @dirs;
+    if ($self) {
+      @dirs = @{$self->{'include_directories'}};
+    } else {
+      # no object with directory list and not an absolute path, never succeed
+      return undef;
+    }
     foreach my $dir (@{$self->{'include_directories'}}) {
       $file = "$dir/$text" if (-e "$dir/$text" and -r "$dir/$text");
       last if (defined($file));
@@ -803,6 +810,45 @@
   return ($canonical_texinfo_encoding, $perl_encoding, 
$canonical_output_encoding);
 }
 
+# This should do the job, or at least don't do wrong if $self
+# is not defined, as could be the case if called from 
+# Texinfo::Convert::Text.
+sub expand_verbatiminclude($$)
+{
+  my $self = shift;
+  my $current = shift;
+
+  return unless ($current->{'extra'} and 
defined($current->{'extra'}->{'text_arg'}));
+  my $text = $current->{'extra'}->{'text_arg'};
+  my $file = locate_include_file($self, $text);
+
+  my $verbatiminclude;
+
+  if (defined($file)) {
+    # FIXME encoding?
+    if (!open(VERBINCLUDE, $file)) {
+      if ($self) {
+        $self->line_error (sprintf($self->__("Cannot read %s: %s"), $file, 
$!), 
+                            $current->{'line_nr'});
+      }
+    } else {
+      $verbatiminclude = { 'cmdname' => 'verbatim',
+                           'parent' => $current->{'parent'},
+                           'extra' => 
+                        {'text_arg' => $current->{'extra'}->{'text_arg'}} };
+      while (<VERBINCLUDE>) {
+        push @{$verbatiminclude->{'contents'}}, 
+                  {'type' => 'raw', 'text' => $_ };
+      }
+      close (VERBINCLUDE);
+    }
+  } elsif ($self) {
+    $self->line_error (sprintf($self->__("address@hidden: Cannot find %s"), 
+                    $current->{'cmdname'}, $text), $current->{'line_nr'});
+  }
+  return $verbatiminclude;
+}
+
 sub definition_category($$)
 {
   my $self = shift;

Index: Texinfo/Convert/Converter.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Converter.pm,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- Texinfo/Convert/Converter.pm        11 Aug 2011 21:38:16 -0000      1.25
+++ Texinfo/Convert/Converter.pm        11 Aug 2011 22:08:51 -0000      1.26
@@ -377,40 +377,6 @@
   );
 }
 
-sub expand_verbatiminclude($$)
-{
-  my $self = shift;
-  my $current = shift;
-
-  return unless ($current->{'extra'} and 
defined($current->{'extra'}->{'text_arg'}));
-  my $text = $current->{'extra'}->{'text_arg'};
-  my $file = Texinfo::Common::locate_include_file($self, $text);
-
-  my $verbatiminclude;
-
-  if (defined($file)) {
-    # FIXME encoding?
-    if (!open(VERBINCLUDE, $file)) {
-      $self->line_error (sprintf($self->__("Cannot read %s: %s"), $file, $!), 
-                          $current->{'line_nr'});
-    } else {
-      $verbatiminclude = { 'cmdname' => 'verbatim',
-                           'parent' => $current->{'parent'},
-                           'extra' => 
-                        {'text_arg' => $current->{'extra'}->{'text_arg'}} };
-      while (<VERBINCLUDE>) {
-        push @{$verbatiminclude->{'contents'}}, 
-                  {'type' => 'raw', 'text' => $_ };
-      }
-      close (VERBINCLUDE);
-    }
-  } else {
-    $self->line_error (sprintf($self->__("address@hidden: Cannot find %s"), 
-                    $current->{'cmdname'}, $text), $current->{'line_nr'});
-  }
-  return $verbatiminclude;
-}
-
 sub _create_destination_directory($)
 {
   my $self = shift;

Index: Texinfo/Convert/HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -b -r1.121 -r1.122
--- Texinfo/Convert/HTML.pm     11 Aug 2011 21:38:16 -0000      1.121
+++ Texinfo/Convert/HTML.pm     11 Aug 2011 22:08:51 -0000      1.122
@@ -2150,7 +2150,8 @@
   my $command = shift;
   my $args = shift;
 
-  my $verbatim_include_verbatim = $self->expand_verbatiminclude($command);
+  my $verbatim_include_verbatim 
+    = $self->Texinfo::Common::expand_verbatiminclude($command);
   if (defined($verbatim_include_verbatim)) {
     return $self->convert_tree($verbatim_include_verbatim);
   } else {

Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.146
retrieving revision 1.147
diff -u -b -r1.146 -r1.147
--- Texinfo/Convert/Plaintext.pm        11 Aug 2011 21:38:16 -0000      1.146
+++ Texinfo/Convert/Plaintext.pm        11 Aug 2011 22:08:51 -0000      1.147
@@ -1841,7 +1841,7 @@
       }
       return $result;
     } elsif ($root->{'cmdname'} eq 'verbatiminclude') {
-      my $expansion = $self->expand_verbatiminclude($root);
+      my $expansion = $self->Texinfo::Common::expand_verbatiminclude($root);
       unshift @{$self->{'current_contents'}->[-1]}, $expansion
         if ($expansion);
       return '';

Index: Texinfo/Convert/Text.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Text.pm,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- Texinfo/Convert/Text.pm     11 Aug 2011 21:38:16 -0000      1.50
+++ Texinfo/Convert/Text.pm     11 Aug 2011 22:08:51 -0000      1.51
@@ -534,10 +534,8 @@
    },
 );
 
-# verbatiminclude would be nice to have too, however it requires a Report
-# object and a list of directories, which is too much for this converter
 our %formatting_misc_commands;
-foreach my $command ('sp', 'center', 'exdent', 
+foreach my $command ('verbatiminclude', 'sp', 'center', 'exdent', 
                      'item', 'itemx', 'tab', 'headitem',
     'node', keys(%Texinfo::Common::sectioning_commands)) {
   $formatting_misc_commands{$command} = 1;
@@ -1100,6 +1098,13 @@
           my $sp_nr = $root->{'extra'}->{'misc_args'}->[0];
           $result = "\n" x $sp_nr;
         }
+      } elsif ($root->{'cmdname'} eq 'verbatiminclude') {
+        my $verbatim_include_verbatim
+          = Texinfo::Common::expand_verbatiminclude($options->{'converter'},
+                                                    $root);
+        if (defined($verbatim_include_verbatim)) {
+          $result .= convert($verbatim_include_verbatim, $options);
+        }
       } elsif ($root->{'cmdname'} ne 'node') {
         $result = convert($root->{'args'}->[0], $options);
         if ($Texinfo::Common::sectioning_commands{$root->{'cmdname'}}) {



reply via email to

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