[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp Texinfo/Structuring.pm t/automatic_n...
From: |
Patrice Dumas |
Subject: |
texinfo/tp Texinfo/Structuring.pm t/automatic_n... |
Date: |
Wed, 07 Mar 2012 00:44:16 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 12/03/07 00:44:16
Modified files:
tp/Texinfo : Structuring.pm
tp/t : automatic_nodes.t
Log message:
Add nodes enven for empty sectioning commands.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Structuring.pm?cvsroot=texinfo&r1=1.126&r2=1.127
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/automatic_nodes.t?cvsroot=texinfo&r1=1.8&r2=1.9
Patches:
Index: Texinfo/Structuring.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Structuring.pm,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -b -r1.126 -r1.127
--- Texinfo/Structuring.pm 4 Mar 2012 23:22:24 -0000 1.126
+++ Texinfo/Structuring.pm 7 Mar 2012 00:44:16 -0000 1.127
@@ -1304,8 +1304,12 @@
= Texinfo::Common::protect_first_parenthesis($node_tree->{'contents'});
$node_tree = reference_to_text_in_tree($self, $node_tree);
- return undef if (!$node_tree->{'contents'}
- or !scalar(@{$node_tree->{'contents'}}));
+ my $empty_node = 0;
+ if (!$node_tree->{'contents'}
+ or !scalar(@{$node_tree->{'contents'}})) {
+ $node_tree->{'contents'} = [{'text' => ''}];
+ $empty_node = 1;
+ }
unless (($node_tree->{'contents'}->[-1]->{'cmdname'}
and ($node_tree->{'contents'}->[-1]->{'cmdname'} eq 'c'
@@ -1316,7 +1320,7 @@
{'type' => 'spaces_at_end', 'text' => "\n"};
}
- my $appended_number = 0;
+ my $appended_number = 0 +$empty_node;
my ($node, $parsed_node);
while (!defined($node)
@@ -1338,8 +1342,14 @@
$content->{'parent'} = $node_arg;
}
$parsed_node = Texinfo::Parser::_parse_node_manual($node_arg);
- return undef if (!defined($parsed_node) or !$parsed_node->{'node_content'}
- or $parsed_node->{'normalized'} !~ /[^-]/);
+ if (!defined($parsed_node) or !$parsed_node->{'node_content'}
+ or $parsed_node->{'normalized'} !~ /[^-]/) {
+ if ($appended_number) {
+ return undef;
+ } else {
+ $node = undef;
+ }
+ }
$appended_number++;
}
@@ -1415,7 +1425,7 @@
$new_node_tree = Texinfo::Common::copy_tree({'contents'
=> $content->{'extra'}->{'misc_content'}});
}
- my $new_node = _new_node ($self, $new_node_tree);
+ my $new_node = _new_node($self, $new_node_tree);
if (defined($new_node)) {
push @contents, $new_node;
$new_node->{'extra'}->{'associated_section'} = $content;
Index: t/automatic_nodes.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/automatic_nodes.t,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- t/automatic_nodes.t 4 Mar 2012 23:46:41 -0000 1.8
+++ t/automatic_nodes.t 7 Mar 2012 00:44:16 -0000 1.9
@@ -1,7 +1,7 @@
use strict;
use Test::More;
-BEGIN { plan tests => 23 };
+BEGIN { plan tests => 24 };
use lib 'maintain/lib/Unicode-EastAsianWidth/lib/';
use lib 'maintain/lib/libintl-perl/lib/';
@@ -57,7 +57,8 @@
'@node changed @code{node} and (@samp{file})
',
'ref in new node');
-test_new_node ('@asis{}', undef, undef, 'empty node');
+test_new_node ('@asis{}', '-1', '@node @asis{} 1
+', 'empty node');
my $parser = Texinfo::Parser::parser();
my $tree = $parser->parse_texi_text('@node a node
@@ -92,6 +93,8 @@
@unnumbered
address@hidden @asis{}
+
@bye';
my $reference =
@@ -122,8 +125,12 @@
@node section 1
@section section
address@hidden 1
@unnumbered
address@hidden @asis{} 2
address@hidden @asis{}
+
@bye
';
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp Texinfo/Structuring.pm t/automatic_n...,
Patrice Dumas <=