texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp Texinfo/Convert/Line.pm Texinfo/Conv...


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Convert/Line.pm Texinfo/Conv...
Date: Sat, 04 Dec 2010 12:11:12 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        10/12/04 12:11:12

Modified files:
        tp/Texinfo/Convert: Line.pm Paragraph.pm Plaintext.pm 
                            UnFilled.pm 
        tp/t           : paragraph.t 

Log message:
        Add lines count in containers.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Line.pm?cvsroot=texinfo&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Paragraph.pm?cvsroot=texinfo&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/UnFilled.pm?cvsroot=texinfo&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/paragraph.t?cvsroot=texinfo&r1=1.10&r2=1.11

Patches:
Index: Texinfo/Convert/Line.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Line.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- Texinfo/Convert/Line.pm     1 Dec 2010 22:39:44 -0000       1.9
+++ Texinfo/Convert/Line.pm     4 Dec 2010 12:11:11 -0000       1.10
@@ -35,7 +35,8 @@
   my $class = shift;
   my $conf = shift;
   my $self = {'indent_length' => 0, 'counter' => 0,
-              'space' => '', 'frenchspacing' => 0, 'line_beginning' => 1};
+              'space' => '', 'frenchspacing' => 0, 'line_beginning' => 1,
+              'lines_counter' => 0};
   if (defined($conf)) {
     foreach my $key (keys(%$conf)) {
       if ($key eq 'text') {
@@ -67,6 +68,7 @@
   my $result = $line->add_pending_word();
   $line->{'line_beginning'} = 1;
   $line->{'space'} = '';
+  $line->{'lines_counter'}++;
   print STDERR "END_LINE\n" if ($line->{'debug'});
   return "$result\n";
 }
@@ -102,8 +104,6 @@
   my $line = shift;
   my $result = $line->add_pending_word();
   $result .= $line->{'space'};
-  $line->{'line_beginning'} = 1;
-  $line->{'space'} = '';
   print STDERR "END_LINE\n" if ($line->{'debug'});
   return $result;
 }

Index: Texinfo/Convert/Paragraph.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Paragraph.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- Texinfo/Convert/Paragraph.pm        1 Dec 2010 22:39:44 -0000       1.9
+++ Texinfo/Convert/Paragraph.pm        4 Dec 2010 12:11:11 -0000       1.10
@@ -35,7 +35,8 @@
   my $class = shift;
   my $conf = shift;
   my $self = {'max' => 72, 'indent_length' => 0, 'counter' => 0, 
-              'word_counter' => 0, 'space' => '', 'frenchspacing' => 0};
+              'word_counter' => 0, 'space' => '', 'frenchspacing' => 0,
+              'lines_counter' => 0};
   if (defined($conf)) {
     foreach my $key (keys(%$conf)) {
       $self->{$key} = $conf->{$key};
@@ -72,6 +73,7 @@
     $paragraph->{'indent_length'} = $paragraph->{'indent_length_next'};
     delete $paragraph->{'indent_length_next'};        
   }
+  $paragraph->{'lines_counter'}++;
   print STDERR "END_LINE\n" if ($paragraph->{'debug'});
   return "\n";
 }
@@ -112,12 +114,10 @@
   my $paragraph = shift;
   print STDERR "PARA END\n" if ($paragraph->{'debug'});
   my $result = $paragraph->add_pending_word();
-  $result .= "\n" if ($paragraph->{'counter'} != 0);
-  # This is only useful if the paragraph is reused.
-  $paragraph->{'counter'} = 0;
-  $paragraph->{'space'} = '';
-  $paragraph->{'word'} = undef;
-  $paragraph->{'word_counter'} = 0;
+  if ($paragraph->{'counter'} != 0) {
+    $result .= "\n"; 
+    $paragraph->{'lines_counter'}++;
+  }
   return $result;
 }
 

Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- Texinfo/Convert/Plaintext.pm        2 Dec 2010 09:17:32 -0000       1.21
+++ Texinfo/Convert/Plaintext.pm        4 Dec 2010 12:11:11 -0000       1.22
@@ -368,8 +368,6 @@
     $container_conf->{'indent_length'} = $indent;
   }
     
