texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * Pod-Simple-Texinfo/pod2texi.pl (_fix_texinfo_tr


From: Patrice Dumas
Subject: branch master updated: * Pod-Simple-Texinfo/pod2texi.pl (_fix_texinfo_tree) tp/texi2any.pl, tp/Texinfo/Common.pm (register_label, set_nodes_list_labels), tp/Texinfo/ParserNonXS.pm (labels_information, _register_label) (_end_line, _parse_texi), tp/Texinfo/XS/parsetexi/Parsetexi.pm (_complete_node_menus) (get_parser_info, parse_texi_line, labels_information) tp/Texinfo/Structuring.pm (_check_menu_entry) (_check_referenced_nodes, check_nodes_are_referenced) (set_menus_node_directions, complete_node_tree_with_menus) [...]
Date: Sat, 28 Aug 2021 16:34:32 -0400

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new c6e4d10  * Pod-Simple-Texinfo/pod2texi.pl (_fix_texinfo_tree) 
tp/texi2any.pl, tp/Texinfo/Common.pm (register_label, set_nodes_list_labels), 
tp/Texinfo/ParserNonXS.pm (labels_information, _register_label) (_end_line, 
_parse_texi), tp/Texinfo/XS/parsetexi/Parsetexi.pm (_complete_node_menus) 
(get_parser_info, parse_texi_line, labels_information) 
tp/Texinfo/Structuring.pm (_check_menu_entry) (_check_referenced_nodes, 
check_nodes_are_referenced) (set_menus_node_directions, complete_no [...]
c6e4d10 is described below

commit c6e4d10b83dfd53f523c60f49024d717a9b4e8e5
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Aug 28 22:31:50 2021 +0200

    * Pod-Simple-Texinfo/pod2texi.pl (_fix_texinfo_tree)
    tp/texi2any.pl,
    tp/Texinfo/Common.pm (register_label, set_nodes_list_labels),
    tp/Texinfo/ParserNonXS.pm (labels_information, _register_label)
    (_end_line, _parse_texi),
    tp/Texinfo/XS/parsetexi/Parsetexi.pm (_complete_node_menus)
    (get_parser_info, parse_texi_line, labels_information)
    tp/Texinfo/Structuring.pm (_check_menu_entry)
    (_check_referenced_nodes, check_nodes_are_referenced)
    (set_menus_node_directions, complete_node_tree_with_menus)
    (nodes_tree, associate_internal_references),
    tp/Texinfo/Transformations.pm (_new_node)
    (insert_nodes_for_sectioning_commands, _print_down_menus)
    (new_master_menu, regenerate_master_menu, set_menus_to_simple_menu),
    tp/Texinfo/Convert/Converter.pm (converter):
    Rename labels_information() as set_nodes_list_labels() in
    Texinfo::Common, do not remove the 'labels' and always set
    'targets'.  Always call that function from the parsers.
    Have labels_information() return 'targets' list and 'nodes'
    list too.
    Use what is returned by labels_information() instead of a parser
    or converter in Texinfo::Structuring and Texinfo::Transform
    functions to access 'labels', 'targets' and 'nodes'.
    Move the definition of Texinfo::ParserNonXS _register_label
    as register_label in Texinfo::Common and use the 'labels'
    list in argument instead of the parser.
    Separate _check_referenced_nodes from complete_node_tree_with_menus
    and rename as check_nodes_are_referenced.
    
    * tp/Texinfo/Common.pm (%default_structure_customization_values):
    remove USE_UP_NODE_FOR_ELEMENT_UP, it is used from converter.
---
 ChangeLog                            | 34 +++++++++++++
 Pod-Simple-Texinfo/pod2texi.pl       | 13 +++--
 tp/Texinfo/Common.pm                 | 38 ++++++++++-----
 tp/Texinfo/Convert/Converter.pm      |  3 +-
 tp/Texinfo/ParserNonXS.pm            | 30 ++++++------
 tp/Texinfo/Structuring.pm            | 95 +++++++++++++++++++++---------------
 tp/Texinfo/Transformations.pm        | 58 ++++++++++++----------
 tp/Texinfo/XS/parsetexi/Parsetexi.pm | 23 ++++++---
 tp/t/automatic_menus.t               | 10 ++--
 tp/t/automatic_nodes.t               | 46 +++++++++++------
 tp/t/do_master_menu.t                | 24 ++++++---
 tp/t/test_utils.pl                   | 18 +++++--
 tp/texi2any.pl                       | 30 +++++++++---
 13 files changed, 282 insertions(+), 140 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 06a9afd..66f3a26 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,40 @@
 
 2021-08-28  Patrice Dumas  <pertusus@free.fr>
 
+       * Pod-Simple-Texinfo/pod2texi.pl (_fix_texinfo_tree)
+       tp/texi2any.pl,
+       tp/Texinfo/Common.pm (register_label, set_nodes_list_labels),
+       tp/Texinfo/ParserNonXS.pm (labels_information, _register_label)
+       (_end_line, _parse_texi),
+       tp/Texinfo/XS/parsetexi/Parsetexi.pm (_complete_node_menus)
+       (get_parser_info, parse_texi_line, labels_information)
+       tp/Texinfo/Structuring.pm (_check_menu_entry)
+       (_check_referenced_nodes, check_nodes_are_referenced)
+       (set_menus_node_directions, complete_node_tree_with_menus)
+       (nodes_tree, associate_internal_references),
+       tp/Texinfo/Transformations.pm (_new_node)
+       (insert_nodes_for_sectioning_commands, _print_down_menus)
+       (new_master_menu, regenerate_master_menu, set_menus_to_simple_menu),
+       tp/Texinfo/Convert/Converter.pm (converter):
+       Rename labels_information() as set_nodes_list_labels() in
+       Texinfo::Common, do not remove the 'labels' and always set
+       'targets'.  Always call that function from the parsers.
+       Have labels_information() return 'targets' list and 'nodes'
+       list too.
+       Use what is returned by labels_information() instead of a parser
+       or converter in Texinfo::Structuring and Texinfo::Transform
+       functions to access 'labels', 'targets' and 'nodes'.
+       Move the definition of Texinfo::ParserNonXS _register_label
+       as register_label in Texinfo::Common and use the 'labels'
+       list in argument instead of the parser.
+       Separate _check_referenced_nodes from complete_node_tree_with_menus
+       and rename as check_nodes_are_referenced.
+
+       * tp/Texinfo/Common.pm (%default_structure_customization_values):
+       remove USE_UP_NODE_FOR_ELEMENT_UP, it is used from converter.
+
+2021-08-28  Patrice Dumas  <pertusus@free.fr>
+
        * tp/Texinfo/ParserNonXS.pm(_parse_def, _end_line): put
        information about documentlanguage into the tree only if defined.
 
diff --git a/Pod-Simple-Texinfo/pod2texi.pl b/Pod-Simple-Texinfo/pod2texi.pl
index 4e99332..d5e987a 100755
--- a/Pod-Simple-Texinfo/pod2texi.pl
+++ b/Pod-Simple-Texinfo/pod2texi.pl
@@ -238,6 +238,7 @@ sub _fix_texinfo_tree($$$$;$)
 
   my $parser = Texinfo::Parser::parser();
   my $tree = $parser->parse_texi_text($manual_texi);
+  my ($labels, $targets_list, $nodes_list) = $parser->labels_information();
 
   if ($fill_gaps_in_sectioning) {
     my ($added_sections, $added_nodes);
@@ -247,7 +248,8 @@ sub _fix_texinfo_tree($$$$;$)
     # new nodes should only be created for the $added_sections.
     if ($section_nodes) {
       ($tree->{'contents'}, $added_nodes)
-        = 
Texinfo::Transformations::insert_nodes_for_sectioning_commands($parser, $tree);
+        = 
Texinfo::Transformations::insert_nodes_for_sectioning_commands($parser,
+                                  $tree, $nodes_list, $targets_list, $labels);
       if ($self and $self->texinfo_sectioning_base_level > 0) {
         # prepend the manual name
         foreach my $node (@$added_nodes) {
@@ -274,10 +276,10 @@ sub _fix_texinfo_tree($$$$;$)
             $content->{'parent'} = $node_arg;
           }
           # Last parse and register node
-          my $parsed_node = Texinfo::Parser::_parse_node_manual($node_arg);
+          my $parsed_node = Texinfo::Common::parse_node_manual($node_arg);
           #push @{$node->{'extra'}->{'nodes_manuals'}}, $parsed_node;
           @{$node->{'extra'}->{'nodes_manuals'}} = ($parsed_node);
-          Texinfo::Parser::_register_label($parser, $node, $parsed_node);
+          Texinfo::Common::register_label($parser, $node, $parsed_node);
         }
       }
     }
@@ -285,7 +287,8 @@ sub _fix_texinfo_tree($$$$;$)
   my $structure = Texinfo::Structuring::sectioning_structure($parser, $tree);
   Texinfo::Transformations::complete_tree_nodes_menus($parser, $tree) 
     if ($section_nodes);
-  Texinfo::Transformations::regenerate_master_menu($parser) if 
($do_master_menu);
+  Texinfo::Transformations::regenerate_master_menu($parser, $labels)
+     if ($do_master_menu);
   return ($parser, $tree);
 }
 
@@ -305,7 +308,7 @@ sub _do_top_node_menu($)
 {
   my $manual_texi = shift;
   my ($parser, $tree) = _fix_texinfo_tree(undef, $manual_texi, 1, 0, 1); 
-  my $labels = $parser->labels_information();
+  my ($labels, $targets_list, $nodes_list) = $parser->labels_information();
   my $top_node_menu = $labels->{'Top'}->{'menus'}->[0];
   if ($top_node_menu) {
     return Texinfo::Convert::Texinfo::convert_to_texinfo($top_node_menu);
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 9b5b3e7..b532353 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -121,8 +121,6 @@ our %default_parser_customization_values = (
 # default values.
 our %default_structure_customization_values = (
   # following are used in Texinfo::Structuring
-  'USE_UP_NODE_FOR_ELEMENT_UP' => 0, # Use node up for Up if there is no 
-                                     # section up.
   'CHECK_NORMAL_MENU_STRUCTURE' => 0, # output warnings when node with
             # automatic direction does directions in menu are not consistent
             # with sectionning, and when node directions are not consistent
@@ -2634,7 +2632,20 @@ sub print_tree($)
 
 # common parser functions
 
-sub _non_bracketed_contents {
+# register a label, that is something that may be the target of a reference
+# and must be unique in the document.  Corresponds to @node, @anchor and
+# @float second arg.
+sub register_label($$$)
+{
+  my ($targets_list, $current, $label) = @_;
+
+  push @{$targets_list}, $current;
+  if ($label->{'node_content'}) {
+    $current->{'extra'}->{'node_content'} = $label->{'node_content'};
+  }
+}
+
+sub _non_bracketed_contents($) {
   my $current = shift;
 
   if ($current->{'type'} and $current->{'type'} eq 'bracketed') {
@@ -2672,7 +2683,8 @@ sub complete_indices {
             and $def_command) {
           # Use the document language that was current when the command was
           # used for getting the translation.
-          $self->{'documentlanguage'} = 
$entry->{'command'}->{'extra'}->{'documentlanguage'};
+          $self->{'documentlanguage'}
+             = $entry->{'command'}->{'extra'}->{'documentlanguage'};
           delete $entry->{'command'}->{'extra'}->{'documentlanguage'};
           if ($def_command eq 'defop'
               or $def_command eq 'deftypeop'
@@ -2714,18 +2726,23 @@ sub complete_indices {
 }
 
 # Called from Texinfo::ParserNonXS and Texinfo::XS::parsetexi::Parsetexi.
-sub labels_information
+# This should be considered an internal function of the parsers for all
+# purposes, it is here to avoid code duplication.
+# Sets $self->{'nodes'} and $self->{'labels'} based on $self->{'targets'}.
+sub set_nodes_list_labels($)
 {
   my $self = shift;
+  $self->{'nodes'} = [];
+  my %labels = ();
   if (defined $self->{'targets'}) {
-    my %labels = ();
     for my $target (@{$self->{'targets'}}) {
       if ($target->{'cmdname'} eq 'node') {
         if ($target->{'extra'}->{'nodes_manuals'}) {
           for my $node_manual (@{$target->{'extra'}{'nodes_manuals'}}) {
             if (defined $node_manual
                   and defined $node_manual->{'node_content'}) {
-              my $normalized = 
Texinfo::Convert::NodeNameNormalization::normalize_node({'contents' => 
$node_manual->{'node_content'}});
+              my $normalized = 
Texinfo::Convert::NodeNameNormalization::normalize_node(
+                                    {'contents' => 
$node_manual->{'node_content'}});
               $node_manual->{'normalized'} = $normalized;
             }
           }
@@ -2733,7 +2750,8 @@ sub labels_information
       }
       if (defined $target->{'extra'}
             and defined $target->{'extra'}->{'node_content'}) {
-        my $normalized = 
Texinfo::Convert::NodeNameNormalization::normalize_node({'contents' => 
$target->{'extra'}->{'node_content'}});
+        my $normalized = 
Texinfo::Convert::NodeNameNormalization::normalize_node(
+                             {'contents' => 
$target->{'extra'}->{'node_content'}});
 
         if ($normalized !~ /[^-]/) {
           $self->line_error (sprintf(__("empty node name after expansion 
`%s'"),
@@ -2775,10 +2793,8 @@ sub labels_information
         }
       }
     }
-    $self->{'labels'} = \%labels;
-    delete $self->{'targets'};
   }
-  return $self->{'labels'};
+  $self->{'labels'} = \%labels;
 }
 
 1;
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index a4ef0e9..401f2b2 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -206,7 +206,8 @@ sub converter(;$)
          = $converter->{'parser'}->global_commands_information();
       $converter->{'info'} = $converter->{'parser'}->global_informations();
       my $floats = $converter->{'parser'}->floats_information();
-      my $labels = $converter->{'parser'}->labels_information();
+      my ($labels, $targets_list, $nodes_list)
+        = $converter->{'parser'}->labels_information();
       $converter->{'structuring'} = $converter->{'parser'}->{'structuring'};
 
       $converter->{'floats'} = $floats if ($floats);
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 80d2820..ec3b502 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -1030,10 +1030,10 @@ sub global_informations($)
   return $self->{'info'};
 }
 
-# Setup labels and nodes info and return labels
-sub labels_information
+sub labels_information($)
 {
-  goto &Texinfo::Common::labels_information;
+  my $self = shift;
+  return $self->{'labels'}, $self->{'targets'}, $self->{'nodes'};
 }
 
 # Following are the internal subroutines.  The most important are
@@ -2493,12 +2493,9 @@ sub _parse_def($$$)
 # @float second arg.
 sub _register_label($$$)
 {
-  my ($self, $current, $label) = @_;
+  my ($targets_list, $current, $label) = @_;
 
-  push @{$self->{'targets'}}, $current;
-  if ($label->{'node_content'}) {
-    $current->{'extra'}->{'node_content'} = $label->{'node_content'};
-  }
+  Texinfo::Common::register_label($targets_list, $current, $label);
 }
 
 # store an index entry.
@@ -2887,7 +2884,7 @@ sub _end_line($$$)
         $float_label = _parse_node_manual($current->{'args'}->[1]);
         _check_internal_node($self, $float_label, $line_nr);
       }
-      _register_label($self, $current, $float_label);
+      _register_label($self->{'targets'}, $current, $float_label);
       _parse_float_type($current);
       $type = $current->{'extra'}->{'type'}->{'normalized'};
       push @{$self->{'floats'}->{$type}}, $current;
@@ -3168,7 +3165,7 @@ sub _end_line($$$)
       }
       _check_internal_node($self, $current->{'extra'}->{'nodes_manuals'}->[0],
                            $line_nr);
-     _register_label($self, $current, 
+     _register_label($self->{'targets'}, $current,
                    $current->{'extra'}->{'nodes_manuals'}->[0]);
      $self->{'current_node'} = $current;
     } elsif ($command eq 'listoffloats') {
@@ -5052,7 +5049,8 @@ sub _parse_texi($;$)
               my $parsed_anchor = _parse_node_manual($current);
               if (_check_node_label($self, $parsed_anchor,
                                 $current->{'parent'}->{'cmdname'}, $line_nr)) {
-                _register_label($self, $current->{'parent'}, $parsed_anchor);
+                _register_label($self->{'targets'}, $current->{'parent'},
+                                $parsed_anchor);
                 if (@{$self->{'regions_stack'}}) {
                   $current->{'extra'}->{'region'} = 
$self->{'regions_stack'}->[-1];
                 }
@@ -5449,8 +5447,8 @@ sub _parse_texi($;$)
     $self->_init_context_stack(1);
   }
 
-  # Call 'labels_information' to initialize labels.
-  my $labels = labels_information($self);
+  # Setup labels info and nodes list based on 'targets'
+  Texinfo::Common::set_nodes_list_labels($self);
   Texinfo::Common::complete_indices($self);
   return $root;
 }
@@ -5884,7 +5882,7 @@ Texinfo::Parser - Parse Texinfo code into a Perl tree
   my $internal_references_array
     = $parser->internal_references_information();
   # An hash reference on normalized node/float/anchor names
-  my $labels_information = $parser->labels_information();
+  my ($labels_information, $targets_list, $nodes_list) = 
$parser->labels_information();
   # A hash reference, keys are @-command names, value is an 
   # array reference holding all the corresponding @-commands.
   my $global_commands_information = $parser->global_commands_information();
@@ -6106,10 +6104,12 @@ the association with @-commands is available through 
C<labels_information>:
 
 =over
 
-=item $labels_information = labels_information($parser)
+=item $labels_information, $targets_list = labels_information($parser)
 
 I<$labels_information> is a hash reference whose keys are normalized
 labels, and the associated value is the corresponding @-command.
+I<$targets_list> is a list of labels @-command.  Using
+I<$labels_information> is preferred.
 
 =back
 
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index 247863c..32facab 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -45,6 +45,8 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 %EXPORT_TAGS = ( 'all' => [ qw(
   associate_internal_references
+  check_nodes_are_referenced
+  complete_node_tree_with_menus
   elements_directions
   elements_file_directions
   merge_indices
@@ -371,16 +373,17 @@ my %direction_texts = (
  'up' => 'Up'
 );
 
-sub _check_menu_entry($$$)
+sub _check_menu_entry($$$$)
 {
   my $self = shift;
+  my $labels = shift;
   my $command = shift;
   my $menu_content = shift;
 
   my $normalized_menu_node
       = $menu_content->{'extra'}->{'menu_entry_node'}->{'normalized'};
 
-  my $menu_node = $self->{'labels'}->{$normalized_menu_node};
+  my $menu_node = $labels->{$normalized_menu_node};
 
   if (!$menu_node) {
     $self->line_error(sprintf(
@@ -401,12 +404,16 @@ sub _check_menu_entry($$$)
   }
 }
 
-sub _check_referenced_nodes
+# In general should be called only after complete_node_tree_with_menus
+# to try to generate menus automatically before checking.
+sub check_nodes_are_referenced
 {
-  my ($self, $top_node) = @_;
+  my ($self, $nodes_list, $top_node, $labels, $refs) = @_;
+
+  return undef unless ($nodes_list and scalar(@{$nodes_list}));
 
   my %referenced_nodes = ($top_node => 1);
-  foreach my $node (@{$self->{'nodes'}}) {
+  foreach my $node (@{$nodes_list}) {
     # gather referenced nodes based on node pointers
     foreach my $direction (@node_directions) {
       if ($node->{'node_'.$direction}
@@ -420,8 +427,6 @@ sub _check_referenced_nodes
   }
 
   # consider nodes in @*ref commands to be referenced
-  my $labels = $self->labels_information();
-  my $refs = $self->internal_references_information();
   if (defined($refs)) {
     foreach my $ref (@$refs) {
       my $node_arg = $ref->{'extra'}{'node_argument'};
@@ -437,7 +442,7 @@ sub _check_referenced_nodes
     }
   }
 
-  foreach my $node (@{$self->{'nodes'}}) {
+  foreach my $node (@{$nodes_list}) {
     if (not exists($referenced_nodes{$node})) {
       $self->line_warn(sprintf(__("node `%s' unreferenced"),
           node_extra_to_texi($node->{'extra'})),
@@ -447,10 +452,13 @@ sub _check_referenced_nodes
 }
 
 # set menu directions
-sub set_menus_node_directions($)
+sub set_menus_node_directions($$$)
 {
   my $self = shift;
-  return undef unless ($self->{'nodes'} and @{$self->{'nodes'}});
+  my $nodes_list = shift;
+  my $labels = shift;
+
+  return undef unless ($nodes_list and scalar(@{$nodes_list}));
 
   my $check_menu_entries = (!$self->{'info'}->{'novalidate'}
                       and $self->get_conf('FORMAT_MENU') eq 'menu');
@@ -462,7 +470,7 @@ sub set_menus_node_directions($)
   # another command such as @format, may be treated slightly
   # differently; at least, there are no error messages for them.
   #
-  foreach my $node (@{$self->{'nodes'}}) {
+  foreach my $node (@{$nodes_list}) {
     if ($node->{'menus'}) {
       if (@{$node->{'menus'}} > 1) {
         foreach my $menu (@{$node->{'menus'}}[1 .. $#{$node->{'menus'}}]) {
@@ -478,12 +486,12 @@ sub set_menus_node_directions($)
             my $menu_node;
             my $external_node;
             if 
(!$menu_content->{'extra'}->{'menu_entry_node'}->{'manual_content'}) {
-              $menu_node = $self->{'labels'}->{
+              $menu_node = $labels->{
                       $menu_content->{'extra'}
                                    ->{'menu_entry_node'}->{'normalized'}};
 
               if ($check_menu_entries) {
-                _check_menu_entry($self, 'menu', $menu_content);
+                _check_menu_entry($self, $labels, 'menu', $menu_content);
               }
               # this may happen more than once for a given node if the node 
               # is in more than one menu.  Therefore all the menu up node 
@@ -523,7 +531,7 @@ sub set_menus_node_directions($)
           if ($menu_content->{'extra'}
              and $menu_content->{'extra'}->{'menu_entry_node'}) {
             if 
(!$menu_content->{'extra'}->{'menu_entry_node'}->{'manual_content'}) {
-              _check_menu_entry($self, 'detailmenu', $menu_content);
+              _check_menu_entry($self, $labels, 'detailmenu', $menu_content);
             }
           }
         }
@@ -557,14 +565,15 @@ sub _section_direction_associated_node($$)
 # complete automatic directions with menus (and first node
 # for Top node).
 # Checks on structure related to menus.
-sub complete_node_tree_with_menus($$)
+sub complete_node_tree_with_menus($$$)
 {
   my $self = shift;
+  my $nodes_list = shift;
   my $top_node = shift;
 
-  return undef unless ($self->{'nodes'} and @{$self->{'nodes'}});
+  return undef unless ($nodes_list and @{$nodes_list});
   # Go through all the nodes
-  foreach my $node (@{$self->{'nodes'}}) {
+  foreach my $node (@{$nodes_list}) {
     my $automatic_directions =
       (scalar(@{$node->{'extra'}->{'nodes_manuals'}}) == 1);
 
@@ -634,7 +643,7 @@ sub complete_node_tree_with_menus($$)
           }
         } else {
           # use the first non top node as next for Top
-          foreach my $first_non_top_node (@{$self->{'nodes'}}) {
+          foreach my $first_non_top_node (@{$nodes_list}) {
             if ($first_non_top_node ne $node) {
               $node->{'node_next'} = $first_non_top_node;
               if (scalar(@{$first_non_top_node->{'extra'}->{'nodes_manuals'}}) 
== 1) {
@@ -686,19 +695,20 @@ sub complete_node_tree_with_menus($$)
       # FIXME check that node_up is not an external node (except for Top)?
     }
   }
-  _check_referenced_nodes($self, $top_node);
 }
 
 
 # set node directions based on sectioning and @node explicit directions
-sub nodes_tree($)
+sub nodes_tree($$$)
 {
   my $self = shift;
-  return undef unless ($self->{'nodes'} and @{$self->{'nodes'}});
+  my $nodes_list = shift;
+  my $labels = shift;
+  return undef unless ($nodes_list and @{$nodes_list});
 
   my $top_node;
   # Go through all the nodes and set directions.
-  foreach my $node (@{$self->{'nodes'}}) {
+  foreach my $node (@{$nodes_list}) {
     if ($node->{'extra'}->{'normalized'} eq 'Top') {
       $top_node = $node;
     }
@@ -754,9 +764,9 @@ sub nodes_tree($)
         if ($node_direction->{'manual_content'}) {
           $node->{'node_'.$direction} = { 'extra' => $node_direction };
         } else {
-          if ($self->{'labels'}->{$node_direction->{'normalized'}}) {
+          if ($labels->{$node_direction->{'normalized'}}) {
             my $node_target 
-               = $self->{'labels'}->{$node_direction->{'normalized'}};
+               = $labels->{$node_direction->{'normalized'}};
             $node->{'node_'.$direction} = $node_target;
 
             if (!$self->{'info'}->{'novalidate'}
@@ -785,7 +795,7 @@ sub nodes_tree($)
       }
     }
   }
-  $top_node = $self->{'nodes'}->[0] if (!$top_node);
+  $top_node = $nodes_list->[0] if (!$top_node);
   $self->{'structuring'}->{'top_node'} = $top_node;
 
   return $top_node;
@@ -1275,12 +1285,12 @@ sub _unsplit($)
 
 # For each internal reference command, set the 'label' key in the 'extra' 
 # hash of the reference tree element to the associated labeled tree element.
-sub associate_internal_references($)
+sub associate_internal_references($$$)
 {
   my $self = shift;
+  my $labels = shift;
+  my $refs = shift;
 
-  my $labels = $self->labels_information();
-  my $refs = $self->internal_references_information();
   return if (!defined($refs));
   foreach my $ref (@$refs) {
     my $node_arg;
@@ -1731,11 +1741,15 @@ Texinfo::Structuring - information on Texinfo::Parser 
tree
     elements_file_directions);
   # $tree is a Texinfo document tree.  $parser is a Texinfo::Parser object.
   my $sections_root = sectioning_structure ($parser, $tree);
-  set_menus_node_directions($parser);
-  my $top_node = nodes_tree($parser);
-  complete_node_tree_with_menus($parser, $top_node);
+  my $nodes_list = $parser->nodes_list();
+  my $labels = $parser->labels_information();
+  set_menus_node_directions($parser, $nodes_list, $labels);
+  my $top_node = nodes_tree($parser, $nodes_list, $labels);
+  complete_node_tree_with_menus($parser, $nodes_list, $top_node);
+  my $refs = $parser->internal_references_information();
+  check_nodes_are_referenced($parser, $nodes_list, $top_node, $labels, $refs);
   number_floats($parser->floats_information());
-  associate_internal_references($parser);
+  associate_internal_references($parser, $labels, $refs);
   my $elements;
   if ($split_at_nodes) {
     $elements = split_by_node($tree);
@@ -1849,7 +1863,7 @@ account C<@part> elements.
 
 =back
 
-=item set_menus_node_directions($parser)
+=item set_menus_node_directions($parser, $nodes_list, $labels)
 
 Goes through menu and set directions.
 
@@ -1871,7 +1885,7 @@ Up, next and previous directions as set in menus.
 
 =back
 
-=item my $top_node = nodes_tree($parser)
+=item my $top_node = nodes_tree($parser, $nodes_list, $labels)
 
 Goes through nodes and set directions.  Returns the top
 node.
@@ -1890,18 +1904,23 @@ Up, next and previous directions for the node.
 
 =back
 
-=item complete_node_tree_with_menus($parser, $top_node)
+=item complete_node_tree_with_menus($parser, $nodes_list, $top_node)
 
 Complete nodes directions with menu directions.  Check consistency
-of menus, sectionning and nodes direction structures.  Check that
-all the nodes are referenced (in menu, @*ref or node direction).
+of menus, sectionning and nodes direction structures.
+
+=item check_nodes_are_referenced($parser, $nodes_list, $top_node, $labels, 
$refs)
+
+Check that all the nodes are referenced (in menu, @*ref or node direction).
+Should be called after C<complete_node_tree_with_menus> in order to
+have the autogenerated menus available.
 
 =item number_floats($float_information)
 
 Number the floats as described in the Texinfo manual.  Sets
 the I<number> key of the float tree elements.
 
-=item associate_internal_references($parser)
+=item associate_internal_references($parser, $labels, $refs)
 
 Verify that internal references (C<@ref> and similar without
 fourth of fifth argument) have an associated node, anchor or float.
diff --git a/tp/Texinfo/Transformations.pm b/tp/Texinfo/Transformations.pm
index b50d951..b805eed 100644
--- a/tp/Texinfo/Transformations.pm
+++ b/tp/Texinfo/Transformations.pm
@@ -188,10 +188,14 @@ sub reference_to_arg_in_tree($$)
 }
 
 # prepare a new node
-sub _new_node($$)
+# modifies $nodes_list, $targets_list, $labels
+sub _new_node($$$$$)
 {
   my $self = shift;
   my $node_tree = shift;
+  my $nodes_list = shift;
+  my $targets_list = shift;
+  my $labels = shift;
 
   $node_tree = Texinfo::Common::protect_comma_in_tree($node_tree);
   $node_tree->{'contents'} 
@@ -218,8 +222,8 @@ sub _new_node($$)
   my ($node, $parsed_node);
 
   while (!defined($node) 
-         or ($self->{'labels'} 
-            and $self->{'labels'}->{$parsed_node->{'normalized'}})) {
+         or ($labels
+            and $labels->{$parsed_node->{'normalized'}})) {
     $node = {'cmdname' => 'node', 'args' => [{}]};
     my $node_arg = $node->{'args'}->[0];
     $node_arg->{'parent'} = $node;
@@ -254,14 +258,11 @@ sub _new_node($$)
 
   push @{$node->{'extra'}->{'nodes_manuals'}}, $parsed_node;
   if ($parsed_node->{'normalized'} ne '') {
-    $self->{'labels'}->{$parsed_node->{'normalized'}} = $node;
+    $labels->{$parsed_node->{'normalized'}} = $node;
     $node->{'extra'}->{'normalized'} = $parsed_node->{'normalized'};
   }
-  push @{$self->{'targets'}}, $node;
-  if ($parsed_node->{'node_content'}) {
-    $node->{'extra'}->{'node_content'} = $parsed_node->{'node_content'};
-  }
-  push @{$self->{'nodes'}}, $node;
+  Texinfo::Common::register_label($targets_list, $node, $parsed_node);
+  push @{$nodes_list}, $node;
   return $node;
 }
 
@@ -306,10 +307,15 @@ sub _reassociate_to_node($$$$)
   return ($current);
 }
 
-sub insert_nodes_for_sectioning_commands($$)
+# modifies $nodes_list, $targets_list, $labels
+sub insert_nodes_for_sectioning_commands($$$$$)
 {
   my $self = shift;
   my $root = shift;
+  my $nodes_list = shift;
+  my $targets_list = shift;
+  my $labels = shift;
+
   if (!$root->{'type'} or $root->{'type'} ne 'document_root'
       or !$root->{'contents'}) {
     return (undef, undef);
@@ -330,7 +336,8 @@ sub insert_nodes_for_sectioning_commands($$)
         $new_node_tree = Texinfo::Common::copy_tree({'contents' 
           => $content->{'args'}->[0]->{'contents'}});
       }
-      my $new_node = _new_node($self, $new_node_tree);
+      my $new_node = _new_node($self, $new_node_tree, $nodes_list,
+                               $targets_list, $labels);
       if (defined($new_node)) {
         push @contents, $new_node;
         push @added_nodes, $new_node;
@@ -505,8 +512,8 @@ sub _copy_contents($)
   return $copy->{'contents'};
 }
 
-sub _print_down_menus($$;$);
-sub _print_down_menus($$;$)
+sub _print_down_menus($$$);
+sub _print_down_menus($$$)
 {
   my $self = shift;
   my $node = shift;
@@ -567,11 +574,10 @@ sub _print_down_menus($$;$)
   return @master_menu_contents;
 }
 
-sub new_master_menu($;$)
+sub new_master_menu($$)
 {
   my $self = shift;
   my $labels = shift;
-  $labels = $self->labels_information() if (!defined($labels));
   my $node = $labels->{'Top'};
   return undef if (!defined($node));
 
@@ -608,11 +614,10 @@ sub new_master_menu($;$)
   }
 }
 
-sub regenerate_master_menu($;$)
+sub regenerate_master_menu($$)
 {
   my $self = shift;
   my $labels = shift;
-  $labels = $self->labels_information() if (!defined($labels));
   my $top_node = $labels->{'Top'};
   return undef if (!defined($top_node));
 
@@ -733,10 +738,10 @@ sub menu_to_simple_menu($)
 
 sub set_menus_to_simple_menu($)
 {
-  my $self = shift;
+  my $nodes_list = shift;
 
-  if ($self->{'nodes'} and @{$self->{'nodes'}}) {
-    foreach my $node (@{$self->{'nodes'}}) {
+  if ($nodes_list) {
+    foreach my $node (@{$nodes_list}) {
       if ($node->{'menus'}) {
         foreach my $menu (@{$node->{'menus'}}) {
           menu_to_simple_menu($menu);
@@ -795,19 +800,22 @@ C<@lowersection> added to some tree elements.
 
 =item menu_to_simple_menu ($menu)
 
-=item set_menus_to_simple_menu ($parser)
+=item set_menus_to_simple_menu ($nodes_list)
 
 C<menu_to_simple_menu> transforms the tree of a menu tree element.  
 C<set_menus_to_simple_menu> calls C<menu_to_simple_menu> for all the
-menus of the document.
+menus of the nodes in C<$nodes_list>.
 
 A simple menu has no I<menu_comment>, I<menu_entry> or 
I<menu_entry_description>
 container anymore, their content are merged directly in the menu in 
 I<preformatted> container.
 
-=item ($root_content, $added_nodes) = insert_nodes_for_sectioning_commands 
($parser, $tree)
+=item ($root_content, $added_nodes) = insert_nodes_for_sectioning_commands 
($parser, $tree, $nodes_list, $targets_list, $labels)
 
 Insert nodes for sectioning commands without node in C<$tree>.
+Add nodes to the labels used as targets for references C<$labels>
+and C<$targets_list> and to C<$nodes_list>.
+
 An array reference is returned, containing the root contents
 with added nodes, as well as an array reference containing the 
 added nodes.
@@ -828,11 +836,11 @@ C<$add_section_names_in_entries> argument is set, a menu 
entry
 name is added using the section name.  This function should be
 called after L<sectioning_structure>.
 
-=item $detailmenu = new_master_menu ($parser)
+=item $detailmenu = new_master_menu ($parser, $labels)
 
 Returns a detailmenu tree element formatted as a master node.
 
-=item regenerate_master_menu ($parser)
+=item regenerate_master_menu ($parser, $labels)
 
 Regenerate the Top node master menu, replacing the first detailmenu
 in Top node menus or appending at the end of the Top node menu.
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm 
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index 5ee1851..890347e 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -157,9 +157,6 @@ sub _complete_node_menus {
   my $self = shift;
   my $root = shift;
 
-  if (!defined $self->{'nodes'}) {
-    $self->{'nodes'} = [];
-  }
   my $node;
   foreach my $child (@{$root->{'contents'}}) {
     if ($child->{'cmdname'} and $child->{'cmdname'} eq 'node') {
@@ -186,7 +183,6 @@ sub get_parser_info {
   $GLOBAL_INFO2 = build_global_info2 ();
 
   $self->{'targets'} = $TARGETS;
-  $self->{'labels'} = {};
   $self->{'internal_references'} = $INTL_XREFS;
   $self->{'floats'} = $FLOATS;
   $self->{'info'} = $GLOBAL_INFO;
@@ -207,6 +203,9 @@ sub get_parser_info {
   }
 
   _get_errors ($self);
+
+  # Setup labels info and nodes list based on 'targets'
+  Texinfo::Common::set_nodes_list_labels($self);
   Texinfo::Common::complete_indices ($self);
 }
 
@@ -258,6 +257,7 @@ sub parse_texi_file ($$)
 
   my $TREE = build_texinfo_tree ();
   get_parser_info ($self);
+
   _complete_node_menus ($self, $TREE);
 
   my $text_root;
@@ -331,6 +331,7 @@ sub parse_texi_text($$;$$$$)
 
     get_parser_info($self);
     _complete_node_menus ($self, $tree);
+
     return $tree;
 }
 
@@ -351,6 +352,16 @@ sub parse_texi_line($$;$$$$)
     parse_string($text);
     my $tree = build_texinfo_tree ();
     _get_errors ($self);
+
+    # It is unclear if it is an error to have targets set in parse_texi_line.
+    # We nevertheless set targets and other infos to do the same as in
+    # ParserNonXS.
+    my $TARGETS = build_label_list ();
+    $self->{'targets'} = $TARGETS;
+
+    # Setup labels info and nodes list based on 'targets'
+    Texinfo::Common::set_nodes_list_labels($self);
+
     return $tree;
 }
 
@@ -391,10 +402,10 @@ sub global_informations($)
   return $self->{'info'};
 }
 
-# Setup labels and nodes info and return labels
 sub labels_information($)
 {
-  goto &Texinfo::Common::labels_information;
+  my $self = shift;
+  return $self->{'labels'}, $self->{'targets'}, $self->{'nodes'};
 }
 
 1;
diff --git a/tp/t/automatic_menus.t b/tp/t/automatic_menus.t
index bc72656..da86f92 100644
--- a/tp/t/automatic_menus.t
+++ b/tp/t/automatic_menus.t
@@ -24,13 +24,15 @@ sub test($$$;$)
 
   my $parser = Texinfo::Parser::parser();
   my $tree = $parser->parse_texi_text($in);
-  $parser->Texinfo::Structuring::associate_internal_references();
-  my $sectioning = $parser->Texinfo::Structuring::sectioning_structure($tree);
+  my ($labels, $targets_list, $nodes_list) = $parser->labels_information();
+  my $refs = $parser->internal_references_information();
+  Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
+  my $sectioning = Texinfo::Structuring::sectioning_structure($parser, $tree);
   if ($complete_missing_menus) {
-    $parser->Texinfo::Transformations::complete_tree_nodes_missing_menu($tree);
+    Texinfo::Transformations::complete_tree_nodes_missing_menu($parser, $tree);
     #print STDERR "".Texinfo::Common::print_tree($tree)."\n";
   } else {
-    $parser->Texinfo::Transformations::complete_tree_nodes_menus($tree);
+    Texinfo::Transformations::complete_tree_nodes_menus($parser, $tree);
   }
   my $texi_result = Texinfo::Convert::Texinfo::convert_to_texinfo($tree);
 
diff --git a/tp/t/automatic_nodes.t b/tp/t/automatic_nodes.t
index b22c6ff..99e1efc 100644
--- a/tp/t/automatic_nodes.t
+++ b/tp/t/automatic_nodes.t
@@ -24,16 +24,23 @@ sub test_new_node($$$$)
 
   my $parser = Texinfo::Parser::parser();
   my $line = $parser->parse_texi_line ($in);
-  Texinfo::Structuring::associate_internal_references($parser);
-  my $node = Texinfo::Transformations::_new_node($parser, $line);
+  my ($labels, $targets_list, $nodes_list) = $parser->labels_information();
+  my $refs = $parser->internal_references_information();
+  Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
+  # $labels, $nodes_list, $targets_list are modified
+  my $node = Texinfo::Transformations::_new_node($parser, $line,
+                                          $nodes_list, $targets_list, $labels);
   
   my ($texi_result, $normalized);
   if (defined($node)) {
     $texi_result = Texinfo::Convert::Texinfo::convert_to_texinfo($node);
-    Texinfo::Structuring::associate_internal_references($parser);
+    my $refs = $parser->internal_references_information();
+    Texinfo::Structuring::associate_internal_references($parser, $labels, 
$refs);
     $normalized = $node->{'extra'}->{'normalized'};
-    my $labels = $parser->labels_information();
-    my @labels = keys(%$labels);
+    my @labels = sort(keys(%$labels));
+    if (scalar(@labels) != 1) {
+      print STDERR " $name labels: !! ".join("|", @labels)."\n";
+    }
     ok ((scalar(@labels) == 1 and $labels[0] eq $normalized), "$name label");
   }
   if (!defined($normalized_ref) and defined($normalized)) {
@@ -67,8 +74,11 @@ my $parser = Texinfo::Parser::parser();
 my $tree = $parser->parse_texi_text('@node a node
 ');
 my $line_tree = Texinfo::Parser::parse_texi_line (undef, 'a node');
-Texinfo::Structuring::associate_internal_references($parser);
-my $node = Texinfo::Transformations::_new_node($parser, $line_tree);
+my ($labels, $targets_list, $nodes_list) = $parser->labels_information();
+my $refs = $parser->internal_references_information();
+Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
+my $node = Texinfo::Transformations::_new_node($parser, $line_tree,
+                                        $nodes_list, $targets_list, $labels);
 is ('@node a node 1
 ',  Texinfo::Convert::Texinfo::convert_to_texinfo($node), 'duplicate node 
added');
 #print STDERR Texinfo::Convert::Texinfo::convert_to_texinfo($node);
@@ -138,8 +148,12 @@ Text.
 
   $parser = Texinfo::Parser::parser();
   $tree = $parser->parse_texi_text ($sections_text);
-  Texinfo::Structuring::associate_internal_references($parser);
-  my ($new_content, $added_nodes) = 
Texinfo::Transformations::insert_nodes_for_sectioning_commands($parser, $tree);
+  ($labels, $targets_list, $nodes_list) = $parser->labels_information();
+  $refs = $parser->internal_references_information();
+  Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
+  my ($new_content, $added_nodes)
+   = Texinfo::Transformations::insert_nodes_for_sectioning_commands($parser,
+                                   $tree, $nodes_list, $targets_list, $labels);
   $tree->{'contents'} = $new_content;
   my $result = Texinfo::Convert::Texinfo::convert_to_texinfo($tree);
   is ($reference, $result, 'add nodes');
@@ -157,12 +171,14 @@ $tree = $parser->parse_texi_text ('@node Top
 * (some_manual)::
 @end menu
 ');
-Texinfo::Structuring::associate_internal_references($parser);
+($labels, $targets_list, $nodes_list) = $parser->labels_information();
+$refs = $parser->internal_references_information();
+Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
 ($new_content, $added_nodes)
-   = Texinfo::Transformations::insert_nodes_for_sectioning_commands($parser, 
$tree);
+   = Texinfo::Transformations::insert_nodes_for_sectioning_commands($parser,
+                                 $tree, $nodes_list, $targets_list, $labels);
 $tree->{'contents'} = $new_content;
 my ($index_names, $merged_indices) = $parser->indices_information();
-my $labels = $parser->labels_information();
 ok (($labels->{'chap'}->{'menus'} and @{$labels->{'chap'}->{'menus'}}
      and scalar(@{$labels->{'chap'}->{'menus'}}) == 1
      and !exists($labels->{'Top'}->{'menus'})), 'new node has a menu');
@@ -190,10 +206,12 @@ is ($labels->{'chap'}, 
$index_names->{'cp'}->{'index_entries'}->[0]->{'node'},
 # ';
 # $tree = $parser->parse_texi_text ($text_duplicate_nodes);
 # # In fact, here we also check that there is no debugging message...
+# ($labels, $targets_list, $nodes_list) = $parser->labels_information();
 # ($new_content, $added_nodes)
-#    = Texinfo::Transformations::insert_nodes_for_sectioning_commands($parser, 
$tree);
+#    = Texinfo::Transformations::insert_nodes_for_sectioning_commands($parser,
+#                                $tree, $nodes_list, $targets_list, $labels);
 # ($index_names, $merged_indices) = $parser->indices_information();
-# $labels = $parser->labels_information();
+# ($labels, $targets_list, $nodes_list) = $parser->labels_information();
 # is ($labels->{'SEE-ALSO'}, 
$index_names->{'cp'}->{'index_entries'}->[0]->{'node'},
 #   'index entry reassociated duplicate node ignored');
 
diff --git a/tp/t/do_master_menu.t b/tp/t/do_master_menu.t
index ab36876..a8ecc05 100644
--- a/tp/t/do_master_menu.t
+++ b/tp/t/do_master_menu.t
@@ -123,8 +123,10 @@ my $no_detailmenu = _get_in('');
 
 my $parser = Texinfo::Parser::parser();
 my $tree = $parser->parse_texi_text($in_detailmenu);
-Texinfo::Structuring::associate_internal_references($parser);
-my $master_menu = Texinfo::Transformations::new_master_menu($parser);
+my ($labels, $targets_list, $nodes_list) = $parser->labels_information();
+my $refs = $parser->internal_references_information();
+Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
+my $master_menu = Texinfo::Transformations::new_master_menu($parser, $labels);
 my $out = Texinfo::Convert::Texinfo::convert_to_texinfo($master_menu);
 
 my $reference = '@detailmenu
@@ -163,15 +165,19 @@ is ($out, $reference, 'master menu');
 
 $parser = Texinfo::Parser::parser();
 $tree = $parser->parse_texi_text($no_detailmenu);
-Texinfo::Structuring::associate_internal_references($parser);
-$master_menu = Texinfo::Transformations::new_master_menu($parser);
+($labels, $targets_list, $nodes_list) = $parser->labels_information();
+$refs = $parser->internal_references_information();
+Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
+$master_menu = Texinfo::Transformations::new_master_menu($parser, $labels);
 $out = Texinfo::Convert::Texinfo::convert_to_texinfo($master_menu);
 is ($out, $reference, 'master menu no detailmenu');
 
 $parser = Texinfo::Parser::parser();
 $tree = $parser->parse_texi_text($in_detailmenu);
-Texinfo::Structuring::associate_internal_references($parser);
-Texinfo::Transformations::regenerate_master_menu($parser);
+($labels, $targets_list, $nodes_list) = $parser->labels_information();
+$refs = $parser->internal_references_information();
+Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
+Texinfo::Transformations::regenerate_master_menu($parser, $labels);
 $out = Texinfo::Convert::Texinfo::convert_to_texinfo($tree);
 
 is ($out, _get_in($reference), 'regenerate with existing detailmenu');
@@ -180,8 +186,10 @@ is ($out, _get_in($reference), 'regenerate with existing 
detailmenu');
 
 $parser = Texinfo::Parser::parser();
 $tree = $parser->parse_texi_text($no_detailmenu);
-Texinfo::Structuring::associate_internal_references($parser);
-Texinfo::Transformations::regenerate_master_menu($parser);
+($labels, $targets_list, $nodes_list) = $parser->labels_information();
+$refs = $parser->internal_references_information();
+Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
+Texinfo::Transformations::regenerate_master_menu($parser, $labels);
 $out = Texinfo::Convert::Texinfo::convert_to_texinfo($tree);
 
 is ($out, _get_in('',"\n".$reference), 'regenerate with no detailmenu');
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 41983d3..a337d5f 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -858,7 +858,9 @@ sub test($$)
   } else {
     $result = $parser->parse_texi_file($test_file);
   }
-  Texinfo::Structuring::associate_internal_references($parser);
+  my ($labels, $targets_list, $nodes_list) = $parser->labels_information();
+  my $refs = $parser->internal_references_information();
+  Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
   my $floats = $parser->floats_information();
 
   my $structure = Texinfo::Structuring::sectioning_structure($parser, $result);
@@ -868,10 +870,16 @@ sub test($$)
 
   Texinfo::Structuring::number_floats($floats);
 
-  Texinfo::Structuring::set_menus_node_directions($parser);
-  my $top_node = Texinfo::Structuring::nodes_tree($parser);
+  Texinfo::Structuring::set_menus_node_directions($parser, $nodes_list, 
$labels);
+  my $top_node = Texinfo::Structuring::nodes_tree($parser, $nodes_list, 
$labels);
 
-  Texinfo::Structuring::complete_node_tree_with_menus($parser, $top_node);
+  if (defined($nodes_list)) {
+    Texinfo::Structuring::complete_node_tree_with_menus($parser,
+                                                        $nodes_list, 
$top_node);
+    Texinfo::Structuring::check_nodes_are_referenced($parser,
+                                                     $nodes_list, $top_node,
+                                                     $labels, $refs);
+  }
 
   my ($errors, $error_nrs) = $parser->errors();
   my $index_names = $parser->indices_information();
@@ -896,7 +904,7 @@ sub test($$)
   if ($simple_menus) {
     # require instead of use for speed when this module is not needed
     require Texinfo::Transformations;
-    $parser->Texinfo::Transformations::set_menus_to_simple_menu();
+    Texinfo::Transformations::set_menus_to_simple_menu($nodes_list);
   }
 
   my $converted_text = Texinfo::Convert::Text::convert_to_text($result, 
{'TEST' => 1});
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 6a00af5..ceca263 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1116,7 +1116,11 @@ if (defined($formats_table{$format}->{'module'})) {
   # HTML
   %converter_defaults = $converter_class->converter_defaults($cmdline_options);
 
-  # set FORMAT_MENU to the output format default, if not nomenu
+  # set FORMAT_MENU to the output format default, if not nomenu. We do not
+  # simply let it be set by taking %converter_defaults values if not already 
set
+  # below in case the default $converter_defaults{'FORMAT_MENU'} is nomenu, but
+  # for the other cases we could simply unset 
$converter_defaults{'FORMAT_MENU'}
+  # and let the converter default value be
   if (defined(get_conf('FORMAT_MENU'))
       and get_conf('FORMAT_MENU') eq 'set_format_menu_from_cmdline_header') {
     if (defined($converter_defaults{'FORMAT_MENU'})
@@ -1233,10 +1237,12 @@ while(@input_files) {
       $tree->{'contents'} = $filled_contents;
     }
   }
+
+  my ($labels, $targets_list, $nodes_list) = $parser->labels_information();
   if ((get_conf('SIMPLE_MENU')
        and $formats_table{$format}->{'simple_menu'})
       or $tree_transformations{'simple_menus'}) {
-    $parser->Texinfo::Transformations::set_menus_to_simple_menu();
+    Texinfo::Transformations::set_menus_to_simple_menu($nodes_list);
   }
 
   if (defined(get_conf('MACRO_EXPAND')) and $file_number == 0) {
@@ -1283,7 +1289,8 @@ while(@input_files) {
 
   if ($tree_transformations{'insert_nodes_for_sectioning_commands'}) {
     my ($modified_contents, $added_nodes)
-     = Texinfo::Transformations::insert_nodes_for_sectioning_commands($parser, 
$tree);
+     = Texinfo::Transformations::insert_nodes_for_sectioning_commands($parser, 
+                              $tree, $nodes_list, $targets_list, $labels);
     if (!defined($modified_contents)) {
       document_warn(__(
        "insert_nodes_for_sectioning_commands transformation return no result. 
No section?"));
@@ -1292,7 +1299,8 @@ while(@input_files) {
     }
   }
 
-  Texinfo::Structuring::associate_internal_references($parser);
+  my $refs = $parser->internal_references_information();
+  Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
   # every format needs the sectioning structure
 
   my $structure = Texinfo::Structuring::sectioning_structure($parser, $tree);
@@ -1309,7 +1317,7 @@ while(@input_files) {
   }
 
   if ($tree_transformations{'regenerate_master_menu'}) {
-    Texinfo::Transformations::regenerate_master_menu($parser);
+    Texinfo::Transformations::regenerate_master_menu($parser, $labels);
   }
 
   # this can be done for every format, since information is already gathered
@@ -1325,12 +1333,18 @@ while(@input_files) {
     # for instance if format is structure.
     if (not defined($parser_options->{'FORMAT_MENU'})
         or $parser_options->{'FORMAT_MENU'} eq 'menu') {
-      Texinfo::Structuring::set_menus_node_directions($parser);
+      Texinfo::Structuring::set_menus_node_directions($parser, $nodes_list, 
$labels);
     }
-    $top_node = Texinfo::Structuring::nodes_tree($parser);
+    $top_node = Texinfo::Structuring::nodes_tree($parser, $nodes_list, 
$labels);
     if (not defined($parser_options->{'FORMAT_MENU'})
         or $parser_options->{'FORMAT_MENU'} eq 'menu') {
-      Texinfo::Structuring::complete_node_tree_with_menus($parser, $top_node);
+      if (defined($nodes_list)) {
+        Texinfo::Structuring::complete_node_tree_with_menus($parser,
+                                                       $nodes_list, $top_node);
+        Texinfo::Structuring::check_nodes_are_referenced($parser,
+                                                     $nodes_list, $top_node,
+                                                     $labels, $refs);
+      }
     }
   }
   if ($formats_table{$format}->{'floats'}) {



reply via email to

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