texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Structuring.pm (root_element_command


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Structuring.pm (root_element_command_to_texinfo), tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/HTML.pm, tp/Texinfo/Convert/Plaintext.pm, tp/Texinfo/Convert/Texinfo.pm (root_element_command_to_texinfo), tp/Texinfo/Transformations.pm, tp/init/book.pm: rename _print_root_command_texi() as root_element_command_to_texinfo(). Move _print_root_command_texi() to Texinfo::Convert::Texinfo and rename as root_element_command_to_texinfo().
Date: Sat, 11 Sep 2021 10:42:35 -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 1e4216f  * tp/Texinfo/Structuring.pm 
(root_element_command_to_texinfo), tp/Texinfo/Convert/Converter.pm, 
tp/Texinfo/Convert/HTML.pm, tp/Texinfo/Convert/Plaintext.pm, 
tp/Texinfo/Convert/Texinfo.pm (root_element_command_to_texinfo), 
tp/Texinfo/Transformations.pm, tp/init/book.pm: rename 
_print_root_command_texi() as root_element_command_to_texinfo().  Move 
_print_root_command_texi() to Texinfo::Convert::Texinfo and rename as 
root_element_command_to_texinfo().
1e4216f is described below

commit 1e4216f13d484a79afa328102e2095f9c9329538
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Sep 11 16:42:28 2021 +0200

    * tp/Texinfo/Structuring.pm (root_element_command_to_texinfo),
    tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/HTML.pm,
    tp/Texinfo/Convert/Plaintext.pm, tp/Texinfo/Convert/Texinfo.pm
    (root_element_command_to_texinfo), tp/Texinfo/Transformations.pm,
    tp/init/book.pm:
    rename _print_root_command_texi() as
    root_element_command_to_texinfo().  Move _print_root_command_texi()
    to Texinfo::Convert::Texinfo and rename as
    root_element_command_to_texinfo().
---
 ChangeLog                       | 12 ++++++++++
 tp/Texinfo/Convert/Converter.pm |  4 +++-
 tp/Texinfo/Convert/HTML.pm      | 12 ++++++----
 tp/Texinfo/Convert/Plaintext.pm |  2 +-
 tp/Texinfo/Convert/Texinfo.pm   | 53 ++++++++++++++++++++++++++++-------------
 tp/Texinfo/Structuring.pm       | 42 ++++++++++----------------------
 tp/Texinfo/Transformations.pm   |  9 ++++---
 tp/init/book.pm                 |  4 ++--
 8 files changed, 78 insertions(+), 60 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 93fedab..5e4216b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2021-09-11  Patrice Dumas  <pertusus@free.fr>
 
+       * tp/Texinfo/Structuring.pm (root_element_command_to_texinfo),
+       tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/HTML.pm,
+       tp/Texinfo/Convert/Plaintext.pm, tp/Texinfo/Convert/Texinfo.pm
+       (root_element_command_to_texinfo), tp/Texinfo/Transformations.pm,
+       tp/init/book.pm:
+       rename _print_root_command_texi() as
+       root_element_command_to_texinfo().  Move _print_root_command_texi()
+       to Texinfo::Convert::Texinfo and rename as
+       root_element_command_to_texinfo().
+
+2021-09-11  Patrice Dumas  <pertusus@free.fr>
+
        * tp/Texinfo/Structuring.pm (section_level_adjusted_command_name),
        tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/DocBook.pm,
        tp/Texinfo/Convert/HTML.pm, tp/Texinfo/Convert/IXIN.pm,
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 5cb1218..88964eb 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -722,7 +722,9 @@ sub _set_tree_units_files($$$$$$)
 
   foreach my $tree_unit (@$tree_units) {
     $self->{'file_counters'}->{$tree_unit->{'filename'}}++;
-    print STDERR "Page $tree_unit 
".Texinfo::Structuring::_print_element_command_texi($tree_unit).": 
$tree_unit->{'filename'}($self->{'file_counters'}->{$tree_unit->{'filename'}})\n"
+    print STDERR "Page $tree_unit "
+     .Texinfo::Structuring::root_or_external_element_cmd_texi($tree_unit)
+     .": 
$tree_unit->{'filename'}($self->{'file_counters'}->{$tree_unit->{'filename'}})\n"
       if ($self->get_conf('DEBUG'));
   }
 }
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 8549a6c..c7da7d7 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -2390,7 +2390,7 @@ sub _default_format_element_header($$$$)
   my $result = '';
    
   print STDERR "Element $tree_unit (@{$tree_unit->{'contents'}}) ".
