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: Tue, 15 Jan 2013 01:25:53 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        13/01/15 01:25:53

Modified files:
        tp/Texinfo/Convert: Converter.pm DocBook.pm Text.pm Unicode.pm 
                            XML.pm 
        tp/t           : accents.t 
        tp/t/results/coverage: item_container.pl 
        tp/t/results/xml_tests: comments_on_block_command_lines.pl 
        tp/tests/layout/res_parser/formatting_xml: formatting.xml 

Log message:
        Texinfo/Convert/XML.pm: remove a spurious space in formattingcommand 
element.
        
        Change the calling convention aof most accent related commands, to allow
        for a converter object to be passed to the fallback accent formatting
        function reference argument.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Converter.pm?cvsroot=texinfo&r1=1.96&r2=1.97
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/DocBook.pm?cvsroot=texinfo&r1=1.58&r2=1.59
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Text.pm?cvsroot=texinfo&r1=1.101&r2=1.102
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Unicode.pm?cvsroot=texinfo&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/XML.pm?cvsroot=texinfo&r1=1.92&r2=1.93
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/accents.t?cvsroot=texinfo&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/coverage/item_container.pl?cvsroot=texinfo&r1=1.53&r2=1.54
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/xml_tests/comments_on_block_command_lines.pl?cvsroot=texinfo&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/tests/layout/res_parser/formatting_xml/formatting.xml?cvsroot=texinfo&r1=1.17&r2=1.18

Patches:
Index: Texinfo/Convert/Converter.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Converter.pm,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -b -r1.96 -r1.97
--- Texinfo/Convert/Converter.pm        22 Dec 2012 12:18:09 -0000      1.96
+++ Texinfo/Convert/Converter.pm        15 Jan 2013 01:25:51 -0000      1.97
@@ -973,14 +973,14 @@
 
   my $encoded;
   if ($self->get_conf('ENABLE_ENCODING')) {
-    $encoded = Texinfo::Convert::Unicode::encoded_accents($result, $stack,
+    $encoded = Texinfo::Convert::Unicode::encoded_accents($self, $result, 
$stack,
                                        $self->get_conf('OUTPUT_ENCODING_NAME'),
                                        $format_accents,
                                        $in_upper_case);
   }
   if (!defined($encoded)) {
     foreach my $accent_command (reverse(@$stack)) {
-      $result = &$format_accents ($result, $accent_command, 
+      $result = &$format_accents ($self, $result, $accent_command, 
                                   $in_upper_case);
     }
     return $result;
@@ -1173,8 +1173,9 @@
 );
 
 
-sub xml_accent($$;$$)
+sub xml_accent($$$;$$)
 {
+  my $self = shift;
   my $text = shift;
   my $command = shift;
   my $in_upper_case = shift;
@@ -1204,10 +1205,11 @@
 
 sub _xml_accent_numeric_entities($$;$)
 {
+  my $self = shift;
   my $text = shift;
   my $command = shift;
   my $in_upper_case = shift;
-  return xml_accent($text, $command, $in_upper_case, 1);
+  return $self->xml_accent($text, $command, $in_upper_case, 1);
 }
 
 sub xml_accents($$;$)

Index: Texinfo/Convert/DocBook.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/DocBook.pm,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -b -r1.58 -r1.59
--- Texinfo/Convert/DocBook.pm  22 Dec 2012 12:18:09 -0000      1.58
+++ Texinfo/Convert/DocBook.pm  15 Jan 2013 01:25:51 -0000      1.59
@@ -398,8 +398,9 @@
   return '';
 }
 
-sub docbook_accent($$;$)
+sub docbook_accent($$$;$)
 {
+  my $self = shift;
   my $text = shift;
   my $command = shift;
   my $in_upper_case = shift;

Index: Texinfo/Convert/Text.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Text.pm,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -b -r1.101 -r1.102
--- Texinfo/Convert/Text.pm     21 Dec 2012 00:30:45 -0000      1.101
+++ Texinfo/Convert/Text.pm     15 Jan 2013 01:25:51 -0000      1.102
@@ -183,7 +183,7 @@
 }
 
 # format a stack of accents as ascii
-sub ascii_accents ($$;$)
+sub ascii_accents($$;$)
 {
   my $result = shift;
   my $stack = shift;
@@ -197,11 +197,23 @@
     }
   }
   foreach my $accent_command (reverse(@$stack)) {
-    $result = ascii_accent ($result, $accent_command);
+    $result = ascii_accent($result, $accent_command);
   }
   return $result;
 }
 
