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


From: Patrice Dumas
Subject: branch master updated: * 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, tp/Texinfo/Convert/TexinfoXML.pm, tp/init/book.pm: move _level_corrected_section() to Texinfo::Structuring and rename as section_level_adjusted_command_name()
Date: Sat, 11 Sep 2021 09:10:52 -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 8c5983f  * 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, tp/Texinfo/Convert/TexinfoXML.pm, tp/init/book.pm: 
move _level_corrected_section() to Texinfo::Structuring and rename as 
section_level_adjusted_command_name()
8c5983f is described below

commit 8c5983f32354a4adc86251b073f4d87a4886f90d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Sep 11 15:10:44 2021 +0200

    * 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,
    tp/Texinfo/Convert/TexinfoXML.pm, tp/init/book.pm: move
    _level_corrected_section() to Texinfo::Structuring and rename as
    section_level_adjusted_command_name()
---
 ChangeLog                        |  9 +++++++++
 tp/Texinfo/Convert/Converter.pm  | 15 ---------------
 tp/Texinfo/Convert/DocBook.pm    | 14 ++++++++------
 tp/Texinfo/Convert/HTML.pm       |  3 ++-
 tp/Texinfo/Convert/IXIN.pm       |  2 +-
 tp/Texinfo/Convert/TexinfoXML.pm | 22 +++++++++++++---------
 tp/Texinfo/Structuring.pm        | 21 +++++++++++++++++++++
 tp/init/book.pm                  |  3 ++-
 8 files changed, 56 insertions(+), 33 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2e27b59..93fedab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 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,
+       tp/Texinfo/Convert/TexinfoXML.pm, tp/init/book.pm: move
+       _level_corrected_section() to Texinfo::Structuring and rename as
+       section_level_adjusted_command_name()
+
+2021-09-11  Patrice Dumas  <pertusus@free.fr>
+
        * tp/Texinfo/Convert/HTML.pm (_convert_heading_command),
        tp/init/book.pm (book_convert_heading_command):
        rename $command as $element.  Use _level_corrected_section().
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index cb411e7..baffd8e 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -1136,21 +1136,6 @@ sub table_item_content_tree($$$)
   return $table_item_tree;
 }
 
-sub _level_corrected_section($$)
-{
-  my $self = shift;
-  my $element = shift;
-  my $heading_level = $element->{'level'};
-  my $command;
-  if ($heading_level ne 
$Texinfo::Common::command_structuring_level{$element->{'cmdname'}}) {
-    $command
-      = 
$Texinfo::Common::level_to_structuring_command{$element->{'cmdname'}}->[$heading_level];
-  } else {
-    $command = $element->{'cmdname'};
-  }
-  return $command;
-}
-
 # generic output method, not used anywhere.
 # FIXME remove?
 sub output_no_split($$)
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index b4daf95..3dff03a 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -397,15 +397,16 @@ sub _docbook_section_element($$)
   if (exists $docbook_sections{$heading_level}) {
     return $docbook_sections{$heading_level};
   }
-  my $level_corrected_sectioning_cmdname = 
$self->_level_corrected_section($element);
-  if ($level_corrected_sectioning_cmdname eq 'unnumbered'
+  my $level_adjusted_cmdname
+     = Texinfo::Structuring::section_level_adjusted_command_name($element);
+  if ($level_adjusted_cmdname eq 'unnumbered'
       and $element->{'extra'}->{'associated_node'}
       and $element->{'extra'}->{'associated_node'}->{'extra'}->{'normalized'}
       and 
$docbook_special_unnumbered{lc($element->{'extra'}->{'associated_node'}->{'extra'}->{'normalized'})})
 {
     return 
lc($element->{'extra'}->{'associated_node'}->{'extra'}->{'normalized'});
   }
 
-  return $docbook_sections{$level_corrected_sectioning_cmdname};
+  return $docbook_sections{$level_adjusted_cmdname};
 }
 
 sub _index_entry($$)
@@ -1481,9 +1482,10 @@ sub _convert($$;$)
     if ($command eq 'part' and !Texinfo::Common::is_content_empty($element)) {
       $result .= "</partintro>\n";
     }
-    my $level_corrected_sectioning_cmdname = 
$self->_level_corrected_section($element);
+    my $level_adjusted_cmdname
+        = Texinfo::Structuring::section_level_adjusted_command_name($element);
     if (!($element->{'section_childs'} and 
scalar(@{$element->{'section_childs'}}))
-        or $level_corrected_sectioning_cmdname eq 'top') {
+        or $level_adjusted_cmdname eq 'top') {
       $result .= "</$command>\n";
       pop @{$self->{'lang_stack'}};
       my $current = $element;
@@ -1492,7 +1494,7 @@ sub _convert($$;$)
              # condition avoids getting into it
              and $current->{'section_up'}->{'cmdname'}
              and !$current->{'section_next'}
-             and $self->_level_corrected_section($current->{'section_up'}) ne 
'top') {
+             and 
Texinfo::Structuring::section_level_adjusted_command_name($current->{'section_up'})
 ne 'top') {
         $current = $current->{'section_up'};
         $result .= '</'.$self->_docbook_section_element($current) .">\n";
         pop @{$self->{'lang_stack'}};
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index e643717..8549a6c 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -2547,7 +2547,8 @@ sub _convert_heading_command($$$$$)
   } elsif (defined $element->{'level'}) {
     $heading_level = $element->{'level'};
     # if the level was changed, set the command name right
-    $cmdname_for_heading = $self->_level_corrected_section($element);
+    $cmdname_for_heading
+      = Texinfo::Structuring::section_level_adjusted_command_name($element);
   } else {
     # for *heading* @-commands which do not have a level
     # in the document as they are not associated with the
diff --git a/tp/Texinfo/Convert/IXIN.pm b/tp/Texinfo/Convert/IXIN.pm
index 4f2cf89..5c2b296 100644
--- a/tp/Texinfo/Convert/IXIN.pm
+++ b/tp/Texinfo/Convert/IXIN.pm
@@ -528,7 +528,7 @@ sub output_ixin($$)
         my $associated_node_id = $self->_associated_node_id($section, 
                                                      \%node_label_number);
         my @attributes = ('nodeid', $associated_node_id, 'type', 
-              $self->_level_corrected_section($section));
+              
Texinfo::Structuring::section_level_adjusted_command_name($section));
         $sectioning_tree .= $self->ixin_open_element('sectionentry',
                  \@attributes);
         $sectioning_tree .= $self->ixin_open_element('sectiontitle');