-     Texinfo::Structuring::_print_element_command_texi($tree_unit) ."\n"
+     Texinfo::Structuring::root_or_external_element_cmd_texi($tree_unit) ."\n"
         if ($self->get_conf('DEBUG'));
 
   # Do the heading if the command is the first command in the element
@@ -2406,7 +2406,7 @@ sub _default_format_element_header($$$$)
                    and 
$self->element_is_tree_unit_top($tree_unit->{'unit_prev'}));
 
     print STDERR "Header ($previous_is_top, $is_top, $first_in_page): "
-      .Texinfo::Structuring::_print_root_command_texi($command)."\n"
+      
.Texinfo::Convert::Texinfo::root_element_command_to_texinfo($command)."\n"
         if ($self->get_conf('DEBUG'));
 
     if ($is_top) {
@@ -2515,7 +2515,7 @@ sub _convert_heading_command($$$$$)
   }
 
   print STDERR "Process $element "
-        .Texinfo::Structuring::_print_root_command_texi($element)."\n"
+        
.Texinfo::Convert::Texinfo::root_element_command_to_texinfo($element)."\n"
           if ($self->get_conf('DEBUG'));
   my $tree_unit;
   if ($Texinfo::Common::root_commands{$element->{'cmdname'}}
@@ -5842,7 +5842,9 @@ sub _html_set_pages_files($$$$$$$$)
          if (defined($filename));
     }
     $self->{'file_counters'}->{$tree_unit->{'filename'}}++;
-    print STDERR "Page $tree_unit 
".Texinfo::Structuring::_print_element_command_texi($tree_unit).": 
$tree_unit->{'filename'}($self->{'file_counters'}->{$tree_unit->{'filename'}})\n"
+    print STDERR "Page $tree_unit "
+      .Texinfo::Structuring::root_or_external_element_cmd_texi($tree_unit)
+      .": 
$tree_unit->{'filename'}($self->{'file_counters'}->{$tree_unit->{'filename'}})\n"
       if ($self->get_conf('DEBUG'));
   }
   if ($special_elements) {
@@ -6155,7 +6157,7 @@ sub _prepare_tree_units_global_targets($$)
     foreach my $global_direction (@global_directions) {
       if (defined($self->{'global_target_elements'}->{$global_direction})) {
         print STDERR 
"$global_direction($self->{'global_target_elements'}->{$global_direction}): ".
-          Texinfo::Structuring::_print_element_command_texi(
+          Texinfo::Structuring::root_or_external_element_cmd_texi(
              $self->{'global_target_elements'}->{$global_direction})."\n";
       }
     }
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 5aa69a2..a9b7e3f 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -456,7 +456,7 @@ sub count_context_bug_message($$$)
     my $element_text;
     if ($element) {
       $element_text
-         = Texinfo::Structuring::_print_element_command_texi($element);
+         = Texinfo::Structuring::root_or_external_element_cmd_texi($element);
     } else {
       $element_text = '';
     }
diff --git a/tp/Texinfo/Convert/Texinfo.pm b/tp/Texinfo/Convert/Texinfo.pm
index b807150..5f856bf 100644
--- a/tp/Texinfo/Convert/Texinfo.pm
+++ b/tp/Texinfo/Convert/Texinfo.pm
@@ -45,6 +45,9 @@ my %brace_commands           = 
%Texinfo::Common::brace_commands;
 my %block_commands           = %Texinfo::Common::block_commands;
 my %def_commands             = %Texinfo::Common::def_commands;
 
+# used in root_element_command_to_texinfo
+my %sectioning_commands = %Texinfo::Common::sectioning_commands;
+
 my @ignored_types = ('spaces_inserted', 'bracketed_inserted',
 'command_as_argument_inserted');
 my %ignored_types;
@@ -52,6 +55,40 @@ for my $a (@ignored_types) {
   $ignored_types{$a} = 1;
 }
 
+# used to put a node name in error messages.
+sub node_extra_to_texi($)
+{
+  my $node = shift;
+  my $result = '';
+  if ($node->{'manual_content'}) {
+    $result = '('.convert_to_texinfo({'contents'
+                              => $node->{'manual_content'}}) .')';
+  }
+  if ($node->{'node_content'}) {
+    $result .= convert_to_texinfo({'contents' => $node->{'node_content'}});
+  }
+  return $result;
+}
+
+# for debugging.
+sub root_element_command_to_texinfo($)
+{
+  my $element = shift;
+  my $tree;
+  if ($element->{'cmdname'}) {
+    if ($element->{'cmdname'} eq 'node') {
+      $tree = $element->{'extra'}->{'node_content'};
+    } elsif ($sectioning_commands{$element->{'cmdname'}}) {
+      $tree = $element->{'args'}->[0]->{'contents'};
+    }
+  } else {
+    return "Not a root command";
+  }
+  return '@'.$element->{'cmdname'}.' '.convert_to_texinfo({'contents' => 
$tree})
+          if ($tree);
+  return 'UNDEF @'.$element->{'cmdname'};
+}
+
 # Following subroutines deal with transforming a texinfo tree into texinfo
 # text.  Should give the text that was used parsed, except for a few cases.
 
@@ -116,22 +153,6 @@ sub convert_to_texinfo($;$)
   return $result;
 }
 
-# used to put a node name in error messages.
-sub node_extra_to_texi($)
-{
-  my $node = shift;
-  my $result = '';
-  if ($node->{'manual_content'}) {
-    $result = '('.convert_to_texinfo({'contents'
-                              => $node->{'manual_content'}}) .')';
-  }
-  if ($node->{'node_content'}) {
-    $result .= convert_to_texinfo({'contents' => $node->{'node_content'}});
-  }
-  return $result;
-}
-
-
 # expand a command argument as texinfo.
 sub _expand_cmd_args_to_texi($;$) {
   my $cmd = shift;
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index 46fe0a6..d2f5973 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -328,7 +328,8 @@ sub _print_sectioning_tree($);
 sub _print_sectioning_tree($)
 {
   my $current = shift;
-  my $result = ' ' x $current->{'level'} . 
_print_root_command_texi($current)."\n";
+  my $result = ' ' x $current->{'level'}
+     . 
Texinfo::Convert::Texinfo::root_element_command_to_texinfo($current)."\n";
   foreach my $child (@{$current->{'section_childs'}}) {
     $result .= _print_sectioning_tree($child);
   }
@@ -989,7 +990,7 @@ sub split_pages ($$)
              and $tree_unit->{'extra'}->{'node'}->{'associated_section'}) {
       $level = 
$tree_unit->{'extra'}->{'node'}->{'associated_section'}->{'level'};
     }
-    #print STDERR "level($split_level) $level 
"._print_element_command_texi($tree_unit)."\n";
+    #print STDERR "level($split_level) $level 
".root_or_external_element_cmd_texi($tree_unit)."\n";
     if (!defined($split_level) or (defined($level) and $split_level >= $level)
         or !$current_first_in_page) {
       $current_first_in_page = $tree_unit;
@@ -1165,7 +1166,7 @@ sub elements_directions($$$)
         and !$directions->{'Up'} and $tree_unit->{'extra'}->{'node'}
         and $tree_unit->{'extra'}->{'node'}->{'node_up'}
         and (!$node_top or ($tree_unit->{'extra'}->{'node'} ne $node_top))) {
-      #print STDERR "Using node for up 
"._print_element_command_texi($tree_unit)."\n";
+      #print STDERR "Node for up: 
".root_or_external_element_cmd_texi($tree_unit)."\n";
       my $up_node_element = 
_label_target_element($tree_unit->{'extra'}->{'node'}->{'node_up'});
       $directions->{'Up'} = $up_node_element if ($up_node_element);
     }
@@ -1246,28 +1247,8 @@ sub elements_file_directions($)
   }
 }
 
