texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

texinfo/tp MANIFEST Texinfo/Parser.pm Texinfo/S...


From: Patrice Dumas
Subject: texinfo/tp MANIFEST Texinfo/Parser.pm Texinfo/S...
Date: Fri, 24 Feb 2012 00:02:42 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        12/02/24 00:02:41

Modified files:
        tp             : MANIFEST 
        tp/Texinfo     : Parser.pm Structuring.pm 
Added files:
        tp/t           : automatic_nodes.t 

Log message:
        Prepare a node and register it.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/MANIFEST?cvsroot=texinfo&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.363&r2=1.364
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Structuring.pm?cvsroot=texinfo&r1=1.113&r2=1.114
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/automatic_nodes.t?cvsroot=texinfo&rev=1.1

Patches:
Index: MANIFEST
===================================================================
RCS file: /sources/texinfo/texinfo/tp/MANIFEST,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- MANIFEST    19 Feb 2012 11:41:30 -0000      1.35
+++ MANIFEST    24 Feb 2012 00:02:41 -0000      1.36
@@ -52,6 +52,7 @@
 t/70value_and_macro.t
 t/80include.t
 t/accents.t
+t/automatic_nodes.t
 t/converters_tests.t
 t/docbook_tests.t
 texi2any
@@ -144,6 +145,7 @@
 TODO
 t/paragraph.t
 t/plaintext_tests.t
+t/protect_character_in_texinfo.t
 t/README
 t/results/alias/alias_table_command.pl
 t/results/alias/bad_line.pl

Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.363
retrieving revision 1.364
diff -u -b -r1.363 -r1.364
--- Texinfo/Parser.pm   22 Feb 2012 00:03:44 -0000      1.363
+++ Texinfo/Parser.pm   24 Feb 2012 00:02:41 -0000      1.364
@@ -2728,8 +2728,6 @@
       push @{$self->{'floats'}->{$type}}, $float;
       $float->{'float_section'} = $self->{'current_section'} 
         if (defined($self->{'current_section'}));
-      #$float->{'float_node'} = $self->{'current_node'} 
-      #  if (defined($self->{'current_node'}));
     }
     $current = $current->{'parent'};
     delete $current->{'remaining_args'};

Index: Texinfo/Structuring.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Structuring.pm,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -b -r1.113 -r1.114
--- Texinfo/Structuring.pm      13 Feb 2012 22:23:23 -0000      1.113
+++ Texinfo/Structuring.pm      24 Feb 2012 00:02:41 -0000      1.114
@@ -1241,6 +1241,58 @@
   }
 }
 
+# prepare a new node and register it
+# FIXME protect comma and punctuation?
+sub _new_node($$)
+{
+  my $self = shift;
+  my $node_tree = shift;
+
+  return undef if (!$node_tree->{'contents'} 
+                   or !scalar(@{$node_tree->{'contents'}}));
+
+  unless (($node_tree->{'contents'}->[-1]->{'cmdname'}
+       and ($node_tree->{'contents'}->[-1]->{'cmdname'} eq 'c'
+            or $node_tree->{'contents'}->[-1]->{'cmdname'} eq 'comment'))
+      or (defined($node_tree->{'contents'}->[-1]->{'text'})
+          and $node_tree->{'contents'}->[-1]->{'text'} =~ /\n/)) {
+    push @{$node_tree->{'contents'}}, 
+           {'type' => 'spaces_at_end', 'text' => "\n"};
+  }
+
+  my $appended_number = 0;
+  my ($node, $parsed_node);
+
+  while (!defined($node) 
+         or ($self->{'labels'} 
+            and $self->{'labels'}->{$parsed_node->{'normalized'}})) {
+    $node = {'cmdname' => 'node', 'args' => [{}]};
+    my $node_arg = $node->{'args'}->[0];
+    $node_arg->{'parent'} = $node;
+    @{$node_arg->{'contents'}} = (
+       {'extra' => {'command' => $node},
+        'text' => ' ',
+        'type' => 'empty_spaces_after_command'},
+        @{$node_tree->{'contents'}});
+    if ($appended_number) {
+      splice (@{$node_arg->{'contents'}}, -1, 0,
+                  {'text' => " $appended_number"});
+    }
+    foreach my $content (@{$node_arg->{'contents'}}) {
+      $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'} !~ /[^-]/);
+    push @{$node->{'extra'}->{'nodes_manuals'}}, $parsed_node;
+  }
+
+  Texinfo::Parser::_register_label($self, $node, $parsed_node, undef);
+  push @{$self->{'nodes'}}, $node;
+  return $node;
+}
+
+
 sub _sort_string($$)
 {
   my $a = shift;

Index: t/automatic_nodes.t
===================================================================
RCS file: t/automatic_nodes.t
diff -N t/automatic_nodes.t
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ t/automatic_nodes.t 24 Feb 2012 00:02:41 -0000      1.1
@@ -0,0 +1,44 @@
+use strict;
+
+use Test::More;
+BEGIN { plan tests => 7 };
+
+use lib 'maintain/lib/Unicode-EastAsianWidth/lib/';
+use lib 'maintain/lib/libintl-perl/lib/';
+use lib 'maintain/lib/Text-Unidecode/lib/';
+use Texinfo::Parser qw(parse_texi_text);
+use Texinfo::Structuring;
+use Texinfo::Convert::Texinfo;
+
+use Data::Dumper;
+
+ok(1);
+
+sub test_new_node($$$$)
+{
+  my $in = shift;
+  my $normalized_ref = shift;
+  my $out = shift;
+  my $name = shift;
+
+  my $parser = Texinfo::Parser::parser();
+  my $line = $parser->parse_texi_line ($in);
+  my $node = Texinfo::Structuring::_new_node($parser, $line);
+  my $texi_result = Texinfo::Convert::Texinfo::convert($node);
+  my $normalized = $node->{'extra'}->{'normalized'};
+  my $labels = $parser->labels_information();
+  my @labels = keys(%$labels);
+  ok ((scalar(@labels) == 1 and $labels[0] eq $normalized), "$name label");
+  if (!defined($normalized_ref)) {
+    print STDERR " --> $name($normalized): $texi_result";
+  } else {
+    is ($normalized_ref, $normalized, "$name normalized");
+    is ($texi_result, $out, $name);
+  }
+}
+
+test_new_node ('a node', 'a-node', '@node a node
+', 'simple');
+test_new_node ('a node @code{in code} @c comment
+', 'a-node-in-code-', '@node a node @code{in code} @c comment
+', 'complex');



reply via email to

[Prev in Thread] Current Thread [Next in Thread]