+# Same as ascii_accent, but with a converter as first argument to be consistent
+# with calling conventions of fallback accent formatting functions given
+# to convert_accents/encoded_accents
+sub ascii_accent_fallback($$$)
+{
+  my $converter = shift;
+  my $text = shift;
+  my $command = shift;
+
+  return ascii_accent($text, $command);
+}
+
 # format an accent command and nested accents within as Text.
 sub text_accents($;$$)
 {
@@ -217,8 +229,8 @@
   $options->{'sc'} = $set_case if (defined($set_case));
   my $text = convert({'contents' => $contents}, $options);
 
-  my $result = Texinfo::Convert::Unicode::encoded_accents($text, $stack,
-                                  $encoding, \&ascii_accent, $set_case);
+  my $result = Texinfo::Convert::Unicode::encoded_accents(undef, $text, 
+                     $stack, $encoding, \&ascii_accent_fallback, $set_case);
   if (defined($result)) {
     return $result;
   } else {
@@ -795,6 +807,13 @@
 an argument.  The function returns a transliteration of the accented
 character.
 
+=item $result_accent_text = ascii_accent_fallback($converter, $text, 
$accent_command)
+
+Same as C<ascii_accent> but  with an additional first argument
+converter, which is in ignored, but needed if this function is to 
+be in argument of functions that need a fallback for accents
+conversion.
+
 =item $accents_text = text_accents($accents, $encoding, $set_case)
 
 I<$accents> is an accent command that may contain other nested accent 

Index: Texinfo/Convert/Unicode.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Unicode.pm,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- Texinfo/Convert/Unicode.pm  2 Dec 2012 18:09:33 -0000       1.34
+++ Texinfo/Convert/Unicode.pm  15 Jan 2013 01:25:51 -0000      1.35
@@ -1265,8 +1265,9 @@
 }
 
 # format a stack of accents as unicode
-sub unicode_accents ($$$;$)
+sub unicode_accents($$$$;$)
 {
+  my $converter = shift;
   my $result = shift;
   my $stack = shift;
   my $format_accent = shift;
@@ -1288,13 +1289,14 @@
   }
   while (@$stack) {
     my $accent_command = pop @$stack;
-    $result = &$format_accent($result, $accent_command, $set_case);
+    $result = &$format_accent($converter, $result, $accent_command, $set_case);
   }
   return $result;
 }
 
