[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp Texinfo/Convert/Plaintext.pm t/parag...
From: |
Patrice Dumas |
Subject: |
texinfo/tp Texinfo/Convert/Plaintext.pm t/parag... |
Date: |
Sat, 20 Nov 2010 23:35:41 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 10/11/20 23:35:41
Modified files:
tp/Texinfo/Convert: Plaintext.pm
tp/t : paragraph.t
tp/t/results/coverage: block_commands.pl def.pl
item_container.pl
nested_block_commands.pl preformatted.pl
table.pl
Log message:
Really indent the formats.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/paragraph.t?cvsroot=texinfo&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/coverage/block_commands.pl?cvsroot=texinfo&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/coverage/def.pl?cvsroot=texinfo&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/coverage/item_container.pl?cvsroot=texinfo&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/coverage/nested_block_commands.pl?cvsroot=texinfo&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/coverage/preformatted.pl?cvsroot=texinfo&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/coverage/table.pl?cvsroot=texinfo&r1=1.22&r2=1.23
Patches:
Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- Texinfo/Convert/Plaintext.pm 20 Nov 2010 22:56:04 -0000 1.8
+++ Texinfo/Convert/Plaintext.pm 20 Nov 2010 23:35:37 -0000 1.9
@@ -287,23 +287,32 @@
return $text;
}
-sub new_container($$)
+sub new_container($$;$)
{
my $self = shift;
my $type = shift;
+ my $conf = shift;
my $container_object;
my $paragraph_conf = {
'max' => $self->{'format_context'}->[-1]->{'max'},
- 'frenchspacing' => $self->{'frenchspacing'}
+ 'frenchspacing' => $self->{'frenchspacing'},
+ 'indent_level' => $self->{'format_context'}->[-1]->{'indent_level'},
};
+ if ($conf) {
+ foreach my $key (keys(%$conf)) {
+ $paragraph_conf->{$key} = $conf->{$key};
+ }
+ }
+ $paragraph_conf->{'indent_length'} =
$indent_length*$paragraph_conf->{'indent_level'}
+ if (!defined($paragraph_conf->{'indent_length'}));
if ($type eq 'line') {
$container_object = Texinfo::Convert::Line->new($paragraph_conf);
} elsif ($type eq 'paragraph') {
$container_object = Texinfo::Convert::Paragraph->new($paragraph_conf);
} elsif ($type eq 'unfilled') {
- $container_object = Texinfo::Convert::UnFilled->new();
+ $container_object = Texinfo::Convert::UnFilled->new($paragraph_conf);
} else {
die "Unknown container type $type\n";
}
@@ -315,11 +324,12 @@
return $container;
}
-sub convert_line($$)
+sub convert_line($$;$)
{
my $self = shift;
my $converted = shift;
- my $container = $self->new_container('line');
+ my $conf = shift;
+ my $container = $self->new_container('line', $conf);
push @{$self->{'containers'}}, $container;
my $result = $self->convert($converted);
$result .= $container->{'container'}->end();
@@ -327,11 +337,12 @@
return $result;
}
-sub convert_unfilled($$)
+sub convert_unfilled($$;$)
{
my $self = shift;
my $converted = shift;
- my $container = $self->new_container('unfilled');
+ my $conf = shift;
+ my $container = $self->new_container('unfilled', $conf);
$container->{'code'} = 1;
push @{$self->{'containers'}}, $container;
my $result = $self->convert($converted);
@@ -563,19 +574,19 @@
# flushleft and flushright -> keep track of result and add space
# at the end. do something specific here or at the end?
+ if ($preformatted_commands{$root->{'cmdname'}} or
$menu_commands{$root->{'cmdname'}}) {
+ push @{$self->{'context'}}, 'preformatted';
+ }
if ($indented_commands{$root->{'cmdname'}}) {
push @{$self->{'format_context'}}, { 'cmdname' => $root->{'cmdname'},
'paragraph_count' => 0,
'indent_level' =>
$self->{'format_context'}->[-1]->{'indent_level'} + 1,
'max' => $self->{'format_context'}->[-1]->{'max'} };
+ if ($self->{'context'}->[-1] eq 'preformatted') {
+ $preformatted = $self->new_container('unfilled');
+ push @{$self->{'containers'}}, $preformatted;
}
- if ($preformatted_commands{$root->{'cmdname'}} or
$menu_commands{$root->{'cmdname'}}) {
- push @{$self->{'context'}}, 'preformatted';
- $preformatted = Texinfo::Convert::UnFilled->new({
- 'indent_length'
- =>
$indent_length*$self->{'format_context'}->[-1]->{'indent_level'} });
- push @{$self->{'containers'}}, {'container' => $preformatted};
}
if ($root->{'cmdname'} eq 'quotation'
or $root->{'cmdname'} eq 'smallquotation') {
@@ -596,7 +607,8 @@
and $root->{'args'}) {
# FIXME handle sectioning commands with their underline
# and item with their prepending
- $result = $self->convert_line($root->{'args'}->[0]);
+ $result = $self->convert_line($root->{'args'}->[0],
+ {'indent_level' =>
$self->{'format_context'}->[-1]->{'indent_level'} -1});
chomp ($result);
$result .= "\n";
} elsif ($root->{'cmdname'} eq 'tab') {
@@ -677,20 +689,22 @@
my @args = @{$root->{'extra'}->{'def_args'}};
my ($category, $name, $class, $type) = ('', '', '', '');
my ($parsed_category, $parsed_name, $parsed_class, $parsed_type);
+ # FIXME this is all wrong. The def should be formatted as a paragraph,
+ # see info.init.
while (@args) {
my $parsed_arg = shift @args;
if ($parsed_arg->[0] eq 'category') {
$parsed_category = $self->_def_argument_content($parsed_arg->[1]);
- $category = $self->convert_unfilled($parsed_category);
+ $category = $self->convert_unfilled($parsed_category,
{'indent_length' => 0});
} elsif ($parsed_arg->[0] eq 'name') {
$parsed_name = $self->_def_argument_content($parsed_arg->[1]);
- $name = $self->convert_unfilled($parsed_name);
+ $name = $self->convert_unfilled($parsed_name, {'indent_length' =>
0});
} elsif ($parsed_arg->[0] eq 'class') {
$parsed_class = $self->_def_argument_content($parsed_arg->[1]);
- $class = $self->convert_unfilled($parsed_class);
+ $class = $self->convert_unfilled($parsed_class, {'indent_length' =>
0});
} elsif ($parsed_arg->[0] eq 'type') {
$parsed_type = $self->_def_argument_content($parsed_arg->[1]);
- $type = $self->convert_unfilled($parsed_type);
+ $type = $self->convert_unfilled($parsed_type, {'indent_length' =>
0});
} elsif ($parsed_arg->[0] eq 'arg' or $parsed_arg->[0] eq 'argtype') {
unshift @args, $parsed_arg;
last;
@@ -702,7 +716,7 @@
my $parsed_definition_category = _definition_category ($root,
[$parsed_category,
$category],
[$parsed_class, $class]);
- my $definition_category =
$self->convert_unfilled($parsed_definition_category);
+ my $definition_category =
$self->convert_unfilled($parsed_definition_category, {'indent_length' => 0});
my $type_name = '';
$type_name .= "$type " if ($type ne '');
$type_name .= $name if ($name ne '');
@@ -714,7 +728,7 @@
$arg_text = $parsed_arg->[1]->{'text'};
} else {
$arg_text
- =
$self->convert_unfilled($self->_def_argument_content($parsed_arg->[1]));
+ =
$self->convert_unfilled($self->_def_argument_content($parsed_arg->[1]),
{'indent_length' => 0});
}
$arguments .= $arg_text;
}
@@ -736,6 +750,8 @@
push @{$self->{'current_contents'}}, address@hidden;
while (@contents) {
my $content = shift @contents;
+ # FIXME an empty line between block commands don't seem to be
+ # output.
if ($content->{'type'}
and $content->{'type'} eq 'empty_line') {
$result .= "\n" if (!$self->{'empty_lines_count'}
@@ -756,7 +772,7 @@
pop @{$self->{'containers'}};
}
if ($preformatted) {
- $result .= $preformatted->end();
+ $result .= $preformatted->{'container'}->end();
pop @{$self->{'containers'}};
pop @{$self->{'context'}};
}
Index: t/paragraph.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/paragraph.t,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- t/paragraph.t 14 Nov 2010 21:30:26 -0000 1.6
+++ t/paragraph.t 20 Nov 2010 23:35:38 -0000 1.7
@@ -9,11 +9,12 @@
#use Test;
use Test::More;
-BEGIN { plan tests => 91 };
+BEGIN { plan tests => 92 };
use lib '../texi2html/lib/Unicode-EastAsianWidth/lib/';
#push @INC, '../texi2html/lib/Unicode-EastAsianWidth/lib/';
use Texinfo::Convert::Paragraph;
use Texinfo::Convert::Line;
+use Texinfo::Convert::UnFilled;
ok(1, "modules loading"); # If we made it this far, we're ok.
#########################
@@ -453,4 +454,12 @@
$result .= $line->end();
is ($result, "aa.))) after\n", 'line inhibit end sentence and ))');
+my $unfilled = Texinfo::Convert::UnFilled->new({'indent_length' => 5});
+$result = '';
+$result .= $unfilled->add_text("something\n");
+$result .= $unfilled->add_text("\n");
+$result .= $unfilled->add_text(" other\n");
+$result .= $unfilled->end();
+is ($result, " something\n\n other\n", 'unfilled and indent');
+
1;
Index: t/results/coverage/block_commands.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/coverage/block_commands.pl,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- t/results/coverage/block_commands.pl 20 Nov 2010 17:05:40 -0000
1.24
+++ t/results/coverage/block_commands.pl 20 Nov 2010 23:35:39 -0000
1.25
@@ -364,8 +364,8 @@
$result_converted{'plaintext'}->{'block_commands'} = '
in group
-warning:
-in quotation
+ warning:
+ in quotation
In float
Index: t/results/coverage/def.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/coverage/def.pl,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- t/results/coverage/def.pl 20 Nov 2010 17:05:40 -0000 1.24
+++ t/results/coverage/def.pl 20 Nov 2010 23:35:41 -0000 1.25
@@ -1762,11 +1762,11 @@
$result_converted{'plaintext'}->{'def'} = '
-- c--ategory: d--effn_name a--rguments...
-d-effn
+ d-effn
-- cate--gory: de--ffn_name ar--guments more args
even more so
-def-fn
+ def-fn
-- fset: i a g
-- cmde: truc
@@ -1781,7 +1781,7 @@
-- truc: followed by a comment
-- truc: after a deff item
-- truc: deffnx before end deffn
-Various deff lines
+ Various deff lines
';
1;
Index: t/results/coverage/item_container.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/coverage/item_container.pl,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- t/results/coverage/item_container.pl 20 Nov 2010 17:05:41 -0000
1.20
+++ t/results/coverage/item_container.pl 20 Nov 2010 23:35:41 -0000
1.21
@@ -215,9 +215,9 @@
$result_converted{'plaintext'}->{'item_container'} = '
-i-tem +
+ i-tem +
-b-ullet
+ b-ullet
';
1;
Index: t/results/coverage/nested_block_commands.pl
===================================================================
RCS file:
/sources/texinfo/texinfo/tp/t/results/coverage/nested_block_commands.pl,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- t/results/coverage/nested_block_commands.pl 20 Nov 2010 17:05:41 -0000
1.13
+++ t/results/coverage/nested_block_commands.pl 20 Nov 2010 23:35:41 -0000
1.14
@@ -1092,39 +1092,39 @@
$result_converted{'plaintext'}->{'nested_block_commands'} = 'In group
-in quotation
+ in quotation
-in quotation
+ in quotation
In group
-in quotation
+ in quotation
after quotation
In group sp b
-in quotation
+ in quotation
In group sp b a
-in quotation
+ in quotation
In group sp a
-in quotation
+ in quotation
-in quotation sp b
+ in quotation sp b
-in quotation sp b a
+ in quotation sp b a
-in quotation sp a
+ in quotation sp a
-in quotation
+ in quotation
After quotation sp b
-in quotation
+ in quotation
After quotation sp a
-in quotation
+ in quotation
After quotation sp b a
Index: t/results/coverage/preformatted.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/coverage/preformatted.pl,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- t/results/coverage/preformatted.pl 20 Nov 2010 22:56:04 -0000 1.23
+++ t/results/coverage/preformatted.pl 20 Nov 2010 23:35:41 -0000 1.24
@@ -236,7 +236,7 @@
text
item in table in format
-in table in format
+ in table in format
';
1;
Index: t/results/coverage/table.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/coverage/table.pl,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- t/results/coverage/table.pl 20 Nov 2010 17:05:41 -0000 1.22
+++ t/results/coverage/table.pl 20 Nov 2010 23:35:41 -0000 1.23
@@ -531,7 +531,7 @@
$result_converted{'plaintext'}->{'table'} = '
table item
table itemx
-In table
+ In table
vtable item
itemx vtable
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp Texinfo/Convert/Plaintext.pm t/parag...,
Patrice Dumas <=