diff --git a/tp/Texinfo/Convert/TexinfoXML.pm b/tp/Texinfo/Convert/TexinfoXML.pm
index 0e208e8..0c7926f 100644
--- a/tp/Texinfo/Convert/TexinfoXML.pm
+++ b/tp/Texinfo/Convert/TexinfoXML.pm
@@ -975,14 +975,15 @@ sub _convert($$;$)
           pop @{$self->{'document_context'}->[-1]->{'monospace'}};
         } elsif ($Texinfo::Common::root_commands{$cmdname}) {
           my $attribute = [_leading_spaces_before_argument($element)];
-          my $level_corrected_cmdname = 
$self->_level_corrected_section($element);
-          if ($level_corrected_cmdname ne $cmdname) {
+          my $level_adjusted_cmdname
+            = 
Texinfo::Structuring::section_level_adjusted_command_name($element);
+          if ($level_adjusted_cmdname ne $cmdname) {
             unshift @$attribute, ('originalcommand', $cmdname);
           }
-          $result .= $self->open_element($level_corrected_cmdname, $attribute);
+          $result .= $self->open_element($level_adjusted_cmdname, $attribute);
           my $closed_section_element;
           if ($self->get_conf('USE_NODES')) {
-            $closed_section_element = 
$self->close_element($level_corrected_cmdname);
+            $closed_section_element = 
$self->close_element($level_adjusted_cmdname);
           } else {
             $closed_section_element = '';
           }
@@ -1681,19 +1682,22 @@ sub _convert($$;$)
     if ($element->{'type'} and $element->{'type'} eq 'unit') {
       $element = $element->{'extra'}->{'unit_command'};
     }
-    my $command = $self->_level_corrected_section($element);
+    my $level_adjusted_cmdname
+       = Texinfo::Structuring::section_level_adjusted_command_name($element);
     if (!($element->{'section_childs'} and 
scalar(@{$element->{'section_childs'}}))
-        or $command eq 'top') {
-      $result .= $self->close_element($command)."\n";
+        or $level_adjusted_cmdname eq 'top') {
+      $result .= $self->close_element($level_adjusted_cmdname)."\n";
       my $current = $element;
       while ($current->{'section_up'}
              # the most up element is a virtual sectioning root element, this
              # condition avoids getting into it
              and $current->{'section_up'}->{'cmdname'}
              and !$current->{'section_next'}
-             and $self->_level_corrected_section($current->{'section_up'}) ne 
'top') {
+             and 
Texinfo::Structuring::section_level_adjusted_command_name($current->{'section_up'})
 ne 'top') {
         $current = $current->{'section_up'};
-        $result .= 
$self->close_element($self->_level_corrected_section($current)) ."\n";
+        my $level_adjusted_current_cmdname
+            = 
Texinfo::Structuring::section_level_adjusted_command_name($current);
+        $result .= $self->close_element($level_adjusted_current_cmdname) ."\n";
       }
     }
     if ($self->{'pending_bye'}) {
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index df6ab1b..46fe0a6 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -830,6 +830,21 @@ sub nodes_tree($$$$$)
   return $top_node;
 }
 
+sub section_level_adjusted_command_name($)
+{
+  my $element = shift;
+
+  my $heading_level = $element->{'level'};
+  my $command;
+  if ($heading_level ne 
$Texinfo::Common::command_structuring_level{$element->{'cmdname'}}) {
+    $command
+      = 
$Texinfo::Common::level_to_structuring_command{$element->{'cmdname'}}->[$heading_level];
+  } else {
+    $command = $element->{'cmdname'};
+  }
+  return $command;
+}
+
 # Return a list of tree units to be converted into pages.  Each tree unit
 # starts with a @node as its first child (except possibly the first one).
 sub split_by_node($)
@@ -1986,6 +2001,12 @@ the I<number> key of the float tree elements.
 Return numbered level of the tree sectioning C<$section>, as modified by
 raise/lowersections.
 
+=item $command_name = section_level_adjusted_command_name($element)
+
+Return the sectioning command name corresponding to the sectioning
+element I<$element>, adjusted in order to take into account raised
+and lowered sections, when needed.
+
 =item $sections_root, $sections_list = sectioning_structure ($registrar, 
$configuration_informations, $tree)
 
 This function goes through the tree and gather information on
diff --git a/tp/init/book.pm b/tp/init/book.pm
index 6b2d9d4..156ed66 100644
--- a/tp/init/book.pm
+++ b/tp/init/book.pm
@@ -217,7 +217,8 @@ sub book_convert_heading_command($$$$$)
   } else {
     $heading_level = $element->{'level'};
     # if the level was changed, set the command name right
-    $cmdname_for_heading = $self->_level_corrected_section($element);
+    $cmdname_for_heading
+      = Texinfo::Structuring::section_level_adjusted_command_name($element);
   }
 
   my $heading = $self->command_text($element);



reply via email to

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