-sub eight_bit_accents($$$$;$)
+sub eight_bit_accents($$$$$;$)
 {
+  my $converter = shift;
   my $unicode_formatted = shift;
   my $stack = shift;
   my $encoding = shift;
@@ -1402,7 +1404,7 @@
   # compatible unicode
   shift @results_stack if (!defined($results_stack[0]->[1]));
   while (@results_stack) {
-    $result = &$convert_accent($result,
+    $result = &$convert_accent($converter, $result,
                                $results_stack[0]->[1],
                                $set_case);
     shift @results_stack;
@@ -1413,8 +1415,9 @@
   return $result;
 }
 
-sub encoded_accents ($$$$;$)
+sub encoded_accents($$$$$;$)
 {
+  my $converter = shift;
   my $text = shift;
   my $stack = shift;
   my $encoding = shift;
@@ -1423,10 +1426,11 @@
 
   if ($encoding) {
     if ($encoding eq 'utf-8') {
-      return unicode_accents($text, $stack, $format_accent, $set_case);
-    } elsif ($Texinfo::Encoding::eight_bit_encoding_aliases{$encoding}) {
-      return eight_bit_accents($text, $stack, $encoding, $format_accent, 
+      return unicode_accents($converter, $text, $stack, $format_accent, 
                                $set_case);
+    } elsif ($Texinfo::Encoding::eight_bit_encoding_aliases{$encoding}) {
+      return eight_bit_accents($converter, $text, $stack, $encoding, 
+                               $format_accent, $set_case);
     }
   }
   return undef;
@@ -1492,8 +1496,9 @@
   my ($innermost_contents, $stack)
       = Texinfo::Common::find_innermost_accent_contents($accent);
   
-  my $formatted_accents = encoded_accents (convert($innermost_contents),
-                        $stack, $encoding, \&Texinfo::Text::ascii_accent);
+  my $formatted_accents = encoded_accents ($converter, 
+                        convert($innermost_contents), $stack, $encoding, 
+                        \&Texinfo::Text::ascii_accent_fallback);
 
   my $accent_text = unicode_accent('e', $accent_command);
 
@@ -1520,8 +1525,10 @@
 an argument.  The function returns the unicode representation of the accented
 character.
 
-=item $result = encoded_accents ($text, $stack, $encoding, $format_accent, 
$set_case)
+=item $result = encoded_accents ($converter, $text, $stack, $encoding, 
$format_accent, $set_case)
 
+I<$converter> is a converter object.  It may be undef if there is no need of
+converter object in I<$format_accent> (I<$format_accent> described below).
 I<$text> is the text appearing within nested accent commands.  I<$stack> is
 an array reference holding the nested accents texinfo element trees.  For
 example, I<$text> could be the formatted content and I<$stack> the stack 

Index: Texinfo/Convert/XML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/XML.pm,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -b -r1.92 -r1.93
--- Texinfo/Convert/XML.pm      21 Dec 2012 00:30:45 -0000      1.92
+++ Texinfo/Convert/XML.pm      15 Jan 2013 01:25:51 -0000      1.93
@@ -25,7 +25,7 @@
 use Texinfo::Convert::Converter;
 use Texinfo::Common;
 use Texinfo::Convert::Unicode;
-# for debugging
+# for debugging and adding the original line for some commands
 use Texinfo::Convert::Texinfo;
 use Data::Dumper;
 use Carp qw(cluck);
@@ -365,8 +365,9 @@
   return $attribute;
 }
 
-sub _texinfo_xml_accent($$;$$)
+sub _texinfo_xml_accent($$$;$$)
 {
+  my $self = shift;
   my $text = shift;
   my $root = shift;
   my $in_upper_case = shift;
@@ -600,7 +601,7 @@
       if ($self->{'itemize_line'} and $root->{'type'} 
           and $root->{'type'} eq 'command_as_argument'
           and !$root->{'args'}) {
-        return "<formattingcommand command=\"$root->{'cmdname'}\" />";
+        return "<formattingcommand command=\"$root->{'cmdname'}\"/>";
       }
       return $xml_commands_formatting{$root->{'cmdname'}};
     } elsif ($xml_accent_types{$root->{'cmdname'}}) {
@@ -619,7 +620,7 @@
              $attributes .= ' bracketed="off"';
           }
         }
-        return _texinfo_xml_accent($result, $root,  undef, $attributes);
+        return $self->_texinfo_xml_accent($result, $root,  undef, $attributes);
       }
     } elsif ($root->{'cmdname'} eq 'item' or $root->{'cmdname'} eq 'itemx'
              or $root->{'cmdname'} eq 'headitem' or $root->{'cmdname'} eq 
'tab') {

Index: t/accents.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/accents.t,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- t/accents.t 12 Oct 2011 23:52:21 -0000      1.17
+++ t/accents.t 15 Jan 2013 01:25:51 -0000      1.18
@@ -77,8 +77,8 @@
   my $text = Texinfo::Convert::Text::convert({'contents' => $contents});
 
   my $result = 
-       Texinfo::Convert::Unicode::eight_bit_accents($text, $commands_stack, 
-    'iso-8859-1', \&Texinfo::Convert::Text::ascii_accent);
+       Texinfo::Convert::Unicode::eight_bit_accents(undef, $text, 
$commands_stack, 
+    'iso-8859-1', \&Texinfo::Convert::Text::ascii_accent_fallback);
 
   my $html_converter = Texinfo::Convert::HTML->converter();
   $html_converter->{'conf'}->{'USE_NUMERIC_ENTITY'} = 0;
@@ -92,8 +92,8 @@
     Texinfo::Common::find_innermost_accent_contents($tree);
   $text = Texinfo::Convert::Text::convert({'contents' => $contents},
                                {'enabled_encoding' => 'utf-8'});
-  my $result_unicode = Texinfo::Convert::Unicode::unicode_accents($text, 
-              $commands_stack, \&Texinfo::Convert::Text::ascii_accent);
+  my $result_unicode = Texinfo::Convert::Unicode::unicode_accents(undef, 
$text, 
+              $commands_stack, 
\&Texinfo::Convert::Text::ascii_accent_fallback);
 
   if (defined($reference)) {
     #ok (Encode::decode('iso-8859-1', $reference) eq $result, $name);

Index: t/results/coverage/item_container.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/coverage/item_container.pl,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- t/results/coverage/item_container.pl        3 Sep 2012 21:58:44 -0000       
1.53
+++ t/results/coverage/item_container.pl        15 Jan 2013 01:25:52 -0000      
1.54
@@ -516,7 +516,7 @@
 <listitem spaces=" "><prepend>+</prepend><para>i&textndash;tem +
 </para></listitem></itemize>
 
-<itemize commandarg="bullet" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="bullet" /></itemprepend>
+<itemize commandarg="bullet" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="bullet"/></itemprepend>
 <listitem><prepend>&bullet;</prepend>
  <para>b&textndash;ullet
 </para></listitem></itemize>

Index: t/results/xml_tests/comments_on_block_command_lines.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/xml_tests/comments_on_block_command_lines.pl,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- t/results/xml_tests/comments_on_block_command_lines.pl      3 Sep 2012 
21:58:50 -0000       1.17
+++ t/results/xml_tests/comments_on_block_command_lines.pl      15 Jan 2013 
01:25:52 -0000      1.18
@@ -2745,7 +2745,7 @@
 <listitem spaces=" "><prepend>x</prepend><para>itemize xit
 </para></listitem></itemize>
 
-<itemize commandarg="bullet" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="bullet" /> </itemprepend><!-- c comm 
-->
+<itemize commandarg="bullet" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="bullet"/> </itemprepend><!-- c comm 
-->
 <listitem spaces=" "><prepend>&bullet;</prepend><para>itemize bulletit
 </para></listitem></itemize>
 

Index: tests/layout/res_parser/formatting_xml/formatting.xml
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/tests/layout/res_parser/formatting_xml/formatting.xml,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- tests/layout/res_parser/formatting_xml/formatting.xml       21 Dec 2012 
00:30:46 -0000      1.17
+++ tests/layout/res_parser/formatting_xml/formatting.xml       15 Jan 2013 
01:25:52 -0000      1.18
@@ -1007,11 +1007,11 @@
 <listitem spaces=" "><prepend>+</prepend><para>i&textndash;tem +
 </para></listitem></itemize>
 
-<itemize commandarg="bullet" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="bullet" /></itemprepend>
+<itemize commandarg="bullet" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="bullet"/></itemprepend>
 <listitem spaces=" "><prepend>&bullet;</prepend><para>b&textndash;ullet
 </para></listitem></itemize>
 
-<itemize commandarg="minus" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="minus" /></itemprepend>
+<itemize commandarg="minus" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="minus"/></itemprepend>
 <listitem spaces=" "><prepend>&minus;</prepend><para>minu&textndash;s
 </para></listitem></itemize>
 
@@ -1608,11 +1608,11 @@
 <listitem spaces=" "><prepend>+</prepend><para>i&textndash;tem +
 </para></listitem></itemize>
 
-<itemize commandarg="bullet" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="bullet" /></itemprepend>
+<itemize commandarg="bullet" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="bullet"/></itemprepend>
 <listitem spaces=" "><prepend>&bullet;</prepend><para>b&textndash;ullet
 </para></listitem></itemize>
 
-<itemize commandarg="minus" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="minus" /></itemprepend>
+<itemize commandarg="minus" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="minus"/></itemprepend>
 <listitem spaces=" "><prepend>&minus;</prepend><para>minu&textndash;s
 </para></listitem></itemize>
 
@@ -2209,11 +2209,11 @@
 <listitem spaces=" "><prepend>+</prepend><para>i&textndash;tem +
 </para></listitem></itemize>
 
-<itemize commandarg="bullet" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="bullet" /></itemprepend>
+<itemize commandarg="bullet" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="bullet"/></itemprepend>
 <listitem spaces=" "><prepend>&bullet;</prepend><para>b&textndash;ullet
 </para></listitem></itemize>
 
-<itemize commandarg="minus" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="minus" /></itemprepend>
+<itemize commandarg="minus" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="minus"/></itemprepend>
 <listitem spaces=" "><prepend>&minus;</prepend><para>minu&textndash;s
 </para></listitem></itemize>
 
@@ -2804,11 +2804,11 @@
 <listitem spaces=" "><prepend>+</prepend><pre xml:space="preserve">i--tem +
 </pre></listitem></itemize>
 <pre xml:space="preserve">
-</pre><itemize commandarg="bullet" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="bullet" /></itemprepend>
+</pre><itemize commandarg="bullet" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="bullet"/></itemprepend>
 <listitem spaces=" "><prepend>&bullet;</prepend><pre 
xml:space="preserve">b--ullet
 </pre></listitem></itemize>
 <pre xml:space="preserve">
-</pre><itemize commandarg="minus" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="minus" /></itemprepend>
+</pre><itemize commandarg="minus" spaces=" " endspaces=" 
"><itemprepend><formattingcommand command="minus"/></itemprepend>
 <listitem spaces=" "><prepend>&minus;</prepend><pre 
xml:space="preserve">minu--s
 </pre></listitem></itemize>
 <pre xml:space="preserve">



reply via email to

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