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 (_parsed_manual_


From: Patrice Dumas
Subject: branch master updated: * Pod-Simple-Texinfo/pod2texi.pl (_parsed_manual_tree): update/fix the code adding the manual name to added nodes with fill_gaps_in_sectioning, and simplify.
Date: Sun, 18 Sep 2022 14:56:07 -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 d836839d4d * Pod-Simple-Texinfo/pod2texi.pl (_parsed_manual_tree): 
update/fix the code adding the manual name to added nodes with 
fill_gaps_in_sectioning, and simplify.
d836839d4d is described below

commit d836839d4dd3203be5ee4d696bc3313a5ec503f8
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Sep 18 20:55:41 2022 +0200

    * Pod-Simple-Texinfo/pod2texi.pl (_parsed_manual_tree): update/fix
    the code adding the manual name to added nodes with
    fill_gaps_in_sectioning, and simplify.
---
 ChangeLog                      |  6 ++++++
 Pod-Simple-Texinfo/pod2texi.pl | 40 ++++++++++++++++++++++------------------
 tp/Texinfo/Common.pm           |  3 +++
 3 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fb3d1022f8..5d06a15b19 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-09-18  Patrice Dumas  <pertusus@free.fr>
+
+       * Pod-Simple-Texinfo/pod2texi.pl (_parsed_manual_tree): update/fix
+       the code adding the manual name to added nodes with
+       fill_gaps_in_sectioning, and simplify.
+
 2022-09-18  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Transformations.pm (_new_node): build a tree
diff --git a/Pod-Simple-Texinfo/pod2texi.pl b/Pod-Simple-Texinfo/pod2texi.pl
index 34c5dc9d2c..0fb3a4eb0b 100755
--- a/Pod-Simple-Texinfo/pod2texi.pl
+++ b/Pod-Simple-Texinfo/pod2texi.pl
@@ -266,48 +266,52 @@ sub _parsed_manual_tree($$$$$)
         foreach my $node (@$added_nodes) {
           # First remove the old normalized entry
           delete $texi_parser->{'labels'}->{$node->{'extra'}->{'normalized'}};
-          # now get the number
+
+          # prepare the new node Texinfo name and parse it to a Texinfo tree
           my $node_texi = Texinfo::Convert::Texinfo::convert_to_texinfo(
                 {'contents' => $node->{'extra'}->{'node_content'}});
           # We could have kept the asis, too, it is kept when !section_nodes
           $node_texi =~ s/^\s*(\@asis\{\})?\s*//;
           # complete with manual name
           my $complete_node_name = $self->_node_name($node_texi);
-          # now recreate node arg, similar with 
Texinfo::Transformations::_new_node
-          my $tree = Texinfo::Parser::parse_texi_text(undef, 
$complete_node_name);
+          my $completed_node_tree
+            = Texinfo::Parser::parse_texi_line(undef, $complete_node_name);
+
+          # now recreate node arg
           my $node_arg = $node->{'args'}->[0];
-          $node_arg->{'contents'} = $tree->{'contents'};
-          push @{$node_arg->{'contents'}},
-              {'type' => 'spaces_at_end', 'text' => "\n"};
-          unshift @{$node_arg->{'contents'}},
-                  {'extra' => {'command' => $node},
-                   'text' => ' ',
-                   'type' => 'empty_spaces_after_command'};
+          $node_arg->{'contents'} = $completed_node_tree->{'contents'};
           foreach my $content (@{$node_arg->{'contents'}}) {
             $content->{'parent'} = $node_arg;
           }
-          # Last parse and register node
-          my $parsed_node = Texinfo::Common::parse_node_manual($node_arg);
-          #push @{$node->{'extra'}->{'nodes_manuals'}}, $parsed_node;
+
+          # reset extra informations
+          my $parsed_node = {'node_content' => $node_arg->{'contents'}};
+          my $normalized_node_name
+             = Texinfo::Convert::NodeNameNormalization::normalize_node(
+                  { 'contents' => $node_arg->{'contents'} });
+          $parsed_node->{'normalized'} = $normalized_node_name;
+          $node->{'extra'}->{'normalized'} = $normalized_node_name;
           @{$node->{'extra'}->{'nodes_manuals'}} = ($parsed_node);
-          Texinfo::Common::register_label($texi_parser, $node, $parsed_node);
+          # this (re)sets $node->{'extra'}->{'node_content'}
+          Texinfo::Common::register_label($targets_list, $node, $parsed_node);
+          # Nothing should link to the added node, but we setup the label
+          # informations nonetheless.
+          $labels->{$normalized_node_name} = $node;
         }
       }
     }
   }
   my ($sectioning_root, $sections_list)
     = Texinfo::Structuring::sectioning_structure($registrar, $texi_parser, 
$tree);
-  my ($updated_labels, $updated_targets_list, $updated_nodes_list)
-        = $texi_parser->labels_information();
   my $refs = $texi_parser->internal_references_information();
   my $parser_information = $texi_parser->global_information();
   # this is needed to set 'normalized' for menu entries, they are
   # used in complete_tree_nodes_menus.
   Texinfo::Structuring::associate_internal_references($registrar, $texi_parser,
-                                  $parser_information, $updated_labels, $refs);
+                                  $parser_information, $labels, $refs);
   Texinfo::Transformations::complete_tree_nodes_menus($tree)
     if ($section_nodes and $do_node_menus);
-  return ($texi_parser, $tree, $updated_labels);
+  return ($texi_parser, $tree, $labels);
 }
 
 sub _fix_texinfo_tree($$$$;$$)
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 8df9fecd56..e2961851e4 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -2701,6 +2701,9 @@ sub register_label($$$)
 {
   my ($targets_list, $current, $label) = @_;
 
+  #if (ref($targets_list) ne 'ARRAY') {
+  #  cluck("BUG: register_label \$targets_list not an ARRAY reference\n");
+  #}
   push @{$targets_list}, $current;
   if ($label->{'node_content'}) {
     $current->{'extra'}->{'node_content'} = $label->{'node_content'};



reply via email to

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