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/Parse...


From: Patrice Dumas
Subject: texinfo/tp TODO Texinfo/Common.pm Texinfo/Parse...
Date: Thu, 29 Sep 2011 23:24:44 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/09/29 23:24:44

Modified files:
        tp             : TODO 
        tp/Texinfo     : Common.pm Parser.pm Structuring.pm 
        tp/Texinfo/Convert: DocBook.pm HTML.pm Info.pm Plaintext.pm 
                            Text.pm 

Log message:
        Pass the encoding information to Text::convert.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/TODO?cvsroot=texinfo&r1=1.180&r2=1.181
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Common.pm?cvsroot=texinfo&r1=1.69&r2=1.70
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.309&r2=1.310
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Structuring.pm?cvsroot=texinfo&r1=1.90&r2=1.91
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/DocBook.pm?cvsroot=texinfo&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.158&r2=1.159
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Info.pm?cvsroot=texinfo&r1=1.64&r2=1.65
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.165&r2=1.166
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Text.pm?cvsroot=texinfo&r1=1.70&r2=1.71

Patches:
Index: TODO
===================================================================
RCS file: /sources/texinfo/texinfo/tp/TODO,v
retrieving revision 1.180
retrieving revision 1.181
diff -u -b -r1.180 -r1.181
--- TODO        29 Sep 2011 11:51:50 -0000      1.180
+++ TODO        29 Sep 2011 23:24:41 -0000      1.181
@@ -169,7 +169,9 @@
 
 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.
+there are in a Text expansion context.  The text is done, but the passed
+information is the enabled_encoding so cannot be in tests as long as
+there is an issue of encoding.
 
 In @copying things like some raw formats may be expanded.  However it is
 not clear that it should be the same than in the main converter.  Maybe a 

Index: Texinfo/Common.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Common.pm,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -b -r1.69 -r1.70
--- Texinfo/Common.pm   29 Sep 2011 20:01:38 -0000      1.69
+++ Texinfo/Common.pm   29 Sep 2011 23:24:42 -0000      1.70
@@ -1204,6 +1204,17 @@
   return $node;
 }
 
+sub _convert_text_options($)
+{
+  my $self = shift;
+  my %options;
+  if ($self->get_conf('ENABLE_ENCODING')
+       and $self->{'encoding_name'}) {
+    $options{'enabled_encoding'} = $self->{'encoding_name'};
+  }
+  return %options;
+}
+
 1;
 
 __END__

Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.309
retrieving revision 1.310
diff -u -b -r1.309 -r1.310
--- Texinfo/Parser.pm   29 Sep 2011 13:57:21 -0000      1.309
+++ Texinfo/Parser.pm   29 Sep 2011 23:24:42 -0000      1.310
@@ -2647,7 +2647,8 @@
       $current->{'extra'}->{'misc_args'} = $args if (defined($args));
     } elsif ($self->{'misc_commands'}->{$command} eq 'text') {
       my $text = Texinfo::Convert::Text::convert($current->{'args'}->[0],
-                                                 {'code' => 1});
+                                                 {'code' => 1, 
+                                          
Texinfo::Common::_convert_text_options($self)});
       if ($text eq '') {
         $self->line_warn (sprintf($self->__("address@hidden missing 
argument"), 
            $command), $line_nr);

Index: Texinfo/Structuring.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Structuring.pm,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -b -r1.90 -r1.91
--- Texinfo/Structuring.pm      29 Sep 2011 11:30:23 -0000      1.90
+++ Texinfo/Structuring.pm      29 Sep 2011 23:24:42 -0000      1.91
@@ -1135,7 +1135,7 @@
       $options->{'code'} = $entry->{'in_code'};
       $entry->{'key'} = Texinfo::Convert::Text::convert(
                               {'contents' => $entry->{'content'}},
-                              $options);
+                  {%$options, Texinfo::Common::_convert_text_options($self)});
     }
   }
 }
