texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp Texinfo/Convert/Plaintext.pm Texinfo...


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Convert/Plaintext.pm Texinfo...
Date: Wed, 01 Dec 2010 23:39:50 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        10/12/01 23:39:50

Modified files:
        tp/Texinfo/Convert: Plaintext.pm Text.pm 
        tp/t           : accents.t 

Log message:
        Handle enable encoding for @-commands with brace and no argument like
        @aa{}.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Text.pm?cvsroot=texinfo&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/accents.t?cvsroot=texinfo&r1=1.5&r2=1.6

Patches:
Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- Texinfo/Convert/Plaintext.pm        1 Dec 2010 22:39:44 -0000       1.19
+++ Texinfo/Convert/Plaintext.pm        1 Dec 2010 23:39:50 -0000       1.20
@@ -583,14 +583,12 @@
       }
       return $result;
     } elsif (defined($text_brace_no_arg_commands{$root->{'cmdname'}})) {
-      $command = $root->{'extra'}->{'clickstyle'}
-         if ($root->{'extra'}
-          and defined($root->{'extra'}->{'clickstyle'})
-          and 
defined($text_brace_no_arg_commands{$root->{'extra'}->{'clickstyle'}}));
+      my $text = Texinfo::Convert::Text::brace_no_arg_command($root, 
+                                                    $self->{'encoding'});
       if ($command eq 'enddots') {
-        $result .= 
$formatter->{'container'}->add_next($text_brace_no_arg_commands{$command}, 
undef, 1),
+        $result .= $formatter->{'container'}->add_next($text, undef, 1),
       } else {
-        $result .= 
$formatter->{'container'}->add_text($text_brace_no_arg_commands{$command});
+        $result .= $formatter->{'container'}->add_text($text);
         if ($command eq 'dots') {
           $formatter->{'container'}->inhibit_end_sentence();
         }

Index: Texinfo/Convert/Text.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Text.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- Texinfo/Convert/Text.pm     1 Dec 2010 22:39:44 -0000       1.23
+++ Texinfo/Convert/Text.pm     1 Dec 2010 23:39:50 -0000       1.24
@@ -797,6 +797,30 @@
   }
 }
 
+sub brace_no_arg_command($;$$)
+{
+  my $root = shift;
+  my $encoding = shift;
+  my $sort_string = shift;
+
+  my $command = $root->{'cmdname'};
+  $command = $root->{'extra'}->{'clickstyle'}
+     if ($root->{'extra'}
+      and defined($root->{'extra'}->{'clickstyle'})
+      and 
defined($text_brace_no_arg_commands{$root->{'extra'}->{'clickstyle'}}));
+  if ($encoding 
+    and (($encoding eq 'utf-8' 
+       and 
$Texinfo::Convert::Unicode::unicode_character_brace_no_arg_commands{$command})
+        or ($Texinfo::Common::eight_bit_encoding_aliases{$encoding}
+        and 
$unicode_to_eight_bit{$Texinfo::Common::eight_bit_encoding_aliases{$encoding}}->{$Texinfo::Convert::Unicode::unicode_map{$command}})))
 {
+    return 
$Texinfo::Convert::Unicode::unicode_character_brace_no_arg_commands{$command};
+  } elsif ($sort_string and $sort_brace_no_arg_commands{$command}) {
+    return $sort_brace_no_arg_commands{$command};
+  } else {
+    return $text_brace_no_arg_commands{$command};
+  }
+}
+
 # decompose a decimal number on a given base. The algorithm looks like
 # the division with growing powers (division suivant les puissances
 # croissantes) ?
@@ -908,15 +932,8 @@
     if (defined($text_no_brace_commands{$root->{'cmdname'}})) {
       return $text_no_brace_commands{$root->{'cmdname'}};
     } elsif (defined($text_brace_no_arg_commands{$root->{'cmdname'}})) {
-      $command = $root->{'extra'}->{'clickstyle'}
-         if ($root->{'extra'}
-          and defined($root->{'extra'}->{'clickstyle'})
-          and 
defined($text_brace_no_arg_commands{$root->{'extra'}->{'clickstyle'}}));
-      if ($options->{'sort_string'} and $sort_brace_no_arg_commands{$command}) 
{
-        return $sort_brace_no_arg_commands{$command};
-      } else {
-        return $text_brace_no_arg_commands{$command};
-     }
+      return brace_no_arg_command($root, $options->{'enable_encoding'}, 
+                                  $options->{'sort_string'});
     # commands with braces
     } elsif ($accent_commands{$root->{'cmdname'}}) {
       return text_accents ($root, $options->{'enable_encoding'});

Index: t/accents.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/accents.t,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- t/accents.t 1 Dec 2010 22:39:44 -0000       1.5
+++ t/accents.t 1 Dec 2010 23:39:50 -0000       1.6
@@ -1,7 +1,7 @@
 use strict;
 
 use Test::More;
-BEGIN { plan tests => 19 };
+BEGIN { plan tests => 21 };
 
 use lib '../texi2html/lib/Unicode-EastAsianWidth/lib/';
 use Texinfo::Convert::Text;
@@ -84,12 +84,16 @@
 #my $aa = Texinfo::Parser::parse_texi_line(undef, '@aa{}');
 my $res_e = Texinfo::Parser::parse_texi_line(undef, '@^e');
 my $result = Texinfo::Convert::Text::convert($res_e, {'enable_encoding' => 
'utf-8'});
-is ("\x{00EA}", $result, 'enable encoding @^e');
+is ($result, "\x{00EA}", 'enable encoding @^e');
 
 my $res_aa = Texinfo::Parser::parse_texi_line(undef, '@aa{}');
 $result = Texinfo::Convert::Text::convert($res_aa, {'enable_encoding' => 
'utf-8'});
+is ($result, "\x{00E5}", 'enable encoding @aa{}');
+
+$result = Texinfo::Convert::Text::convert($res_aa, {'enable_encoding' => 
'iso-8859-1'});
+is ($result, "\x{00E5}", 'enable encoding latin1 @aa{}');
 #print STDERR "$result\n";
 #print STDERR "`$result'\n".ord($result)."\n".sprintf("%x\n",ord($result));
-#print STDERR "".Encode::encode('utf8', "\x{00EA}\n");
+#print STDERR "".Encode::encode('utf8', "\x{00E5}\n");
 
 1;



reply via email to

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