[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp Texinfo/Convert/Plaintext.pm Texinfo...
From: |
Patrice Dumas |
Subject: |
texinfo/tp Texinfo/Convert/Plaintext.pm Texinfo... |
Date: |
Thu, 03 Mar 2011 22:20:38 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 11/03/03 22:20:37
Modified files:
tp/Texinfo/Convert: Plaintext.pm Unicode.pm
tp/t : plaintext_tests.t
Added files:
tp/t/results/plaintext_tests:
flushright_not_closed_and_format.pl
sc_with_utf8_enable_encoding.pl
Log message:
Pass text to unicode_text.
Fix bug with flushright and stack.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.108&r2=1.109
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Unicode.pm?cvsroot=texinfo&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/plaintext_tests.t?cvsroot=texinfo&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/plaintext_tests/flushright_not_closed_and_format.pl?cvsroot=texinfo&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/plaintext_tests/sc_with_utf8_enable_encoding.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.108
retrieving revision 1.109
diff -u -b -r1.108 -r1.109
--- Texinfo/Convert/Plaintext.pm 3 Mar 2011 09:46:07 -0000 1.108
+++ Texinfo/Convert/Plaintext.pm 3 Mar 2011 22:20:36 -0000 1.109
@@ -556,7 +556,8 @@
$text = uc($text) if ($self->{'formatters'}->[-1]->{'upper_case'});
if ($self->{'ENABLE_ENCODING'} and $self->{'encoding_name'}
and $self->{'encoding_name'} eq 'utf-8') {
- return Texinfo::Convert::Unicode::unicode_text($self, $command, $context);
+ return Texinfo::Convert::Unicode::unicode_text($self, $text, $command,
+ $context);
} elsif (!$context->{'code'} and !$context->{'preformatted'}) {
$text =~ s/---/\x{1F}/g;
$text =~ s/--/-/g;
@@ -842,15 +843,6 @@
return $result;
}
-sub flushright_index ($)
-{
- my $self = shift;
- my $index = -1;
- $index--
- while (!$flush_commands{$self->{'format_context'}->[$index]->{'cmdname'}});
- return $index;
-}
-
sub _align_lines($$$$$)
{
my $self = shift;
@@ -1784,7 +1776,9 @@
# use settitle for empty @top
# ignore @part
my $contents;
- if (@{$root->{'extra'}->{'misc_content'}} and $root->{'cmdname'} ne
'part') {
+ if ($root->{'extra'}->{'misc_content'}
+ and @{$root->{'extra'}->{'misc_content'}}
+ and $root->{'cmdname'} ne 'part') {
$contents = $root->{'extra'}->{'misc_content'};
} elsif ($root->{'cmdname'} eq 'top'
and $self->{'extra'}->{'settitle'}
@@ -2399,7 +2393,7 @@
$paragraph->{'container'}->end());
if ($self->{'context'}->[-1] eq 'flushright') {
$result = $self->_align_environment ($result,
- $self->{'text_element_context'}->[$self->flushright_index]->{'max'},
'right');
+ $self->{'text_element_context'}->[-1]->{'max'}, 'right');
}
pop @{$self->{'formatters'}};
delete $self->{'text_element_context'}->[-1]->{'counter'};
@@ -2411,11 +2405,11 @@
}
if ($self->{'context'}->[-1] eq 'flushright') {
$result = $self->_align_environment ($result,
- $self->{'text_element_context'}->[$self->flushright_index]->{'max'},
'right');
+ $self->{'text_element_context'}->[-1]->{'max'}, 'right');
}
pop @{$self->{'formatters'}};
- #Â We assume that, upon closing the preformatted we are at the
- #Â beginning of a line.
+ # We assume that, upon closing the preformatted we are at the
+ # beginning of a line.
delete $self->{'text_element_context'}->[-1]->{'counter'};
}
Index: Texinfo/Convert/Unicode.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Unicode.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- Texinfo/Convert/Unicode.pm 2 Mar 2011 01:04:15 -0000 1.9
+++ Texinfo/Convert/Unicode.pm 3 Mar 2011 22:20:36 -0000 1.10
@@ -561,12 +561,13 @@
return &$fallback_convert_accent($text, $command);
}
-sub unicode_text($$$)
+sub unicode_text($$$$)
{
my $self = shift;
+ my $text = shift;
my $command = shift;
my $context = shift;
- my $text = $command->{'text'};
+ $text = $command->{'text'} if (!defined($text));
if (!$context->{'code'} and !$context->{'preformatted'}) {
$text =~ s/---/\x{2014}/g;
Index: t/plaintext_tests.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/plaintext_tests.t,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- t/plaintext_tests.t 2 Mar 2011 22:52:22 -0000 1.11
+++ t/plaintext_tests.t 3 Mar 2011 22:20:37 -0000 1.12
@@ -339,6 +339,18 @@
'a. @^a'],
['invalid_accent_punctuation',
'a. @^@@'],
+['sc_with_utf8_enable_encoding',
+'@documentencoding utf-8
address@hidden sc}.
+'],
+['flushright_not_closed_and_format',
+'@flushright
+flushright
+
address@hidden
+A quot---ation
address@hidden quotation
+'],
);
foreach my $test (@test_cases) {
Index: t/results/plaintext_tests/flushright_not_closed_and_format.pl
===================================================================
RCS file: t/results/plaintext_tests/flushright_not_closed_and_format.pl
diff -N t/results/plaintext_tests/flushright_not_closed_and_format.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ t/results/plaintext_tests/flushright_not_closed_and_format.pl 3 Mar
2011 22:20:37 -0000 1.1
@@ -0,0 +1,122 @@
+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{'flushright_not_closed_and_format'} = {
+ 'contents' => [
+ {
+ 'cmdname' => 'flushright',
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line_after_command'
+ },
+ {
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => 'flushright
+'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'paragraph'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'cmdname' => 'quotation',
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line_after_command'
+ },
+ {
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => 'A quot---ation
+'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'paragraph'
+ }
+ ],
+ 'line_nr' => {
+ 'file_name' => '',
+ 'line_nr' => 4,
+ 'macro' => ''
+ },
+ 'parent' => {}
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line_after_command'
+ }
+ ],
+ 'line_nr' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ },
+ 'parent' => {}
+ }
+ ],
+ 'type' => 'text_root'
+};
+$result_trees{'flushright_not_closed_and_format'}{'contents'}[0]{'contents'}[0]{'parent'}
= $result_trees{'flushright_not_closed_and_format'}{'contents'}[0];
+$result_trees{'flushright_not_closed_and_format'}{'contents'}[0]{'contents'}[1]{'contents'}[0]{'parent'}
=
$result_trees{'flushright_not_closed_and_format'}{'contents'}[0]{'contents'}[1];
+$result_trees{'flushright_not_closed_and_format'}{'contents'}[0]{'contents'}[1]{'parent'}
= $result_trees{'flushright_not_closed_and_format'}{'contents'}[0];
+$result_trees{'flushright_not_closed_and_format'}{'contents'}[0]{'contents'}[2]{'parent'}
= $result_trees{'flushright_not_closed_and_format'}{'contents'}[0];
+$result_trees{'flushright_not_closed_and_format'}{'contents'}[0]{'contents'}[3]{'contents'}[0]{'parent'}
=
$result_trees{'flushright_not_closed_and_format'}{'contents'}[0]{'contents'}[3];
+$result_trees{'flushright_not_closed_and_format'}{'contents'}[0]{'contents'}[3]{'contents'}[1]{'contents'}[0]{'parent'}
=
$result_trees{'flushright_not_closed_and_format'}{'contents'}[0]{'contents'}[3]{'contents'}[1];
+$result_trees{'flushright_not_closed_and_format'}{'contents'}[0]{'contents'}[3]{'contents'}[1]{'parent'}
=
$result_trees{'flushright_not_closed_and_format'}{'contents'}[0]{'contents'}[3];
+$result_trees{'flushright_not_closed_and_format'}{'contents'}[0]{'contents'}[3]{'parent'}
= $result_trees{'flushright_not_closed_and_format'}{'contents'}[0];
+$result_trees{'flushright_not_closed_and_format'}{'contents'}[0]{'contents'}[4]{'parent'}
= $result_trees{'flushright_not_closed_and_format'}{'contents'}[0];
+$result_trees{'flushright_not_closed_and_format'}{'contents'}[0]{'parent'} =
$result_trees{'flushright_not_closed_and_format'};
+
+$result_texis{'flushright_not_closed_and_format'} = '@flushright
+flushright
+
address@hidden
+A quot---ation
address@hidden quotation
address@hidden flushright';
+
+
+$result_texts{'flushright_not_closed_and_format'} = 'flushright
+
+A quot---ation
+';
+
+$result_errors{'flushright_not_closed_and_format'} = [
+ {
+ 'error_line' => ':6: No matching address@hidden flushright\'
+',
+ 'file_name' => '',
+ 'line_nr' => 6,
+ 'macro' => '',
+ 'text' => 'No matching address@hidden flushright\'',
+ 'type' => 'error'
+ }
+];
+
+
+
+$result_converted{'plaintext'}->{'flushright_not_closed_and_format'} = '
flushright
+
+ A quot--ation
+';
+
+1;
Index: t/results/plaintext_tests/sc_with_utf8_enable_encoding.pl
===================================================================
RCS file: t/results/plaintext_tests/sc_with_utf8_enable_encoding.pl
diff -N t/results/plaintext_tests/sc_with_utf8_enable_encoding.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ t/results/plaintext_tests/sc_with_utf8_enable_encoding.pl 3 Mar 2011
22:20:37 -0000 1.1
@@ -0,0 +1,106 @@
+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{'sc_with_utf8_enable_encoding'} = {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => ' ',
+ 'type' => 'empty_spaces_after_command'
+ },
+ {
+ 'parent' => {},
+ 'text' => 'utf-8'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'spaces_at_end'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'misc_line_arg'
+ }
+ ],
+ 'cmdname' => 'documentencoding',
+ 'extra' => {
+ 'encoding_name' => 'utf-8',
+ 'perl_encoding' => 'utf-8-strict',
+ 'text_arg' => 'utf-8'
+ },
+ 'line_nr' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ },
+ 'parent' => {}
+ },
+ {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => 'in sc'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'cmdname' => 'sc',
+ 'contents' => [],
+ 'line_nr' => {
+ 'file_name' => '',
+ 'line_nr' => 2,
+ 'macro' => ''
+ },
+ 'parent' => {}
+ },
+ {
+ 'parent' => {},
+ 'text' => '.
+'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'paragraph'
+ }
+ ],
+ 'type' => 'text_root'
+};
+$result_trees{'sc_with_utf8_enable_encoding'}{'contents'}[0]{'args'}[0]{'contents'}[0]{'parent'}
= $result_trees{'sc_with_utf8_enable_encoding'}{'contents'}[0]{'args'}[0];
+$result_trees{'sc_with_utf8_enable_encoding'}{'contents'}[0]{'args'}[0]{'contents'}[1]{'parent'}
= $result_trees{'sc_with_utf8_enable_encoding'}{'contents'}[0]{'args'}[0];
+$result_trees{'sc_with_utf8_enable_encoding'}{'contents'}[0]{'args'}[0]{'contents'}[2]{'parent'}
= $result_trees{'sc_with_utf8_enable_encoding'}{'contents'}[0]{'args'}[0];
+$result_trees{'sc_with_utf8_enable_encoding'}{'contents'}[0]{'args'}[0]{'parent'}
= $result_trees{'sc_with_utf8_enable_encoding'}{'contents'}[0];
+$result_trees{'sc_with_utf8_enable_encoding'}{'contents'}[0]{'parent'} =
$result_trees{'sc_with_utf8_enable_encoding'};
+$result_trees{'sc_with_utf8_enable_encoding'}{'contents'}[1]{'contents'}[0]{'args'}[0]{'contents'}[0]{'parent'}
=
$result_trees{'sc_with_utf8_enable_encoding'}{'contents'}[1]{'contents'}[0]{'args'}[0];
+$result_trees{'sc_with_utf8_enable_encoding'}{'contents'}[1]{'contents'}[0]{'args'}[0]{'parent'}
= $result_trees{'sc_with_utf8_enable_encoding'}{'contents'}[1]{'contents'}[0];
+$result_trees{'sc_with_utf8_enable_encoding'}{'contents'}[1]{'contents'}[0]{'parent'}
= $result_trees{'sc_with_utf8_enable_encoding'}{'contents'}[1];
+$result_trees{'sc_with_utf8_enable_encoding'}{'contents'}[1]{'contents'}[1]{'parent'}
= $result_trees{'sc_with_utf8_enable_encoding'}{'contents'}[1];
+$result_trees{'sc_with_utf8_enable_encoding'}{'contents'}[1]{'parent'} =
$result_trees{'sc_with_utf8_enable_encoding'};
+
+$result_texis{'sc_with_utf8_enable_encoding'} = '@documentencoding utf-8
address@hidden sc}.
+';
+
+
+$result_texts{'sc_with_utf8_enable_encoding'} = 'in sc.
+';
+
+$result_errors{'sc_with_utf8_enable_encoding'} = [];
+
+
+
+$result_converted{'plaintext'}->{'sc_with_utf8_enable_encoding'} = 'IN SC.
+';
+
+1;
- texinfo/tp Texinfo/Convert/Plaintext.pm Texinfo...,
Patrice Dumas <=