texinfo-commits
[Top][All Lists]
Advanced

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

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


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Convert/Plaintext.pm t/plain...
Date: Wed, 02 Mar 2011 22:52:23 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/03/02 22:52:23

Modified files:
        tp/Texinfo/Convert: Plaintext.pm 
        tp/t           : plaintext_tests.t 
Added files:
        tp/t/results/plaintext_tests: before_accent_punctuation.pl 
                                      invalid_accent_punctuation.pl 

Log message:
        Don't inhibit end sentence if an accent command led to an empty text.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.106&r2=1.107
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/plaintext_tests.t?cvsroot=texinfo&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/plaintext_tests/before_accent_punctuation.pl?cvsroot=texinfo&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/plaintext_tests/invalid_accent_punctuation.pl?cvsroot=texinfo&rev=1.1

Patches:
Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -b -r1.106 -r1.107
--- Texinfo/Convert/Plaintext.pm        2 Mar 2011 22:26:33 -0000       1.106
+++ Texinfo/Convert/Plaintext.pm        2 Mar 2011 22:52:22 -0000       1.107
@@ -1323,11 +1323,15 @@
       return $result;
     # commands with braces
     } elsif ($accent_commands{$root->{'cmdname'}}) {
+      my $accented_text 
+         = Texinfo::Convert::Text::text_accents($root, $self->{'encoding'});
       $result .= $self->_count_added($formatter->{'container'},
-         $formatter->{'container'}->add_text(
-          Texinfo::Convert::Text::text_accents($root, $self->{'encoding'})));
-      # in case the text added ends with punctuation
-      $formatter->{'container'}->inhibit_end_sentence();
+         $formatter->{'container'}->add_text($accented_text));
+      # in case the text added ends with punctuation.  
+      # If the text is empty (likely because of an error) previous 
+      # punctuation will be cancelled, we don't want that.
+      $formatter->{'container'}->inhibit_end_sentence()
+        if ($accented_text ne '');
       return $result;
     } elsif ($style_map{$command} 
          or ($root->{'type'} and $root->{'type'} eq 'definfoenclose_command')) 
{

Index: t/plaintext_tests.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/plaintext_tests.t,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- t/plaintext_tests.t 1 Mar 2011 21:44:54 -0000       1.10
+++ t/plaintext_tests.t 2 Mar 2011 22:52:22 -0000       1.11
@@ -335,6 +335,10 @@
 
@uref{http://foo.org/some/long/url/which/goes/past/eighty/columns/and/has/no/alternative/text.html}
 @end itemize
 '],
+['before_accent_punctuation',
+'a. @^a'],
+['invalid_accent_punctuation',
+'a. @^@@'],
 );
 
 foreach my $test (@test_cases) {

Index: t/results/plaintext_tests/before_accent_punctuation.pl
===================================================================
RCS file: t/results/plaintext_tests/before_accent_punctuation.pl
diff -N t/results/plaintext_tests/before_accent_punctuation.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ t/results/plaintext_tests/before_accent_punctuation.pl      2 Mar 2011 
22:52:23 -0000       1.1
@@ -0,0 +1,47 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
+   %result_indices %result_sectioning %result_nodes %result_menus
+   %result_floats %result_converted %result_converted_errors);
+
+$result_trees{'before_accent_punctuation'} = {
+  'contents' => [
+    {
+      'contents' => [
+        {
+          'parent' => {},
+          'text' => 'a. '
+        },
+        {
+          'args' => [
+            {
+              'parent' => {},
+              'text' => 'a'
+            }
+          ],
+          'cmdname' => '^',
+          'parent' => {}
+        }
+      ],
+      'parent' => {},
+      'type' => 'paragraph'
+    }
+  ],
+  'type' => 'text_root'
+};
+$result_trees{'before_accent_punctuation'}{'contents'}[0]{'contents'}[0]{'parent'}
 = $result_trees{'before_accent_punctuation'}{'contents'}[0];
+$result_trees{'before_accent_punctuation'}{'contents'}[0]{'contents'}[1]{'args'}[0]{'parent'}
 = $result_trees{'before_accent_punctuation'}{'contents'}[0]{'contents'}[1];
+$result_trees{'before_accent_punctuation'}{'contents'}[0]{'contents'}[1]{'parent'}
 = $result_trees{'before_accent_punctuation'}{'contents'}[0];
+$result_trees{'before_accent_punctuation'}{'contents'}[0]{'parent'} = 
$result_trees{'before_accent_punctuation'};
+
+$result_texis{'before_accent_punctuation'} = 'a. @^a';
+
+
+$result_texts{'before_accent_punctuation'} = 'a. a^';
+
+$result_errors{'before_accent_punctuation'} = [];
+
+
+
+$result_converted{'plaintext'}->{'before_accent_punctuation'} = 'a.  a^
+';
+
+1;

Index: t/results/plaintext_tests/invalid_accent_punctuation.pl
===================================================================
RCS file: t/results/plaintext_tests/invalid_accent_punctuation.pl
diff -N t/results/plaintext_tests/invalid_accent_punctuation.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ t/results/plaintext_tests/invalid_accent_punctuation.pl     2 Mar 2011 
22:52:23 -0000       1.1
@@ -0,0 +1,56 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
+   %result_indices %result_sectioning %result_nodes %result_menus
+   %result_floats %result_converted %result_converted_errors);
+
+$result_trees{'invalid_accent_punctuation'} = {
+  'contents' => [
+    {
+      'contents' => [
+        {
+          'parent' => {},
+          'text' => 'a. '
+        },
+        {
+          'cmdname' => '^',
+          'contents' => [],
+          'parent' => {}
+        },
+        {
+          'cmdname' => '@',
+          'parent' => {}
+        }
+      ],
+      'parent' => {},
+      'type' => 'paragraph'
+    }
+  ],
+  'type' => 'text_root'
+};
+$result_trees{'invalid_accent_punctuation'}{'contents'}[0]{'contents'}[0]{'parent'}
 = $result_trees{'invalid_accent_punctuation'}{'contents'}[0];
+$result_trees{'invalid_accent_punctuation'}{'contents'}[0]{'contents'}[1]{'parent'}
 = $result_trees{'invalid_accent_punctuation'}{'contents'}[0];
+$result_trees{'invalid_accent_punctuation'}{'contents'}[0]{'contents'}[2]{'parent'}
 = $result_trees{'invalid_accent_punctuation'}{'contents'}[0];
+$result_trees{'invalid_accent_punctuation'}{'contents'}[0]{'parent'} = 
$result_trees{'invalid_accent_punctuation'};
+
+$result_texis{'invalid_accent_punctuation'} = 'a. @^@@';
+
+
+$result_texts{'invalid_accent_punctuation'} = 'a. @';
+
+$result_errors{'invalid_accent_punctuation'} = [
+  {
+    'error_line' => ':1: Use braces to give a command as an argument to @^
+',
+    'file_name' => '',
+    'line_nr' => 1,
+    'macro' => '',
+    'text' => 'Use braces to give a command as an argument to @^',
+    'type' => 'error'
+  }
+];
+
+
+
+$result_converted{'plaintext'}->{'invalid_accent_punctuation'} = 'a.  @
+';
+
+1;



reply via email to

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