[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp TODO Texinfo/Convert/Line.pm Texinfo...
From: |
Patrice Dumas |
Subject: |
texinfo/tp TODO Texinfo/Convert/Line.pm Texinfo... |
Date: |
Wed, 09 Feb 2011 08:24:24 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 11/02/09 08:24:24
Modified files:
tp : TODO
tp/Texinfo/Convert: Line.pm Paragraph.pm
tp/t : 03coverage_braces.t paragraph.t
tp/t/results/coverage_braces: test_w.pl
Log message:
Fix @w and line splitting.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/TODO?cvsroot=texinfo&r1=1.78&r2=1.79
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Line.pm?cvsroot=texinfo&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Paragraph.pm?cvsroot=texinfo&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/03coverage_braces.t?cvsroot=texinfo&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/paragraph.t?cvsroot=texinfo&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/coverage_braces/test_w.pl?cvsroot=texinfo&r1=1.1&r2=1.2
Patches:
Index: TODO
===================================================================
RCS file: /sources/texinfo/texinfo/tp/TODO,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -b -r1.78 -r1.79
--- TODO 6 Feb 2011 23:44:56 -0000 1.78
+++ TODO 9 Feb 2011 08:24:23 -0000 1.79
@@ -53,8 +53,6 @@
test empty line in block or brace command in menu description.
-test @w.
-
test unknown @value expanded.
test recursive acronym
Index: Texinfo/Convert/Line.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Line.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- Texinfo/Convert/Line.pm 5 Feb 2011 19:56:12 -0000 1.14
+++ Texinfo/Convert/Line.pm 9 Feb 2011 08:24:23 -0000 1.15
@@ -167,9 +167,13 @@
print STDERR "WORD+.L $word -> $line->{'word'}\n" if ($line->{'DEBUG'});
}
if (defined($space)) {
+ if ($line->{'protect_spaces'}) {
+ $result .= $line->_add_text($space);
+ } else {
$result .= $line->_add_pending_word();
$line->{'space'} = $space;
}
+ }
if (defined($end_sentence)) {
$line->{'end_sentence'} = $end_sentence;
}
@@ -198,11 +202,9 @@
if defined($keep_end_lines);
$line->{'frenchspacing'} = $frenchspacing
if defined($frenchspacing);
- # flush the spaces already existing
+ # begin a word, to have something even if empty
if ($space_protection) {
- my $new_space = $line->{'space'};
- $line->{'space'} = '';
- return $new_space;
+ $line->_add_next('');
}
return '';
}
@@ -227,18 +229,20 @@
if ($text =~ s/^([^\S\n]+)//) {
my $spaces = $1;
print STDERR "SPACES.L\n" if ($line->{'DEBUG'});
+ if ($line->{'protect_spaces'}) {
+ $line->{'word'} .= $spaces;
+ } else {
my $added_word = $line->{'word'};
$result .= $line->_add_pending_word();
- if ($line->{'protect_spaces'}) {
- $result .= $spaces;
- $line->{'space'} = '';
- } elsif (!$line->{'begin'}) {
+
+ if (!$line->{'begin'}) {
if (!$line->{'frenchspacing'} and $line->{'end_sentence'}) {
$line->{'space'} = ' ';
} else {
$line->{'space'} = ' ';
}
}
+ }
delete $line->{'end_sentence'};
} elsif ($text =~ s/^([^\s\p{Unicode::EastAsianWidth::InFullwidth}]+)//) {
my $added_word = $1;
Index: Texinfo/Convert/Paragraph.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Paragraph.pm,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- Texinfo/Convert/Paragraph.pm 8 Feb 2011 00:27:38 -0000 1.15
+++ Texinfo/Convert/Paragraph.pm 9 Feb 2011 08:24:23 -0000 1.16
@@ -190,6 +190,9 @@
}
}
if (defined($space)) {
+ if ($paragraph->{'protect_spaces'}) {
+ $result .= $paragraph->_add_text($space);
+ } else {
$result .= $paragraph->_add_pending_word();
$paragraph->{'space'} = $space;
if ($paragraph->{'counter'} + length($paragraph->{'space'})
@@ -197,6 +200,7 @@
$result .= $paragraph->_cut_line();
}
}
+ }
if (defined($end_sentence)) {
$paragraph->{'end_sentence'} = $end_sentence;
}
@@ -224,12 +228,9 @@
if defined($keep_end_lines);
$paragraph->{'frenchspacing'} = $frenchspacing
if defined($frenchspacing);
- # flush the spaces already existing
- if (defined($space_protection)) {
- my $new_space = $paragraph->{'space'};
- $paragraph->{'counter'} += length($new_space);
- $paragraph->{'space'} = '';
- return $new_space;
+ # begin a word, to have something even if empty
+ if ($space_protection) {
+ $paragraph->_add_next('');
}
return '';
}
@@ -255,18 +256,29 @@
my $spaces = $1;
print STDERR "SPACES($paragraph->{'counter'})\n" if
($paragraph->{'DEBUG'});
my $added_word = $paragraph->{'word'};
- $result .= $paragraph->_add_pending_word();
if ($paragraph->{'protect_spaces'}) {
- $paragraph->{'space'} .= $spaces;
- if ($paragraph->{'space'} =~ s/\n/ /g
- and !$paragraph->{'frenchspacing'} and $paragraph->{'end_sentence'}
- and length($paragraph->{'space'}) < 2) {
- $paragraph->{'space'} = ' ';
+
+ $paragraph->{'word'} .= $spaces;
+ $paragraph->{'word_counter'} += length($spaces);
+ #$paragraph->{'space'} .= $spaces;
+ if ($paragraph->{'word'} =~ s/\n/ /g
+ and !$paragraph->{'frenchspacing'} and
$paragraph->{'end_sentence'}) {
+ $paragraph->{'word'} =~ /(\s*)$/;
+ if (length($1) < 2) {
+ $paragraph->{'word'} =~ s/(\s*)$/ /;
+ my $removed = $1;
+ $paragraph->{'word_counter'} += length(' ') - length($removed);
+ }
+ }
+ # The $paragraph->{'counter'} != 0 is here to avoid having an
+ # additional line output when the text is longer than the max.
+ if ($paragraph->{'counter'} != 0 and
+ $paragraph->{'counter'} + $paragraph->{'word_counter'} +
+ length($paragraph->{'space'}) > $paragraph->{'max'}) {
+ $result .= $paragraph->_cut_line();
}
- #$result .= $paragraph->{'space'};
- #$paragraph->{'counter'} += length($paragraph->{'space'});
- #$paragraph->{'space'} = '';
} else {
+ $result .= $paragraph->_add_pending_word();
if ($paragraph->{'counter'} != 0) {
if (!$paragraph->{'frenchspacing'} and $paragraph->{'end_sentence'})
{
$paragraph->{'space'} = ' ';
Index: t/03coverage_braces.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/03coverage_braces.t,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- t/03coverage_braces.t 8 Feb 2011 00:27:38 -0000 1.23
+++ t/03coverage_braces.t 9 Feb 2011 08:24:24 -0000 1.24
@@ -60,7 +60,7 @@
'@w{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbb bbbbb bbb
b b b b b b b b b bb .
ccc dddd}.
-a a a a a a a a a a a a a a a a a a a a a a a a a a a a @w{a a a a a a a a a
a a a a a a a a a a a a a a a a a a a a a a a a a a}
+a a a a a a a a a a a a a a a a a a a a a a a a a a a a @w{b a a a a a a a a
a a a a a a a a a a a a a a a a a a a a a a a a a a}
@w{}
Index: t/paragraph.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/paragraph.t,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- t/paragraph.t 8 Feb 2011 00:27:38 -0000 1.15
+++ t/paragraph.t 9 Feb 2011 08:24:24 -0000 1.16
@@ -9,7 +9,7 @@
#use Test;
use Test::More;
-BEGIN { plan tests => 107 };
+BEGIN { plan tests => 101 };
use lib '../texi2html/lib/Unicode-EastAsianWidth/lib/';
#use lib '../texi2html/lib/libintl-perl/lib/';
use Texinfo::Convert::Paragraph;
@@ -234,41 +234,37 @@
$result = '';
$para->set_space_protection(1,1);
$result .= $para->add_text('aa.) bb ');
-is ($result, 'aa.) bb', 'space protected 2 words');
$result = $para->add_text(' eee ');
-is ($result, ' eee', 'space protected more word');
-$result = $para->add_text(' .)');
+$result .= $para->add_text(' .)');
$result .= $para->add_next('_');
$result .= $para->add_text("\n");
-is ($result, ' .)_', 'space protected and end of sentence and line added');
-$result = $para->add_text("aa\n");
-is ($result, ' aa', 'protected space after end of line');
-$result = $para->add_text(' . gg');
-is ($result, ' .', 'protected space with dot inside');
-$result = $para->add_text(". \n");
+$result .= $para->add_text("aa\n");
+$result .= $para->add_text(' . gg');
+$result .= $para->add_text(". \n");
$result .= $para->add_text("a");
-is ($result, ' gg.', 'protected space end line with already a space');
-$result = $para->add_text(' ');
+$result .= $para->add_text(' ');
$result .= $para->set_space_protection(0,0);
$result .= $para->add_text("c ");
-is ($result, " a \nc", 'end protected space end of line');
+is ($result, "aa.) bb eee .)_ aa . gg. a c\n", "protected spaces
many inputs");
$para->end();
$para = Texinfo::Convert::Paragraph->new({'indent_length' => 3});
$result = '';
-$para->set_space_protection(1,1);
+$result .= $para->set_space_protection(1,1);
$result .= $para->add_text(" a\n");
-$para->set_space_protection(0,0);
+$result .= $para->set_space_protection(0,0);
$result .= $para->end();
-is ($result, " a\n", 'end space protectoin by end line');
-$para = Texinfo::Convert::Paragraph->new({'indent_length' => 3});
+is ($result, " a \n", 'end space protection by end line');
-#$result = '';
-#$para->set_space_protection(1,1);
-#$result .= $para->add_text(" a rr\n");
-#$para->set_space_protection(0,0);
-#$result .= $para->end();
-#is ($result, " a rr\n", 'para begin space protection and space');
+$para = Texinfo::Convert::Paragraph->new();
+$result = '';
+$result .= $para->set_space_protection(1,1);
+$result .= $para->add_text("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbb bbbbb bbb b b b b b b b b b bb .\n");
+$result .= $para->add_text ("ccc dddd");
+$result .= $para->set_space_protection(0,0);
+$result .= $para->add_text ("gg.\n");
+$result .= $para->end();
+is ($result, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbb
bbbbb bbb b b b b b b b b b bb . ccc ddddgg.\n", 'long text followed by text
protected');
$para = Texinfo::Convert::Paragraph->new();
$result = '';
@@ -490,7 +486,6 @@
$result = '';
$line->set_space_protection(1,1);
$result .= $line->add_text(' aa.)');
-is ($result, " ", 'line space_protection leading space');
$result .= $line->add_text(' ');
$result .= $line->add_text('then');
$result .= $line->add_text('fff g');
Index: t/results/coverage_braces/test_w.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/coverage_braces/test_w.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- t/results/coverage_braces/test_w.pl 8 Feb 2011 00:27:39 -0000 1.1
+++ t/results/coverage_braces/test_w.pl 9 Feb 2011 08:24:24 -0000 1.2
@@ -55,7 +55,7 @@
'contents' => [
{
'parent' => {},
- 'text' => 'a a a a a a a a a a a a a a a a a a a a a a a a a
a a a a a a a a a a'
+ 'text' => 'b a a a a a a a a a a a a a a a a a a a a a a a a
a a a a a a a a a a'
}
],
'parent' => {},
@@ -751,7 +751,7 @@
$result_texis{'test_w'} =
'@w{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbb bbbbb bbb b
b b b b b b b b bb .
ccc dddd}.
-a a a a a a a a a a a a a a a a a a a a a a a a a a a a @w{a a a a a a a a a
a a a a a a a a a a a a a a a a a a a a a a a a a a}
+a a a a a a a a a a a a a a a a a a a a a a a a a a a a @w{b a a a a a a a a
a a a a a a a a a a a a a a a a a a a a a a a a a a}
@w{}
@@ -790,7 +790,7 @@
$result_texts{'test_w'} = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbb bbbbb bbb b b b b b b b b b bb .
ccc dddd.
-a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
a a a a a a a a a a a a a a a a a a a a a a a a
+a a a a a a a a a a a a a a a a a a a a a a a a a a a a b a a a a a a a a a a
a a a a a a a a a a a a a a a a a a a a a a a a
@@ -829,10 +829,10 @@
-$result_converted{'plaintext'}->{'test_w'} =
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbb bbbbb bbb b b
b b b b b b b bb . ccc
-dddd.
+$result_converted{'plaintext'}->{'test_w'} =
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbb bbbbb bbb b b
b b b b b b b bb . ccc dddd.
+
+ a a a a a a a a a a a a a a a a a a a a a a a a a a a a b a a a a a a a a a
a a a a a a a a a a a a a a a a a a a a a a a a a
- a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
a a a a a a a a a a a a a a a a a a a a a a a a a
a rr ggg.
- texinfo/tp TODO Texinfo/Convert/Line.pm Texinfo...,
Patrice Dumas <=