@@ -1203,23 +1203,20 @@
 
 sub output_internal_links($$$)
 {
-  my $converter = shift;
+  my $self = shift;
   my $fh = shift;
-  if ($converter->{'elements'}) {
-    my $options = {'converter' => $converter};
-    if ($converter->get_conf('ENABLE_ENCODING') and 
$converter->{'encoding_name'}) {
-      $options->{'enabled_encoding'} = $converter->{'encoding_name'};
-    }
-    foreach my $element (@{$converter->{'elements'}}) {
+  if ($self->{'elements'}) {
+    foreach my $element (@{$self->{'elements'}}) {
       my $text;
       my $href;
-      my $command = $converter->element_command($element);
+      my $command = $self->element_command($element);
       if (defined($command)) {
         # Use '' for filename, to force a filename in href.
-        $href = $converter->command_href($command, '');
-        my $tree = $converter->command_text($command, 'tree');
+        $href = $self->command_href($command, '');
+        my $tree = $self->command_text($command, 'tree');
         if ($tree) {
-          $text = Texinfo::Convert::Text::convert($tree, $options);
+          $text = Texinfo::Convert::Text::convert($tree, 
+                             {Texinfo::Common::_convert_text_options($self)});
         }
       }
       if (defined($href) or defined($text)) {
@@ -1232,13 +1229,13 @@
       }
     }
   }
-  if ($converter->{'parser'}) {
-    foreach my $index_name (sort(keys 
(%{$converter->{'index_entries_by_letter'}}))) {
-      foreach my $letter_entry 
(@{$converter->{'index_entries_by_letter'}->{$index_name}}) {
+  if ($self->{'parser'}) {
+    foreach my $index_name (sort(keys 
(%{$self->{'index_entries_by_letter'}}))) {
+      foreach my $letter_entry 
(@{$self->{'index_entries_by_letter'}->{$index_name}}) {
         foreach my $index_entry (@{$letter_entry->{'entries'}}) {
           my $href;
           my $key;
-          $href = $converter->command_href($index_entry->{'command'}, '');
+          $href = $self->command_href($index_entry->{'command'}, '');
           $key = $index_entry->{'key'};
           if (defined($key) and $key =~ /\S/) {
             my $out_string = '';

Index: Texinfo/Convert/DocBook.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/DocBook.pm,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- Texinfo/Convert/DocBook.pm  29 Sep 2011 20:01:38 -0000      1.17
+++ Texinfo/Convert/DocBook.pm  29 Sep 2011 23:24:43 -0000      1.18
@@ -742,7 +742,8 @@
               $filename 
                 = $self->xml_protect_text(Texinfo::Convert::Text::convert(
               {'contents' => 
$root->{'extra'}->{'brace_command_contents'}->[-1]},
-                                           {'converter' => $self, 'code' => 
1}));
+                                           {'converter' => $self, 'code' => 1,
+                                    
Texinfo::Common::_convert_text_options($self)}));
             }
             my $node;
             if (defined($root->{'extra'}->{'brace_command_contents'}->[0])) {
@@ -847,7 +848,7 @@
         if (defined($root->{'extra'}->{'brace_command_contents'}->[0])) {
           my $basefile = Texinfo::Convert::Text::convert(
            {'contents' => $root->{'extra'}->{'brace_command_contents'}->[0]},
-           {'code' => 1});
+           {'code' => 1, $self->_convert_text_options()});
           my $element;
           my $is_inline = $self->_is_inline($root);
           if ($is_inline) {
@@ -896,7 +897,8 @@
             $email_text 
               = $self->xml_protect_text(Texinfo::Convert::Text::convert(
                                          {'contents' => $email},
-                                         {'converter' => $self, 'code' => 1}));
+                                         {'converter' => $self, 'code' => 1,
+                                  
Texinfo::Common::_convert_text_options($self)}));
           }
           if ($name and $email) {
             return "<ulink url=\"mailto:$email_text\";>"
@@ -917,7 +919,8 @@
             $url_content = $root->{'extra'}->{'brace_command_contents'}->[0];
             $url_text = 
$self->xml_protect_text(Texinfo::Convert::Text::convert(
                                          {'contents' => $url_content},
-                                         {'converter' => $self, 'code' => 1}));
+                                         {'converter' => $self, 'code' => 1,
+                                  
Texinfo::Common::_convert_text_options($self)}));
           } else {
             $url_text = '';
           }
@@ -1033,7 +1036,8 @@
             foreach my $prototype (@{$root->{'extra'}->{'prototypes'}}) {
               my $prototype_text
                 = Texinfo::Convert::Text::convert($prototype,
-                                                  {'converter' => $self});
+                                                  {'converter' => $self,
+                                           
Texinfo::Common::_convert_text_options($self)});
               push @fractions, 
                 Texinfo::Convert::Unicode::string_width($prototype_text);
             }
@@ -1068,7 +1072,8 @@
           if ($root->{'extra'}->{'block_command_line_contents'}
               and 
defined($root->{'extra'}->{'block_command_line_contents'}->[0])) {
             my $quotation_arg_text = Texinfo::Convert::Text::convert(
-                     {'contents' => 
$root->{'extra'}->{'block_command_line_contents'}->[0]});
+                     {'contents' => 
$root->{'extra'}->{'block_command_line_contents'}->[0]},
+                     {Texinfo::Common::_convert_text_options($self)});
             if ($docbook_special_quotations{lc($quotation_arg_text)}) {
               $element = lc($quotation_arg_text);
             } else {

Index: Texinfo/Convert/HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.158
retrieving revision 1.159
diff -u -b -r1.158 -r1.159
--- Texinfo/Convert/HTML.pm     29 Sep 2011 20:01:38 -0000      1.158
+++ Texinfo/Convert/HTML.pm     29 Sep 2011 23:24:43 -0000      1.159
@@ -5143,7 +5143,8 @@
   if ($external_node->{'manual_content'}) {
     my $manual_name = Texinfo::Convert::Text::convert(
        {'contents' => $external_node->{'manual_content'}}, 
-       {'converter' => $self, 'code' => 1});
+       {'converter' => $self, 'code' => 1, 
+        Texinfo::Common::_convert_text_options($self)});
     my $manual_base = $manual_name;
     $manual_base =~ s/\.[^\.]*$//;
     $manual_base =~ s/^.*\///;
@@ -5974,14 +5975,10 @@
 
   # copying comment
   if ($self->{'extra'}->{'copying'}) {
-    my $options = {'converter' => $self};
-    if ($self->get_conf('ENABLE_ENCODING') 
-        and $self->{'encoding_name'}) {
-      $options->{'enabled_encoding'} = $self->{'encoding_name'};
-    }
     print STDERR "DO copying_comment\n" if ($self->get_conf('DEBUG'));
     my $copying_comment = Texinfo::Convert::Text::convert(
-     {'contents' => $self->{'extra'}->{'copying'}->{'contents'}}, $options);
+     {'contents' => $self->{'extra'}->{'copying'}->{'contents'}}, 
+     {Texinfo::Common::_convert_text_options($self)});
     if ($copying_comment ne '') {
       $self->{'copying_comment'} = &{$self->{'comment'}}($self, 
$copying_comment);
     }
@@ -6466,7 +6463,8 @@
                 $arg_formatted->{$arg_type} 
                   = Texinfo::Convert::Text::convert($arg, 
                                                   {'converter' => $self,
-                                                   'code' => 1});
+                                                   'code' => 1,
+                                           
Texinfo::Common::_convert_text_options($self)});
               }
             }
             

Index: Texinfo/Convert/Info.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Info.pm,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -b -r1.64 -r1.65
--- Texinfo/Convert/Info.pm     29 Sep 2011 14:04:40 -0000      1.64
+++ Texinfo/Convert/Info.pm     29 Sep 2011 23:24:43 -0000      1.65
@@ -531,11 +531,11 @@
   if (defined($root->{'extra'}->{'brace_command_contents'}->[0])) {
     my $basefile = Texinfo::Convert::Text::convert(
       {'contents' => $root->{'extra'}->{'brace_command_contents'}->[0]},
-      {'code' => 1});
+      {'code' => 1, Texinfo::Common::_convert_text_options($self)});
     if (defined($root->{'extra'}->{'brace_command_contents'}->[4])) {
       my $extension = Texinfo::Convert::Text::convert(
         {'contents' => $root->{'extra'}->{'brace_command_contents'}->[4]},
-        {'code' => 1});
+        {'code' => 1, Texinfo::Common::_convert_text_options($self)});
       unshift @extensions, ".$extension";
       unshift @extensions, "$extension";
     }
