texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp Texinfo/Convert/Converter.pm Texinfo...


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Convert/Converter.pm Texinfo...
Date: Thu, 11 Aug 2011 21:38:17 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/08/11 21:38:17

Modified files:
        tp/Texinfo/Convert: Converter.pm HTML.pm Plaintext.pm Text.pm 
        tp/t/results/coverage_braces: nested_in_sc.pl 

Log message:
        More handling of upper case accented letters within the accent stack
        formatting function.
        Handle upper casing accented letters corresponding to @-commands with
        brace but no argument.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Converter.pm?cvsroot=texinfo&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.120&r2=1.121
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.145&r2=1.146
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Text.pm?cvsroot=texinfo&r1=1.49&r2=1.50
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/coverage_braces/nested_in_sc.pl?cvsroot=texinfo&r1=1.4&r2=1.5

Patches:
Index: Texinfo/Convert/Converter.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Converter.pm,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- Texinfo/Convert/Converter.pm        11 Aug 2011 21:07:16 -0000      1.24
+++ Texinfo/Convert/Converter.pm        11 Aug 2011 21:38:16 -0000      1.25
@@ -567,13 +567,18 @@
 );
 
 
-sub xml_accent($$;$)
+sub xml_accent($$;$$)
 {
   my $text = shift;
   my $command = shift;
+  my $in_upper_case = shift;
   my $use_numeric_entities = shift;
   my $accent = $command->{'cmdname'};
   
+  if ($in_upper_case and $text =~ /^\w$/) {
+    $text = uc ($text);
+  }
+ 
   return "&${text}$xml_accent_entities{$accent};" 
     if (defined($xml_accent_entities{$accent}) 
         and defined($xml_accent_text_with_entities{$accent}) 
@@ -588,11 +593,12 @@
   return Texinfo::Convert::Text::ascii_accent($text, $command);
 }
 
-sub xml_accent_numeric_entities($$)
+sub xml_accent_numeric_entities($$;$)
 {
   my $text = shift;
   my $command = shift;
-  return xml_accent($text, $command, 1);
+  my $in_upper_case = shift;
+  return xml_accent($text, $command, $in_upper_case, 1);
 }
 
 sub xml_accents($$;$)
@@ -609,11 +615,14 @@
   
   if ($self->get_conf('ENABLE_ENCODING')) {
     if ($self->{'encoding_name'} and $self->{'encoding_name'} eq 'utf-8') {
-      return Texinfo::Convert::Text::unicode_accents($accent, $format_accents);
+      return Texinfo::Convert::Text::unicode_accents($accent, $format_accents,
+                                                     $in_upper_case);
     } elsif ($self->{'encoding_name'} 
            and 
$Texinfo::Common::eight_bit_encoding_aliases{$self->{'encoding_name'}}) {
       return Texinfo::Convert::Text::eight_bit_accents($accent, 
-                                      $self->{'encoding_name'}, 
$format_accents);
+                                      $self->{'encoding_name'}, 
+                                      $format_accents,
+                                      $in_upper_case);
     }
   }
   my ($contents, $innermost_accent, $stack)
@@ -621,7 +630,8 @@
   my $result = $self->_convert({'contents' => $contents});
   
   foreach my $accent_command (reverse(@$stack)) {
-    $result = &$format_accents ($result, {'cmdname' => $accent_command});
+    $result = &$format_accents ($result, {'cmdname' => $accent_command}, 
+                                $in_upper_case);
   }
   return $result;
 }

Index: Texinfo/Convert/HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -b -r1.120 -r1.121
--- Texinfo/Convert/HTML.pm     8 Aug 2011 01:14:35 -0000       1.120
+++ Texinfo/Convert/HTML.pm     11 Aug 2011 21:38:16 -0000      1.121
@@ -82,6 +82,7 @@
 my %align_commands = %Texinfo::Common::align_commands;
 my %region_commands = %Texinfo::Common::region_commands;
 my %context_brace_commands = %Texinfo::Common::context_brace_commands;
+my %letter_no_arg_commands = %Texinfo::Common::letter_no_arg_commands;
 
 foreach my $def_command (keys(%def_commands)) {
   $formatting_misc_commands{$def_command} = 1 if 
($misc_commands{$def_command});
@@ -1108,6 +1109,10 @@
       $cmdname = $click_cmdname;
     }
   }
