texinfo-commits
[Top][All Lists]
Advanced

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

[7877] move section_level function


From: gavinsmith0123
Subject: [7877] move section_level function
Date: Thu, 29 Jun 2017 10:39:26 -0400 (EDT)

Revision: 7877
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7877
Author:   gavin
Date:     2017-06-29 10:39:26 -0400 (Thu, 29 Jun 2017)
Log Message:
-----------
move section_level function

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/tp/Texinfo/Convert/HTML.pm
    trunk/tp/Texinfo/Convert/Text.pm
    trunk/tp/Texinfo/Parser.pm
    trunk/tp/Texinfo/Structuring.pm

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2017-06-29 14:13:30 UTC (rev 7876)
+++ trunk/ChangeLog     2017-06-29 14:39:26 UTC (rev 7877)
@@ -1,5 +1,11 @@
 2017-06-29  Gavin Smith  <address@hidden>
 
+       * tp/Texinfo/Parser.pm (_section_level),
+       * tp/Texinfo/Structuring.pm (section_level): Move function to
+       Structuring.pm.
+
+2017-06-29  Gavin Smith  <address@hidden>
+
        * tp/Texinfo/Parser.pm (_parse_texi): Do not add 'level' value
        on sectioning commands.
        * tp/Texinfo/Structuring.pm (sectioning_structure): Add 'level' 

Modified: trunk/tp/Texinfo/Convert/HTML.pm
===================================================================
--- trunk/tp/Texinfo/Convert/HTML.pm    2017-06-29 14:13:30 UTC (rev 7876)
+++ trunk/tp/Texinfo/Convert/HTML.pm    2017-06-29 14:39:26 UTC (rev 7877)
@@ -1,8 +1,8 @@
 # $Id$
 # HTML.pm: output tree as HTML.
 #
-# Copyright 2011, 2012, 2013, 2014, 2015,
-# 2016 Free Software Foundation, Inc.
+# Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 Free Software Foundation, 
+# Inc.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -2370,7 +2370,7 @@
   } elsif (defined $command->{'level'}) {
     $heading_level = $command->{'level'};
   } else {
-    $heading_level = Texinfo::Parser::_section_level($command);
+    $heading_level = Texinfo::Structuring::section_level($command);
   }
 
   my $heading = $self->command_text($command);

Modified: trunk/tp/Texinfo/Convert/Text.pm
===================================================================
--- trunk/tp/Texinfo/Convert/Text.pm    2017-06-29 14:13:30 UTC (rev 7876)
+++ trunk/tp/Texinfo/Convert/Text.pm    2017-06-29 14:39:26 UTC (rev 7877)
@@ -1,7 +1,7 @@
 # Text.pm: output tree as simple text.
 #
-# Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free Software Foundation, 
-# Inc., 
+# Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Free Software 
+# Foundation, Inc., 
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -311,7 +311,7 @@
     $indent_length = 0;
   }
   if (!defined $current->{'level'}) {
-    $current->{'level'} = Texinfo::Parser::_section_level($current);
+    $current->{'level'} = Texinfo::Structuring::section_level($current);
   }
   $result .=($underline_symbol{$current->{'level'}} 
      x (Texinfo::Convert::Unicode::string_width($text) - $indent_length))."\n";

Modified: trunk/tp/Texinfo/Parser.pm
===================================================================
--- trunk/tp/Texinfo/Parser.pm  2017-06-29 14:13:30 UTC (rev 7876)
+++ trunk/tp/Texinfo/Parser.pm  2017-06-29 14:39:26 UTC (rev 7877)
@@ -252,7 +252,6 @@
 my %root_commands             = %Texinfo::Common::root_commands;
 my %sectioning_commands       = %Texinfo::Common::sectioning_commands;
 my %command_index             = %Texinfo::Common::command_index;
-my %command_structuring_level = %Texinfo::Common::command_structuring_level;
 my %ref_commands              = %Texinfo::Common::ref_commands;
 my %region_commands           = %Texinfo::Common::region_commands;
 my %code_style_commands       = %Texinfo::Common::code_style_commands;
@@ -5420,30 +5419,6 @@
   return $root;
 }
 
-my $min_level = $command_structuring_level{'chapter'};
-my $max_level = $command_structuring_level{'subsubsection'};
-
-# Return numbered level of an element
-sub _section_level($)
-{
-  my $section = shift;
-  my $level = $command_structuring_level{$section->{'cmdname'}};
-  # correct level according to raise/lowersections
-  if ($section->{'extra'} and $section->{'extra'}->{'sections_level'}) {
-    $level -= $section->{'extra'}->{'sections_level'};
-    if ($level < $min_level) {
-      if ($command_structuring_level{$section->{'cmdname'}} < $min_level) {
-        $level = $command_structuring_level{$section->{'cmdname'}};
-      } else {
-        $level = $min_level;
-      }
-    } elsif ($level > $max_level) {
-      $level = $max_level;
-    }
-  }
-  return $level;
-}
-
 # parse special line @-commands, unmacro, set, clear, clickstyle.
 # Also remove spaces or ignore text, as specified in the misc_commands hash.
 sub _parse_special_misc_command($$$$)

Modified: trunk/tp/Texinfo/Structuring.pm
===================================================================
--- trunk/tp/Texinfo/Structuring.pm     2017-06-29 14:13:30 UTC (rev 7876)
+++ trunk/tp/Texinfo/Structuring.pm     2017-06-29 14:39:26 UTC (rev 7877)
@@ -95,6 +95,31 @@
 $unnumbered_commands{'centerchap'} = 1;
 $unnumbered_commands{'part'} = 1;
 
+my $min_level = $command_structuring_level{'chapter'};
+my $max_level = $command_structuring_level{'subsubsection'};
+
+# Return numbered level of an element
+sub section_level($)
+{
+  my $section = shift;
+  my $level = $command_structuring_level{$section->{'cmdname'}};
+  # correct level according to raise/lowersections
+  if ($section->{'extra'} and $section->{'extra'}->{'sections_level'}) {
+    $level -= $section->{'extra'}->{'sections_level'};
+    if ($level < $min_level) {
+      if ($command_structuring_level{$section->{'cmdname'}} < $min_level) {
+        $level = $command_structuring_level{$section->{'cmdname'}};
+      } else {
+        $level = $min_level;
+      }
+    } elsif ($level > $max_level) {
+      $level = $max_level;
+    }
+  }
+  return $level;
+}
+
+
 # Go through the sectioning commands (e.g. @chapter, not @node), and
 # set:
 # 'number'
@@ -142,7 +167,7 @@
       }
     }
     my $level;
-    $level = $content->{'level'} = Texinfo::Parser::_section_level($content);
+    $level = $content->{'level'} = section_level($content);
     if (!defined($level)) {
       warn "bug: level not defined for $content->{'cmdname'}\n";
       $level = $content->{'level'} = 0;




reply via email to

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