@@ -566,7 +566,8 @@
 
       if (defined($root->{'extra'}->{'brace_command_contents'}->[3])) {
         my $alt = Texinfo::Convert::Text::convert(
-         {'contents' => $root->{'extra'}->{'brace_command_contents'}->[3]});
+         {'contents' => $root->{'extra'}->{'brace_command_contents'}->[3]},
+         {Texinfo::Common::_convert_text_options($self)});
         $alt =~ s/\\/\\\\/g;
         $alt =~ s/\"/\\\"/g;
         $result .= " alt=\"$alt\"";

Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.165
retrieving revision 1.166
diff -u -b -r1.165 -r1.166
--- Texinfo/Convert/Plaintext.pm        29 Sep 2011 13:57:21 -0000      1.165
+++ Texinfo/Convert/Plaintext.pm        29 Sep 2011 23:24:43 -0000      1.166
@@ -1018,7 +1018,7 @@
   if (defined($root->{'extra'}->{'brace_command_contents'}->[0])) {
     my $basefile = Texinfo::Convert::Text::convert(
      {'contents' => $root->{'extra'}->{'brace_command_contents'}->[0]},
-     {'code' => 1});
+     {'code' => 1, Texinfo::Common::_convert_text_options($self)});
     my $result = $self->_image_text($root, $basefile);
     if (defined($result)) {
       if (!$self->{'formatters'}->[-1]->{'_top_formatter'}) {

Index: Texinfo/Convert/Text.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Text.pm,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -b -r1.70 -r1.71
--- Texinfo/Convert/Text.pm     29 Sep 2011 22:06:59 -0000      1.70
+++ Texinfo/Convert/Text.pm     29 Sep 2011 23:24:43 -0000      1.71
@@ -521,3 +521,50 @@
 }
 
 1;
+
+__END__
+
+=head1 NAME
+
+Texinfo::Convert::Text - Convert Texinfo tree to simple text
+
+=head1 SYNOPSIS
+
+  use Texinfo::Convert::Text qw(convert);
+
+  my $result = convert($tree);
+  my $result_encoded = convert($tree, 
+             {'enabled_encoding' => 'utf-8'});
+  my $result_converter = convert($tree,
+             {'converter' => $converter});
+
+  my $result_accent_text = ascii_accent('e', $accent_command);
+  my text_accents = text_accents($accents, 'utf-8');
+
+=head1 DESCRIPTION
+
+Texinfo::Convert::Text is a simple backend that Encoding takes care of 
encoding definition and aliasing.
+
+=head1 METHODS
+
+=over
+
+=item 
+
+=back
+
+=head1 AUTHOR
+
+Patrice Dumas, E<lt>address@hidden<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+
+This library is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License,
+or (at your option) any later version.
+
+=cut
+



reply via email to

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