texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp Texinfo/Convert/Line.pm t/paragraph....


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Convert/Line.pm t/paragraph....
Date: Sun, 21 Nov 2010 10:15:32 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        10/11/21 10:15:32

Modified files:
        tp/Texinfo/Convert: Line.pm 
        tp/t           : paragraph.t 
        tp/t/results/coverage: block_commands.pl 

Log message:
        Don't add an end of line at the end of a line.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Line.pm?cvsroot=texinfo&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/paragraph.t?cvsroot=texinfo&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/coverage/block_commands.pl?cvsroot=texinfo&r1=1.25&r2=1.26

Patches:
Index: Texinfo/Convert/Line.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Line.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- Texinfo/Convert/Line.pm     13 Nov 2010 21:13:16 -0000      1.3
+++ Texinfo/Convert/Line.pm     21 Nov 2010 10:15:24 -0000      1.4
@@ -19,7 +19,8 @@
 
 # this module has nothing Texinfo specific.  It is similar with 
 # Texinfo::Convert::Paragraph, but simpler.
-# It could be even simpler: there is no need to delay outputting a word.
+# The delay to output a word is here to be able to detect when an upper
+# case letter is before an end of line
 
 package Texinfo::Convert::Line;
 
@@ -28,12 +29,12 @@
 
 use Unicode::EastAsianWidth;
 
