[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp Texinfo/Convert/Info.pm Texinfo/Conv...
From: |
Patrice Dumas |
Subject: |
texinfo/tp Texinfo/Convert/Info.pm Texinfo/Conv... |
Date: |
Wed, 16 Feb 2011 22:33:11 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 11/02/16 22:33:11
Modified files:
tp/Texinfo/Convert: Info.pm Plaintext.pm
tp/t : 09indices.t
Added files:
tp/t/include : count_image.png count_image.txt
count_image_text.txt
tp/t/results/indices: image_lines_count.pl
image_text_lines_count.pl
Log message:
Count lines passed in image text.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Info.pm?cvsroot=texinfo&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.83&r2=1.84
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/09indices.t?cvsroot=texinfo&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/include/count_image.png?cvsroot=texinfo&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/include/count_image.txt?cvsroot=texinfo&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/include/count_image_text.txt?cvsroot=texinfo&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/indices/image_lines_count.pl?cvsroot=texinfo&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/indices/image_text_lines_count.pl?cvsroot=texinfo&rev=1.1
Patches:
Index: Texinfo/Convert/Info.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Info.pm,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- Texinfo/Convert/Info.pm 16 Feb 2011 22:16:15 -0000 1.24
+++ Texinfo/Convert/Info.pm 16 Feb 2011 22:33:10 -0000 1.25
@@ -483,6 +483,7 @@
my $root = shift;
my @extensions = @image_files_extensions;
+ my $lines_count = 0;
if (defined($root->{'extra'}->{'brace_command_contents'}->[0])) {
my $basefile = Texinfo::Convert::Text::convert(
@@ -533,12 +534,13 @@
$result .= "\x{00}\x{08}]";
} else {
$result = $text;
+ $lines_count = ($result =~ tr/\n/\n/);
}
if (defined($result)) {
- return $result;
+ return ($result, $lines_count);
}
}
- return '';
+ return ('', 0);
}
1;
Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -b -r1.83 -r1.84
--- Texinfo/Convert/Plaintext.pm 16 Feb 2011 22:16:15 -0000 1.83
+++ Texinfo/Convert/Plaintext.pm 16 Feb 2011 22:33:10 -0000 1.84
@@ -1037,10 +1037,11 @@
if (!$self->{'formatters'}->[-1]->{'_top_formatter'}) {
$result = '['.$result.']';
}
- return $result;
+ my $lines_count = ($result =~ tr/\n/\n/);
+ return ($result, $lines_count);
}
}
- return '';
+ return ('', 0);
}
# on top, the converter object which holds some global information
@@ -1303,8 +1304,9 @@
$formatter->{'upper_case'}-- if ($upper_case_commands{$command});
return $result;
} elsif ($root->{'cmdname'} eq 'image') {
- #Â FIXME count lines
- $result = $self->_image($root);
+ my $lines_count;
+ ($result, $lines_count) = $self->_image($root);
+ $self->_add_lines_count($lines_count);
$self->_add_text_count($result);
if ($result ne '' and $formatter->{'type'} ne 'paragraph') {
$self->{'empty_lines_count'} = 0;
Index: t/09indices.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/09indices.t,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- t/09indices.t 16 Feb 2011 22:16:15 -0000 1.7
+++ t/09indices.t 16 Feb 2011 22:33:10 -0000 1.8
@@ -97,6 +97,24 @@
Text.
@printindex cp
'],
+['image_lines_count',
+'@node Top
+
address@hidden
+
address@hidden index entry
+
address@hidden cp
+'],
+['image_text_lines_count',
+'@node Top
+
address@hidden
+
address@hidden index entry
+
address@hidden cp
+'],
['empty_index_entry',
'@node Top
Index: t/include/count_image.png
===================================================================
RCS file: t/include/count_image.png
diff -N t/include/count_image.png
Index: t/include/count_image.txt
===================================================================
RCS file: t/include/count_image.txt
diff -N t/include/count_image.txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ t/include/count_image.txt 16 Feb 2011 22:33:11 -0000 1.1
@@ -0,0 +1,7 @@
+aaaa
+bbb
+cc
+
+ff
+
+
Index: t/include/count_image_text.txt
===================================================================
RCS file: t/include/count_image_text.txt
diff -N t/include/count_image_text.txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ t/include/count_image_text.txt 16 Feb 2011 22:33:11 -0000 1.1
@@ -0,0 +1,7 @@
+aaaa
+bbb
+cc
+
+ff
+
+
Index: t/results/indices/image_lines_count.pl
===================================================================
RCS file: t/results/indices/image_lines_count.pl
diff -N t/results/indices/image_lines_count.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ t/results/indices/image_lines_count.pl 16 Feb 2011 22:33:11 -0000
1.1
@@ -0,0 +1,298 @@
+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{'image_lines_count'} = {
+ 'contents' => [
+ {
+ 'contents' => [],
+ 'parent' => {},
+ 'type' => 'text_root'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => ' ',
+ 'type' => 'empty_spaces_after_command'
+ },
+ {
+ 'parent' => {},
+ 'text' => 'Top'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'spaces_at_end'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'misc_line_arg'
+ }
+ ],
+ 'cmdname' => 'node',
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => 'count_image'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'cmdname' => 'image',
+ 'contents' => [],
+ 'extra' => {
+ 'brace_command_contents' => [
+ [
+ {}
+ ]
+ ]
+ },
+ 'line_nr' => {
+ 'file_name' => '',
+ 'line_nr' => 3,
+ 'macro' => ''
+ },
+ 'parent' => {}
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => ' ',
+ 'type' => 'empty_spaces_after_command'
+ },
+ {
+ 'parent' => {},
+ 'text' => 'index entry'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'spaces_at_end'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'misc_line_arg'
+ }
+ ],
+ 'cmdname' => 'cindex',
+ 'extra' => {
+ 'index_entry' => {
+ 'command' => {},
+ 'content' => [
+ {}
+ ],
+ 'index_at_command' => 'cindex',
+ 'index_name' => 'cp',
+ 'index_prefix' => 'c',
+ 'key' => 'index entry',
+ 'node' => {},
+ 'number' => 1
+ },
+ 'misc_content' => []
+ },
+ 'line_nr' => {
+ 'file_name' => '',
+ 'line_nr' => 5,
+ 'macro' => ''
+ },
+ 'parent' => {}
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => ' ',
+ 'type' => 'empty_spaces_after_command'
+ },
+ {
+ 'parent' => {},
+ 'text' => 'cp'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'spaces_at_end'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'misc_line_arg'
+ }
+ ],
+ 'cmdname' => 'printindex',
+ 'extra' => {
+ 'misc_args' => [
+ 'cp'
+ ]
+ },
+ 'line_nr' => {
+ 'file_name' => '',
+ 'line_nr' => 7,
+ 'macro' => ''
+ },
+ 'parent' => {}
+ }
+ ],
+ 'extra' => {
+ 'node_content' => [
+ {}
+ ],
+ 'nodes_manuals' => [
+ {
+ 'node_content' => [],
+ 'normalized' => 'Top'
+ }
+ ],
+ 'normalized' => 'Top'
+ },
+ 'line_nr' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ },
+ 'parent' => {}
+ }
+ ],
+ 'type' => 'document_root'
+};
+$result_trees{'image_lines_count'}{'contents'}[0]{'parent'} =
$result_trees{'image_lines_count'};
+$result_trees{'image_lines_count'}{'contents'}[1]{'args'}[0]{'contents'}[0]{'parent'}
= $result_trees{'image_lines_count'}{'contents'}[1]{'args'}[0];
+$result_trees{'image_lines_count'}{'contents'}[1]{'args'}[0]{'contents'}[1]{'parent'}
= $result_trees{'image_lines_count'}{'contents'}[1]{'args'}[0];
+$result_trees{'image_lines_count'}{'contents'}[1]{'args'}[0]{'contents'}[2]{'parent'}
= $result_trees{'image_lines_count'}{'contents'}[1]{'args'}[0];
+$result_trees{'image_lines_count'}{'contents'}[1]{'args'}[0]{'parent'} =
$result_trees{'image_lines_count'}{'contents'}[1];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[0]{'parent'} =
$result_trees{'image_lines_count'}{'contents'}[1];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[1]{'args'}[0]{'contents'}[0]{'parent'}
= $result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[1]{'args'}[0];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[1]{'args'}[0]{'parent'}
= $result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[1];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[1]{'extra'}{'brace_command_contents'}[0][0]
=
$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[1]{'args'}[0]{'contents'}[0];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[1]{'parent'} =
$result_trees{'image_lines_count'}{'contents'}[1];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[2]{'parent'} =
$result_trees{'image_lines_count'}{'contents'}[1];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[3]{'parent'} =
$result_trees{'image_lines_count'}{'contents'}[1];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[4]{'args'}[0]{'contents'}[0]{'parent'}
= $result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[4]{'args'}[0];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[4]{'args'}[0]{'contents'}[1]{'parent'}
= $result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[4]{'args'}[0];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[4]{'args'}[0]{'contents'}[2]{'parent'}
= $result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[4]{'args'}[0];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[4]{'args'}[0]{'parent'}
= $result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[4];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[4]{'extra'}{'index_entry'}{'command'}
= $result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[4];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[4]{'extra'}{'index_entry'}{'content'}[0]
=
$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[4]{'args'}[0]{'contents'}[1];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[4]{'extra'}{'index_entry'}{'node'}
= $result_trees{'image_lines_count'}{'contents'}[1];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[4]{'extra'}{'misc_content'}
=
$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[4]{'extra'}{'index_entry'}{'content'};
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[4]{'parent'} =
$result_trees{'image_lines_count'}{'contents'}[1];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[5]{'parent'} =
$result_trees{'image_lines_count'}{'contents'}[1];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[6]{'args'}[0]{'contents'}[0]{'parent'}
= $result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[6]{'args'}[0];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[6]{'args'}[0]{'contents'}[1]{'parent'}
= $result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[6]{'args'}[0];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[6]{'args'}[0]{'contents'}[2]{'parent'}
= $result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[6]{'args'}[0];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[6]{'args'}[0]{'parent'}
= $result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[6];
+$result_trees{'image_lines_count'}{'contents'}[1]{'contents'}[6]{'parent'} =
$result_trees{'image_lines_count'}{'contents'}[1];
+$result_trees{'image_lines_count'}{'contents'}[1]{'extra'}{'node_content'}[0]
= $result_trees{'image_lines_count'}{'contents'}[1]{'args'}[0]{'contents'}[1];
+$result_trees{'image_lines_count'}{'contents'}[1]{'extra'}{'nodes_manuals'}[0]{'node_content'}
= $result_trees{'image_lines_count'}{'contents'}[1]{'extra'}{'node_content'};
+$result_trees{'image_lines_count'}{'contents'}[1]{'parent'} =
$result_trees{'image_lines_count'};
+
+$result_texis{'image_lines_count'} = '@node Top
+
address@hidden
+
address@hidden index entry
+
address@hidden cp
+';
+
+
+$result_texts{'image_lines_count'} = '
+count_image
+
+
+';
+
+$result_sectioning{'image_lines_count'} = {};
+
+$result_nodes{'image_lines_count'} = {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'normalized' => 'Top'
+ },
+ 'node_up' => {
+ 'extra' => {
+ 'manual_content' => [
+ {
+ 'text' => 'dir'
+ }
+ ]
+ }
+ }
+};
+
+$result_menus{'image_lines_count'} = {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'normalized' => 'Top'
+ }
+};
+
+$result_errors{'image_lines_count'} = [];
+
+
+
+$result_converted{'info'}->{'image_lines_count'} = 'This is , produced by
makeinfo version 4.13 from .
+
+
+File: , Node: Top, Up: (dir)
+
+ [image src="count_image.png" text="aaaa
+bbb
+cc
+
+ff
+
+"