[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp Texinfo/Parser.pm Texinfo/Convert/Pl...
From: |
Patrice Dumas |
Subject: |
texinfo/tp Texinfo/Parser.pm Texinfo/Convert/Pl... |
Date: |
Sun, 21 Nov 2010 22:30:35 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 10/11/21 22:30:35
Modified files:
tp/Texinfo : Parser.pm
tp/Texinfo/Convert: Plaintext.pm
tp/t/results/coverage: multitable.pl
tp/t/results/invalid_nestings: bad_tab_nesting.pl
on_block_command_line.pl
tab_in_index.pl
tp/t/results/multitable: multitable_begin_with_tab.pl
multitable_not_closed_item.pl
multitable_not_closed_item_tab.pl
multitable_one_column_too_much_cells.pl
multitable_two_columns_too_much_cells.pl
Log message:
Add the cell and row counts to the Parser tree.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.150&r2=1.151
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/coverage/multitable.pl?cvsroot=texinfo&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/invalid_nestings/bad_tab_nesting.pl?cvsroot=texinfo&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/invalid_nestings/on_block_command_line.pl?cvsroot=texinfo&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/invalid_nestings/tab_in_index.pl?cvsroot=texinfo&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/multitable/multitable_begin_with_tab.pl?cvsroot=texinfo&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/multitable/multitable_not_closed_item.pl?cvsroot=texinfo&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/multitable/multitable_not_closed_item_tab.pl?cvsroot=texinfo&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/multitable/multitable_one_column_too_much_cells.pl?cvsroot=texinfo&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/multitable/multitable_two_columns_too_much_cells.pl?cvsroot=texinfo&r1=1.9&r2=1.10
Patches:
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -b -r1.150 -r1.151
--- Texinfo/Parser.pm 15 Nov 2010 00:22:36 -0000 1.150
+++ Texinfo/Parser.pm 21 Nov 2010 22:30:34 -0000 1.151
@@ -849,6 +849,17 @@
return $current;
}
+# remove the counters in multitable
+sub _close_multitable($) {
+ my $multitable = shift;
+ foreach my $row (@{$multitable->{'contents'}}) {
+ if ($row->{'type'} and $row->{'type'} eq 'row') {
+ delete $row->{'cells_count'};
+ }
+ }
+ delete $multitable->{'rows_count'};
+}
+
# close the current command, with error messages and give the parent.
# If the last argument is given it is the command being closed if
# there was no error, currently only block command, used for a
@@ -926,21 +937,29 @@
and ($root_commands{$current->{'cmdname'}}
or ($command and $current->{'parent'}->{'cmdname'}
and
$context_brace_commands{$current->{'parent'}->{'cmdname'}})))){
+ if ($current->{'cmdname'} and $current->{'cmdname'} eq 'multitable') {
+ _close_multitable($current);
+ }
$current = $self->_close_current($current, $line_nr, $command);
}
+ my $closed_command;
if ($command and $current->{'cmdname'}
and $current->{'cmdname'} eq $command) {
pop @{$self->{'context_stack'}} if
($preformatted_commands{$current->{'cmdname'}}
or $menu_commands{$current->{'cmdname'}});
+ $closed_command = $current;
+ if ($current->{'cmdname'} and $current->{'cmdname'} eq 'multitable') {
+ _close_multitable($current);
+ }
$current = $current->{'parent'}
} elsif ($command) {
_line_error ($self,
sprintf($self->__("Unmatched `%c%s'"),
ord('@'), "end $command"), $line_nr);
}
- return $current;
+ return ($closed_command, $current);
}
# begin paragraph if needed. If not try to merge with the previous
@@ -2568,8 +2587,9 @@
}
last;
}
- $current = _close_commands($self, $current, $line_nr,
- $end_command);
+ my $closed_command;
+ ($closed_command, $current)
+ = _close_commands($self, $current, $line_nr, $end_command);
}
$line = _start_empty_line_after_command($line, $current);
next;
@@ -2691,13 +2711,15 @@
die if (!$row->{'type'});
if ($row->{'type'} eq 'before_item') {
$self->_line_error($self->__("address@hidden before
address@hidden"), $line_nr);
- } elsif ($row->{'extra'}->{'cell_number'} >=
$parent->{'extra'}->{'max_columns'}) {
+ } elsif ($row->{'cells_count'} >=
$parent->{'extra'}->{'max_columns'}) {
$self->_line_error (sprintf($self->__("Too many columns
in multitable item (max %d)"), $parent->{'extra'}->{'max_columns'}), $line_nr);
} else {
- $row->{'extra'}->{'cell_number'}++;
+ $row->{'cells_count'}++;
push @{$row->{'contents'}}, { 'cmdname' => $command,
'parent' => $row,
- 'contents' => [] };
+ 'contents' => [],
+ 'extra' =>
+ {'cell_number' => $row->{'cells_count'}} };
$row->{'contents'}->[-1]->{'extra'}->{'invalid_nesting'}
= 1
if ($invalid);
$current = $row->{'contents'}->[-1];
@@ -2705,13 +2727,16 @@
}
} else {
print STDERR "ROW\n" if ($self->{'debug'});
+ $parent->{'rows_count'}++;
my $row = { 'type' => 'row', 'contents' => [],
- 'extra' => { 'cell_number' => 1 },
+ 'cells_count' => 1,
+ 'extra' => {'row_number' =>
$parent->{'rows_count'} },
'parent' => $parent };
push @{$parent->{'contents'}}, $row;
push @{$row->{'contents'}}, { 'cmdname' => $command,
'parent' => $row,
- 'contents' => [] };
+ 'contents' => [],
+ 'extra' => {'cell_number' =>
1}};
$row->{'contents'}->[-1]->{'extra'}->{'invalid_nesting'} =
1
if ($invalid);
$current = $row->{'contents'}->[-1];
Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- Texinfo/Convert/Plaintext.pm 21 Nov 2010 20:18:54 -0000 1.14
+++ Texinfo/Convert/Plaintext.pm 21 Nov 2010 22:30:35 -0000 1.15
@@ -85,6 +85,7 @@
my %root_commands = %Texinfo::Common::root_commands;
my %preformatted_commands = %Texinfo::Common::preformatted_commands;
my %explained_commands = %Texinfo::Common::explained_commands;
+my %item_container_commands = %Texinfo::Common::item_container_commands;
foreach my $def_command (keys(%def_commands)) {
$kept_misc_commands{$def_command} = 1 if ($misc_commands{$def_command});
@@ -613,6 +614,7 @@
my @contents;
if ($command eq 'xref') {
$contents[0] = {'text' => '*Note '};
+ # FIXME error message about no punctuation character following xref.
} else {
$contents[0] = {'text' => '*note '};
}
@@ -733,7 +735,12 @@
{'indent_level' =>
$self->{'format_context'}->[-1]->{'indent_level'} -1});
chomp ($result);
$result .= "\n";
- } elsif ($root->{'cmdname'} eq 'tab') {
+ } elsif ($root->{'cmdname'} eq 'item' and $root->{'parent'}->{'cmdname'}
+ and $item_container_commands{$root->{'parent'}->{'cmdname'}}) {
+ # TODO
+ } elsif ($root->{'cmdname'} eq 'headitem' or $root->{'cmdname'} eq 'item'
+ or $root->{'cmdname'} eq 'tab') {
+ #} elsif ($root->{'cmdname'} eq 'tab') {
# TODO
} elsif ($root->{'cmdname'} eq 'listoffloats') {
# FIXME handle listoffloats
@@ -800,6 +807,9 @@
$self->{'empty_lines_count'} = 0;
# FIXME indenting. First and not first paragraph.
# FIXME also beware of 'asis'! The space before has to be kept then.
+ # it should be just before the paragraph.
+ # Maybe just handle empty_spaces_before_paragraph instead of
+ # ignoring it?
# my $paragraphindent = get_conf('paragraphindent');
# $paragraphindent = 0 if ($paragraphindent eq 'none');
# if ($paragraphindent ne 'asis' and $paragraphindent and
$line_char_counter == 0 and (defined($content->{'paragraph_in_element_nr'}))
and ($info_state->{'indent_para'} or (!defined($info_state->{'indent_para'})
and ($content->{'paragraph_in_element_nr'} or (get_conf('firstparagraphindent')
eq 'insert')))))
Index: t/results/coverage/multitable.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/coverage/multitable.pl,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- t/results/coverage/multitable.pl 20 Nov 2010 17:05:41 -0000 1.23
+++ t/results/coverage/multitable.pl 21 Nov 2010 22:30:35 -0000 1.24
@@ -90,6 +90,9 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 1
+ },
'parent' => {}
},
{
@@ -112,11 +115,14 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 2
+ },
'parent' => {}
}
],
'extra' => {
- 'cell_number' => 2
+ 'row_number' => 1
},
'parent' => {},
'type' => 'row'
@@ -142,6 +148,9 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 1
+ },
'parent' => {}
},
{
@@ -176,11 +185,14 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 2
+ },
'parent' => {}
}
],
'extra' => {
- 'cell_number' => 2
+ 'row_number' => 2
},
'parent' => {},
'type' => 'row'
@@ -206,6 +218,9 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 1
+ },
'parent' => {}
},
{
@@ -272,11 +287,14 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 2
+ },
'parent' => {}
}
],
'extra' => {
- 'cell_number' => 2
+ 'row_number' => 3
},
'parent' => {},
'type' => 'row'
@@ -303,11 +321,14 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 1
+ },
'parent' => {}
}
],
'extra' => {
- 'cell_number' => 1
+ 'row_number' => 4
},
'parent' => {},
'type' => 'row'
@@ -401,6 +422,9 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 1
+ },
'parent' => {}
},
{
@@ -423,11 +447,14 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 2
+ },
'parent' => {}
}
],
'extra' => {
- 'cell_number' => 2
+ 'row_number' => 1
},
'parent' => {},
'type' => 'row'
Index: t/results/invalid_nestings/bad_tab_nesting.pl
===================================================================
RCS file:
/sources/texinfo/texinfo/tp/t/results/invalid_nestings/bad_tab_nesting.pl,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- t/results/invalid_nestings/bad_tab_nesting.pl 20 Nov 2010 16:58:06
-0000 1.10
+++ t/results/invalid_nestings/bad_tab_nesting.pl 21 Nov 2010 22:30:35
-0000 1.11
@@ -88,6 +88,9 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 1
+ },
'parent' => {}
},
{
@@ -111,13 +114,14 @@
}
],
'extra' => {
+ 'cell_number' => 2,
'invalid_nesting' => 1
},
'parent' => {}
}
],
'extra' => {
- 'cell_number' => 2
+ 'row_number' => 1
},
'parent' => {},
'type' => 'row'
Index: t/results/invalid_nestings/on_block_command_line.pl
===================================================================
RCS file:
/sources/texinfo/texinfo/tp/t/results/invalid_nestings/on_block_command_line.pl,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- t/results/invalid_nestings/on_block_command_line.pl 20 Nov 2010 16:58:06
-0000 1.19
+++ t/results/invalid_nestings/on_block_command_line.pl 21 Nov 2010 22:30:35
-0000 1.20
@@ -138,11 +138,14 @@
'
}
],
+ 'extra' => {
+ 'cell_number' => 1
+ },
'parent' => {}
}
],
'extra' => {
- 'cell_number' => 1
+ 'row_number' => 1
},
'parent' => {},
'type' => 'row'
Index: t/results/invalid_nestings/tab_in_index.pl
===================================================================
RCS file:
/sources/texinfo/texinfo/tp/t/results/invalid_nestings/tab_in_index.pl,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- t/results/invalid_nestings/tab_in_index.pl 20 Nov 2010 16:58:07 -0000
1.11
+++ t/results/invalid_nestings/tab_in_index.pl 21 Nov 2010 22:30:35 -0000
1.12
@@ -75,6 +75,9 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 1
+ },
'parent' => {}
},
{
@@ -152,11 +155,14 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 2
+ },
'parent' => {}
}
],
'extra' => {
- 'cell_number' => 2
+ 'row_number' => 1
},
'parent' => {},
'type' => 'row'
Index: t/results/multitable/multitable_begin_with_tab.pl
===================================================================
RCS file:
/sources/texinfo/texinfo/tp/t/results/multitable/multitable_begin_with_tab.pl,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- t/results/multitable/multitable_begin_with_tab.pl 20 Nov 2010 16:58:08
-0000 1.8
+++ t/results/multitable/multitable_begin_with_tab.pl 21 Nov 2010 22:30:35
-0000 1.9
@@ -182,11 +182,14 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 1
+ },
'parent' => {}
}
],
'extra' => {
- 'cell_number' => 1
+ 'row_number' => 1
},
'parent' => {},
'type' => 'row'
Index: t/results/multitable/multitable_not_closed_item.pl
===================================================================
RCS file:
/sources/texinfo/texinfo/tp/t/results/multitable/multitable_not_closed_item.pl,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- t/results/multitable/multitable_not_closed_item.pl 20 Nov 2010 16:58:08
-0000 1.8
+++ t/results/multitable/multitable_not_closed_item.pl 21 Nov 2010 22:30:35
-0000 1.9
@@ -76,11 +76,14 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 1
+ },
'parent' => {}
}
],
'extra' => {
- 'cell_number' => 1
+ 'row_number' => 1
},
'parent' => {},
'type' => 'row'
Index: t/results/multitable/multitable_not_closed_item_tab.pl
===================================================================
RCS file:
/sources/texinfo/texinfo/tp/t/results/multitable/multitable_not_closed_item_tab.pl,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- t/results/multitable/multitable_not_closed_item_tab.pl 20 Nov 2010
16:58:08 -0000 1.8
+++ t/results/multitable/multitable_not_closed_item_tab.pl 21 Nov 2010
22:30:35 -0000 1.9
@@ -75,6 +75,9 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 1
+ },
'parent' => {}
},
{
@@ -97,11 +100,14 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 2
+ },
'parent' => {}
}
],
'extra' => {
- 'cell_number' => 2
+ 'row_number' => 1
},
'parent' => {},
'type' => 'row'
Index: t/results/multitable/multitable_one_column_too_much_cells.pl
===================================================================
RCS file:
/sources/texinfo/texinfo/tp/t/results/multitable/multitable_one_column_too_much_cells.pl,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- t/results/multitable/multitable_one_column_too_much_cells.pl 20 Nov
2010 16:58:08 -0000 1.8
+++ t/results/multitable/multitable_one_column_too_much_cells.pl 21 Nov
2010 22:30:35 -0000 1.9
@@ -107,11 +107,14 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 1
+ },
'parent' => {}
}
],
'extra' => {
- 'cell_number' => 1
+ 'row_number' => 1
},
'parent' => {},
'type' => 'row'
@@ -138,11 +141,14 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 1
+ },
'parent' => {}
}
],
'extra' => {
- 'cell_number' => 1
+ 'row_number' => 2
},
'parent' => {},
'type' => 'row'
@@ -214,11 +220,14 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 1
+ },
'parent' => {}
}
],
'extra' => {
- 'cell_number' => 1
+ 'row_number' => 3
},
'parent' => {},
'type' => 'row'
@@ -260,11 +269,14 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 1
+ },
'parent' => {}
}
],
'extra' => {
- 'cell_number' => 1
+ 'row_number' => 4
},
'parent' => {},
'type' => 'row'
Index: t/results/multitable/multitable_two_columns_too_much_cells.pl
===================================================================
RCS file:
/sources/texinfo/texinfo/tp/t/results/multitable/multitable_two_columns_too_much_cells.pl,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- t/results/multitable/multitable_two_columns_too_much_cells.pl 20 Nov
2010 16:58:08 -0000 1.9
+++ t/results/multitable/multitable_two_columns_too_much_cells.pl 21 Nov
2010 22:30:35 -0000 1.10
@@ -84,6 +84,9 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 1
+ },
'parent' => {}
},
{
@@ -151,11 +154,14 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 2
+ },
'parent' => {}
}
],
'extra' => {
- 'cell_number' => 2
+ 'row_number' => 1
},
'parent' => {},
'type' => 'row'
@@ -182,11 +188,14 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 1
+ },
'parent' => {}
}
],
'extra' => {
- 'cell_number' => 1
+ 'row_number' => 2
},
'parent' => {},
'type' => 'row'
@@ -212,6 +221,9 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 1
+ },
'parent' => {}
},
{
@@ -249,11 +261,14 @@
'type' => 'paragraph'
}
],
+ 'extra' => {
+ 'cell_number' => 2
+ },
'parent' => {}
}
],
'extra' => {
- 'cell_number' => 2
+ 'row_number' => 3
},
'parent' => {},
'type' => 'row'
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp Texinfo/Parser.pm Texinfo/Convert/Pl...,
Patrice Dumas <=