-# initialize a paragraph object.
+# initialize a line object.
 sub new($;$)
 {
   my $class = shift;
   my $conf = shift;
-  my $self = {'max' => 72, 'indent_length' => 0, 'counter' => 0,
+  my $self = {'indent_length' => 0, 'counter' => 0,
               'space' => '', 'frenchspacing' => 0, 'line_beginning' => 1};
   if (defined($conf)) {
     foreach my $key (keys(%$conf)) {
@@ -98,7 +99,11 @@
 sub end($)
 {
   my $line = shift;
-  return $line->end_line();
+  my $result = $line->add_pending_word();
+  $line->{'line_beginning'} = 1;
+  $line->{'space'} = '';
+  print STDERR "END_LINE\n" if ($line->{'debug'});
+  return $result;
 }
 
 # add a word and/or spaces and end of sentence.
@@ -147,7 +152,7 @@
       $word = $line->{'word'} if (defined($line->{'word'}));
       print STDERR "s `$line->{'space'}', w `$word'\n";
     }
-    if ($text =~ s/^\s+//) {
+    if ($text =~ s/^[^\S\n]+//) {
       print STDERR "SPACES\n" if ($line->{'debug'});
       my $added_word = $line->{'word'};
       $result .= $line->add_pending_word();
@@ -170,6 +175,8 @@
            and $line->{'word'} !~ 
/[[:upper:]][$end_sentence_character][$after_punctuation_characters]*$/) {
         $line->{'end_sentence'} = 1;
       }
+    } elsif ($text =~ s/^\n//) {
+      $result .= $line->end_line();
     } elsif ($text =~ s/^(\p{Unicode::EastAsianWidth::InFullwidth})//) {
       my $added = $1;
       print STDERR "EAST_ASIAN\n" if ($line->{'debug'});

Index: t/paragraph.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/paragraph.t,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- t/paragraph.t       20 Nov 2010 23:35:38 -0000      1.7
+++ t/paragraph.t       21 Nov 2010 10:15:28 -0000      1.8
@@ -9,7 +9,7 @@
 
 #use Test;
 use Test::More;
-BEGIN { plan tests => 92 };
+BEGIN { plan tests => 93 };
 use lib '../texi2html/lib/Unicode-EastAsianWidth/lib/';
 #push @INC, '../texi2html/lib/Unicode-EastAsianWidth/lib/';
 use Texinfo::Convert::Paragraph;
@@ -346,20 +346,21 @@
   #print STDERR "$result\n";
 }
 
-test_line(['word'], "word\n", 'word');
-test_line(['word other'], "word other\n", 'two_words');
-test_line(['word '], "word\n", 'trailing spaces');
-test_line([' word'], "word\n", 'leading spaces');
-test_line([' ', ' word'], "word\n", 'double leading spaces');
-test_line(['word  other'], "word other\n", 'two_words_two_spaces');
-test_line(['word.  other'], "word.  other\n", 'two_words_dot');
-test_line(['word. other'], "word.  other\n", 'two_words_dot_one_space');
-test_line(['word.) other'], "word.)  other\n", 
'two_words_dot_paren_one_space');
-test_line(['worD.  other'], "worD. other\n", 'two_words_dot_upper');
-test_line(['word','other'], "wordother\n", 'concatenate');
-test_line(["\x{7b2c}\x{4e00} ",'other'], "\x{7b2c}\x{4e00} other\n", 
'east_asian');
-test_line(['word.  other'], "word. other\n", 'two_words_dot_frenchspacing', 
{'frenchspacing' => 1});
-test_line(["aa.)\x{7b2c} b"], "aa.)\x{7b2c} b\n", 'end_sentence_east_asian');
+test_line(["word\n"], "word\n", 'word');
+test_line(['word other'], "word other", 'two_words');
+test_line(['word '], "word", 'trailing spaces');
+test_line(["word \n"], "word\n", 'trailing spaces eol');
+test_line([' word'], "word", 'leading spaces');
+test_line([' ', ' word'], "word", 'double leading spaces');
+test_line(['word  other'], "word other", 'two_words_two_spaces');
+test_line(['word.  other'], "word.  other", 'two_words_dot');
+test_line(['word. other'], "word.  other", 'two_words_dot_one_space');
+test_line(['word.) other'], "word.)  other", 'two_words_dot_paren_one_space');
+test_line(['worD.  other'], "worD. other", 'two_words_dot_upper');
+test_line(['word','other',"\n"], "wordother\n", 'concatenate');
+test_line(["\x{7b2c}\x{4e00} ","other \n"], "\x{7b2c}\x{4e00} other\n", 
'east_asian');
+test_line(['word.  other'], "word. other", 'two_words_dot_frenchspacing', 
{'frenchspacing' => 1});
+test_line(["aa.)\x{7b2c} b"], "aa.)\x{7b2c} b", 'end_sentence_east_asian');
 
 my $line = Texinfo::Convert::Line->new();
 $result = '';
@@ -367,14 +368,14 @@
 $result .= $line->add_next('_');
 $result .= $line->add_text(' after');
 $result .= $line->end();
-is ($result, "aa.)_  after\n", 'line add char after end sentence');
+is ($result, "aa.)_  after", 'line add char after end sentence');
 
 $para = Texinfo::Convert::Line->new();
 $result = '';
 $result .= $line->end_line();
 $result .= $line->add_text(' after');
 $result .= $line->end();
-is ($result, "\nafter\n", 'line space after end_line');
+is ($result, "\nafter", 'line space after end_line');
 #print STDERR "$result";
 
 $line = Texinfo::Convert::Line->new();
@@ -385,7 +386,7 @@
 $result = $line->end_line();
 is ($result, "\n", 'line call end_line after add_pending_word');
 $result = $line->end();
-is ($result, "\n", 'line call end after end_line');
+is ($result, "", 'line call end after end_line');
 
 $para = Texinfo::Convert::Line->new();
 $result = '';
@@ -393,7 +394,7 @@
 $result .= $line->add_pending_word();
 $result .= $line->add_text(' after');
 $result .= $line->end();
-is ($result, "aa.)  after\n", 'line space after sentence and 
add_pending_word');
+is ($result, "aa.)  after", 'line space after sentence and add_pending_word');
 
 $para = Texinfo::Convert::Line->new();
 $result = '';
@@ -401,7 +402,7 @@
 $result .= $line->add_next('.', undef, 1);
 $result .= $line->add_text(' after');
 $result .= $line->end();
-is ($result, "aA.  after\n", 'line force end sentence after upper case');
+is ($result, "aA.  after", 'line force end sentence after upper case');
 
 $line = Texinfo::Convert::Line->new();
 $result = '';
@@ -409,7 +410,7 @@
 $result .= $line->add_text('.');
 $result .= $line->add_text(' after');
 $result .= $line->end();
-is ($result, "aA. after\n", 'line end sentence after upper case');
+is ($result, "aA. after", 'line end sentence after upper case');
 
 $line = Texinfo::Convert::Line->new();
 $result = '';
@@ -417,7 +418,7 @@
 $result .= $line->add_text('))');
 $result .= $line->add_text(' after');
 $result .= $line->end();
-is ($result, "aa.)))  after\n", 'line continue with 
after_punctuation_characters');
+is ($result, "aa.)))  after", 'line continue with 
after_punctuation_characters');
 
 $line = Texinfo::Convert::Line->new();
 $result = '';
@@ -425,7 +426,7 @@
 $line->inhibit_end_sentence();
 $result .= $line->add_text(' after');
 $result .= $line->end();
-is ($result, "aa.) after\n", 'line inhibit end sentence');
+is ($result, "aa.) after", 'line inhibit end sentence');
 
 $line = Texinfo::Convert::Line->new();
 $result = '';
@@ -434,7 +435,7 @@
 $result .= $line->add_next('_');
 $result .= $line->add_text(' after');
 $result .= $line->end();
-is ($result, "aa.)_ after\n", 'line inhibit end sentence then add next');
+is ($result, "aa.)_ after", 'line inhibit end sentence then add next');
 
 $line = Texinfo::Convert::Line->new();
 $result = '';
@@ -443,7 +444,7 @@
 $result .= $line->add_text('aa.)');
 $result .= $line->add_text(' after');
 $result .= $line->end();
-is ($result, "aa.)aa.)  after\n", 'line cancel inhibit end sentence');
+is ($result, "aa.)aa.)  after", 'line cancel inhibit end sentence');
 
 $line = Texinfo::Convert::Line->new();
 $result = '';
@@ -452,7 +453,7 @@
 $result .= $line->add_text('))');
 $result .= $line->add_text(' after');
 $result .= $line->end();
-is ($result, "aa.))) after\n", 'line inhibit end sentence and ))');
+is ($result, "aa.))) after", 'line inhibit end sentence and ))');
 
 my $unfilled = Texinfo::Convert::UnFilled->new({'indent_length' => 5});
 $result = '';

Index: t/results/coverage/block_commands.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/coverage/block_commands.pl,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- t/results/coverage/block_commands.pl        20 Nov 2010 23:35:39 -0000      
1.25
+++ t/results/coverage/block_commands.pl        21 Nov 2010 10:15:29 -0000      
1.26
@@ -364,8 +364,7 @@
 $result_converted{'plaintext'}->{'block_commands'} = '
 in group
 
-     warning:
-     in quotation
+     warning:     in quotation
 
 In float
 



reply via email to

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