-my %sectioning_commands = %Texinfo::Common::sectioning_commands;
-# for debugging.  Used in other modules.
-sub _print_root_command_texi($)
-{
-  my $command = shift;
-  my $tree;
-  if ($command->{'cmdname'}) {
-    if ($command->{'cmdname'} eq 'node') {
-      $tree = $command->{'extra'}->{'node_content'};
-    } elsif ($sectioning_commands{$command->{'cmdname'}}) {
-      $tree = $command->{'args'}->[0]->{'contents'};
-    }
-  } else {
-    return "Not a root command";
-  }
-  return '@'.$command->{'cmdname'}. ' '
-       .Texinfo::Convert::Texinfo::convert_to_texinfo({'contents' => $tree})
-          if ($tree);
-  return 'UNDEF @'.$command->{'cmdname'};
-}
-
-sub _print_element_command_texi($)
+# used in debug messages
+sub root_or_external_element_cmd_texi($)
 {
   my $element = shift;
   if (!$element) {
@@ -1288,14 +1269,14 @@ sub _print_element_command_texi($)
     return Texinfo::Convert::Texinfo::convert_to_texinfo($command);
   }
   
-  my $command = $element->{'extra'}->{'unit_command'};
-  if (!defined($command)) {
+  my $command_element = $element->{'extra'}->{'unit_command'};
+  if (!defined($command_element)) {
     # happens when there are only nodes and sections are used as elements
     my $result = "No associated command ";
     $result .= "(type $element->{'type'})" if (defined($element->{'type'}));
     return $result;
   }
-  return _print_root_command_texi($command);
+  return 
Texinfo::Convert::Texinfo::root_element_command_to_texinfo($command_element);
 }
 
 # Used for debugging and in test suite, but not generally useful. Not
@@ -1306,12 +1287,13 @@ sub _print_element_command_texi($)
 sub print_element_directions($)
 {
   my $element = shift;
-  my $result = 'element: '._print_element_command_texi($element)."\n";
+  my $result = 'element: '.root_or_external_element_cmd_texi($element)."\n";
 
   if ($element->{'extra'} and $element->{'extra'}->{'directions'}) {
     foreach my $direction (sort(keys(%{$element->{'extra'}->{'directions'}}))) 
{
       $result .= "  $direction: ".
-       
_print_element_command_texi($element->{'extra'}->{'directions'}->{$direction})."\n";
+       root_or_external_element_cmd_texi(
+         $element->{'extra'}->{'directions'}->{$direction})."\n";
     }
   } else {
     $result .= "  NO DIRECTION";
diff --git a/tp/Texinfo/Transformations.pm b/tp/Texinfo/Transformations.pm
index 16c0259..dbbab95 100644
--- a/tp/Texinfo/Transformations.pm
+++ b/tp/Texinfo/Transformations.pm
@@ -109,8 +109,6 @@ sub fill_gaps_in_sectioning($)
         if (@correct_level_offset_commands) {
           push @{$contents[-1]->{'contents'}}, @correct_level_offset_commands;
         }
-        #print STDERR "* $current_section_level 
"._print_root_command_texi($current_section)."\n";
-        #print STDERR "  $next_section_level 
"._print_root_command_texi($next_section)."\n";
         while ($next_section_level - $current_section_level > 1) {
           $current_section_level++;
           my $new_section = {'cmdname' =>
@@ -138,7 +136,6 @@ sub fill_gaps_in_sectioning($)
                  'parent' => $new_section->{'args'}->[0]->{'contents'}->[1]}];
           push @contents, $new_section;
           push @added_sections, $new_section;
-          #print STDERR "  -> "._print_root_command_texi($new_section)."\n";
         }
         my @set_level_offset_commands = _correct_level($next_section,
                                                        $contents[-1], -1);
@@ -301,10 +298,12 @@ sub _reassociate_to_node($$$$)
         Texinfo::Convert::Texinfo::convert_to_texinfo(
             {'contents' => $current->{'extra'}->{'index_entry'}->{'content'}})
          .") not in previous node $previous_node\n";
-      print STDERR "  previous node: 
"._print_root_command_texi($previous_node)."\n";
+      print STDERR "  previous node: "
+        
.Texinfo::Convert::Texinfo::root_element_command_to_texinfo($previous_node)."\n";
       if ($current->{'extra'}->{'index_entry'}->{'node'}) {
         print STDERR "  current node: ".
-         
_print_root_command_texi($current->{'extra'}->{'index_entry'}->{'node'})."\n";
+         Texinfo::Convert::Texinfo::root_element_command_to_texinfo(
+                            
$current->{'extra'}->{'index_entry'}->{'node'})."\n";
       } else {
         print STDERR "  current node not set\n";
       }
diff --git a/tp/init/book.pm b/tp/init/book.pm
index 156ed66..da8d7fa 100644
--- a/tp/init/book.pm
+++ b/tp/init/book.pm
@@ -73,7 +73,7 @@ sub book_print_up_toc($$)
   return '' if !(@up_commands);
   #print $fh "<ul>" . &$anchor('', $Texi2HTML::HREF{Contents}, '[' . 
$Texi2HTML::NAME{Contents} . ']') . " <br>\n";
   my $up = shift @up_commands;
-#print STDERR "$up $up->{'cmdname'} 
".Texinfo::Structuring::_print_root_command_texi($up)."\n";
+  #print STDERR "$up 
".Texinfo::Convert::Texinfo::root_element_command_to_texinfo($up)."\n";
   $result .= $converter->_attribute_class('ul', $NO_BULLET_LIST_CLASS)."><li>"
   . "<a 
href=\"".$converter->command_href($up)."\">".$converter->command_text($up)
    . "</a> </li>\n";
@@ -184,7 +184,7 @@ sub book_convert_heading_command($$$$$)
   $result .= ">\n";
 
   print STDERR "Process $element "
-        .Texinfo::Structuring::_print_root_command_texi($element)."\n"
+        
.Texinfo::Convert::Texinfo::root_element_command_to_texinfo($element)."\n"
           if ($self->get_conf('DEBUG'));
   my $tree_unit;
   if ($Texinfo::Common::root_commands{$element->{'cmdname'}}



reply via email to

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