+  if ($self->in_upper_case and $letter_no_arg_commands{$cmdname}
+      and $self->{'commands_formatting'}->{'normal'}->{uc($cmdname)}) {
+    $cmdname = uc($cmdname);
+  }
 
   my $result;
   if ($self->in_preformatted() or $self->in_math()) {
@@ -1530,7 +1535,7 @@
   my $command = shift;
   my $args = shift;
 
-  return $self->xml_accents($command);
+  return $self->xml_accents($command, $self->in_upper_case());
 }
 
 foreach my $command (keys(%accent_commands)) {

Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.145
retrieving revision 1.146
diff -u -b -r1.145 -r1.146
--- Texinfo/Convert/Plaintext.pm        4 Aug 2011 23:22:28 -0000       1.145
+++ Texinfo/Convert/Plaintext.pm        11 Aug 2011 21:38:16 -0000      1.146
@@ -1240,8 +1240,8 @@
         $encoding = $self->{'encoding_name'};
       }
       my $accented_text 
-         = Texinfo::Convert::Text::text_accents($root, $encoding);
-      $accented_text = uc($accented_text) if ($formatter->{'upper_case'});
+         = Texinfo::Convert::Text::text_accents($root, $encoding,
+                                                $formatter->{'upper_case'});
       $result .= $self->_count_added($formatter->{'container'},
          $formatter->{'container'}->add_text($accented_text));
       # in case the text added ends with punctuation.  

Index: Texinfo/Convert/Text.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Text.pm,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -b -r1.49 -r1.50
--- Texinfo/Convert/Text.pm     11 Aug 2011 21:07:16 -0000      1.49
+++ Texinfo/Convert/Text.pm     11 Aug 2011 21:38:16 -0000      1.50
@@ -751,7 +751,9 @@
     if ($eight_bit_command_index > -1);
   for (my $remaining_accents = $eight_bit_command_index+1; 
           $remaining_accents <= $#results_stack; $remaining_accents++) {
-    $result = &$convert_accent($result, 
$results_stack[$remaining_accents]->[1]);
+    $result = &$convert_accent($result, 
+                               $results_stack[$remaining_accents]->[1],
+                               $in_upper_case);
     print STDERR "REMAINING($remaining_accents) "
        .Encode::encode('utf8', $result)."\n" if ($debug);
   }
@@ -780,11 +782,14 @@
 }
 
 # format a stack of accents as ascii
-sub ascii_accents ($)
+sub ascii_accents ($;$)
 {
   my $current = shift;
+  my $in_upper_case = shift;
+
   my ($result, $innermost_accent, $stack) = _find_innermost_accent($current);
 
+  $result = uc($result) if ($in_upper_case);
   foreach my $accent_command (reverse(@$stack)) {
     $result = ascii_accent ($result, {'cmdname' => $accent_command});
   }
@@ -821,19 +826,20 @@
   return $result;
 }
 
-sub text_accents($$)
+sub text_accents($$;$)
 {
   my $accent = shift;
   my $encoding = shift;
+  my $in_upper_case = shift;
   
   return '' if (!$accent->{'args'});
   if ($encoding and $encoding eq 'utf-8') {
-    return unicode_accents($accent, \&ascii_accent);
+    return unicode_accents($accent, \&ascii_accent, $in_upper_case);
   } elsif ($encoding 
            and $Texinfo::Common::eight_bit_encoding_aliases{$encoding}) {
-    return eight_bit_accents($accent, $encoding, \&ascii_accent);
+    return eight_bit_accents($accent, $encoding, \&ascii_accent, 
$in_upper_case);
   } else {
-    return ascii_accents($accent);
+    my $result = ascii_accents($accent, $in_upper_case);
   }
 }
 
@@ -1027,12 +1033,9 @@
       return brace_no_arg_command($root, $options);
     # commands with braces
     } elsif ($accent_commands{$root->{'cmdname'}}) {
-      my $result = text_accents ($root, $options->{'enabled_encoding'});
-      if ($options->{'sc'}) {
-        return uc ($result);
-      } else {
+      my $result = text_accents ($root, $options->{'enabled_encoding'}, 
+                                        $options->{'sc'});
         return $result;
-      }
     } elsif ($root->{'cmdname'} eq 'image') {
       return convert($root->{'args'}->[0], $options);
     } elsif ($root->{'cmdname'} eq 'email') {

Index: t/results/coverage_braces/nested_in_sc.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/coverage_braces/nested_in_sc.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- t/results/coverage_braces/nested_in_sc.pl   8 Aug 2011 01:34:36 -0000       
1.4
+++ t/results/coverage_braces/nested_in_sc.pl   11 Aug 2011 21:38:17 -0000      
1.5
@@ -285,7 +285,7 @@
 
 <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" 
vlink="#800080" alink="#FF0000">
 
-<p><small><small>AAA &Ntilde; &aring; <a name="DOCF1" href="#FOOT1">(1)</a>, 
<abbr title="EXPL">ABR</abbr> (EXPL), 
+<p><small><small>AAA &Ntilde; &Aring; <a name="DOCF1" href="#FOOT1">(1)</a>, 
<abbr title="EXPL">ABR</abbr> (EXPL), 
 <tt>in verb</tt></small></small>
 </p><div class="footnote">
 <hr>



reply via email to

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