-  #$container_conf->{'indent_length'} = 
$indent_length*$container_conf->{'indent_level'}
-  #  if (!defined($container_conf->{'indent_length'}));
   if ($type eq 'line') {
     $container = Texinfo::Convert::Line->new($container_conf);
   } elsif ($type eq 'paragraph') {
@@ -761,7 +759,8 @@
       return $result;
      # could this be used otherwise?
     } elsif ($command eq 'titlefont') {
-      $result = Texinfo::Convert::Text::heading({'level' => 0},
+      $result = Texinfo::Convert::Text::heading({'level' => 0, 
+           'cmdname' => 'titlefont'},
            $self->convert_line ($root->{'args'}->[0]));
       $self->{'empty_lines_count'} = 0 unless ($result eq '');
       return $result;

Index: Texinfo/Convert/UnFilled.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/UnFilled.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- Texinfo/Convert/UnFilled.pm 1 Dec 2010 22:39:44 -0000       1.3
+++ Texinfo/Convert/UnFilled.pm 4 Dec 2010 12:11:12 -0000       1.4
@@ -33,7 +33,7 @@
   my $class = shift;
   my $conf = shift;
   my $self = {'indent_length' => 0, 'counter' => 0, 'line_beginning' => 1,
-              'leading_spaces' => '', 'only_spaces' => 1};
+              'leading_spaces' => '', 'only_spaces' => 1, 'lines_counter' => 
0};
   if (defined($conf)) {
     foreach my $key (keys(%$conf)) {
       if ($key eq 'text') {
@@ -63,6 +63,7 @@
   $line->{'line_beginning'} = 1;
   $line->{'leading_spaces'} = '';
   $line->{'only_spaces'} = 1;
+  $line->{'lines_counter'}++;
   print STDERR "END_LINE\n" if ($line->{'debug'});
   return "\n";
 }

Index: t/paragraph.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/paragraph.t,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- t/paragraph.t       21 Nov 2010 13:30:11 -0000      1.10
+++ t/paragraph.t       4 Dec 2010 12:11:12 -0000       1.11
@@ -9,7 +9,7 @@
 
 #use Test;
 use Test::More;
-BEGIN { plan tests => 95 };
+BEGIN { plan tests => 105 };
 use lib '../texi2html/lib/Unicode-EastAsianWidth/lib/';
 #push @INC, '../texi2html/lib/Unicode-EastAsianWidth/lib/';
 use Texinfo::Convert::Paragraph;
@@ -323,6 +323,13 @@
 is ($result, 'aa   ggg', 'space protected space');
 $para->end();
 
+$para = Texinfo::Convert::Paragraph->new({'max' => 8});
+$result = $para->add_text('aa ');
+is ($para->{'lines_counter'}, 0, 'count lines first');
+$result .= $para->add_text('bbbbbbbbbbbbbbbbbbbb');
+is ($para->{'lines_counter'}, 1, 'count lines text pending');
+$result .= $para->end();
+is ($para->{'lines_counter'}, 2, 'count lines end paragraph');
 
 #print STDERR "$result";
 #exit;
@@ -467,12 +474,26 @@
 $result .= $line->end();
 is ($result, " aa.) thenfff     g", 'line space_protection and spaces');
 
+$line = Texinfo::Convert::Line->new();
+$result = '';
+$result .= $line->add_text('aaaa ');
+is ($line->{'lines_counter'}, 0, 'line count line first line begin');
+$result .= $line->add_text("bbbb\n");
+is ($line->{'lines_counter'}, 1, 'line count line first line end');
+$result .= $line->add_text("\n");
+$result .= $line->end();
+is ($line->{'lines_counter'}, 2, 'line count line end line');
+
 my $unfilled = Texinfo::Convert::UnFilled->new({'indent_length' => 5});
 $result = '';
+is ($unfilled->{'lines_counter'}, 0, 'line count unfilled first line begin');
 $result .= $unfilled->add_text("something\n");
+is ($unfilled->{'lines_counter'}, 1, 'line count unfilled first line');
 $result .= $unfilled->add_text("\n");
+is ($unfilled->{'lines_counter'}, 2, 'line count unfilled second line');
 $result .= $unfilled->add_text(" other\n");
 $result .= $unfilled->end();
+is ($unfilled->{'lines_counter'}, 3, 'line count unfilled third line');
 is ($result, "     something\n\n      other\n", 'unfilled and indent');
 
 1;



reply via email to

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