[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6666] lower and raisesections for @heading commands
From: |
Gavin D. Smith |
Subject: |
[6666] lower and raisesections for @heading commands |
Date: |
Fri, 02 Oct 2015 14:54:50 +0000 |
Revision: 6666
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6666
Author: gavin
Date: 2015-10-02 14:54:49 +0000 (Fri, 02 Oct 2015)
Log Message:
-----------
lower and raisesections for @heading commands
Modified Paths:
--------------
trunk/ChangeLog
trunk/tp/Texinfo/Parser.pm
trunk/tp/Texinfo/Structuring.pm
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2015-10-02 14:43:32 UTC (rev 6665)
+++ trunk/ChangeLog 2015-10-02 14:54:49 UTC (rev 6666)
@@ -1,5 +1,19 @@
2015-10-02 Gavin Smith <address@hidden>
+ * tp/Texinfo/Structuring.pm (_section_level): Function moved to
+ tp/Texinfo/Parser.pm. All uses updated to access 'level' value
+ of element instead.
+ * tp/Texinfo/Parser.pm (_end_line) <command is in in
+ command_structuring_level>: Don't set 'level' value.
+ (_parse_texi) <sectioning commands>: Set 'sections_level' extra
+ value on element, and set 'level' value by calling _section_level.
+ Do it for all sectioning elements, and not just those that are
+ "root commands", to include @heading and similar. This is
+ intended to make @heading affected by @lowersections and
+ @raisesections, reported by Quinn Greer not to work.
+
+2015-10-02 Gavin Smith <address@hidden>
+
* tp/Changes: File deleted.
2015-10-02 Gavin Smith <address@hidden>
Modified: trunk/tp/Texinfo/Parser.pm
===================================================================
--- trunk/tp/Texinfo/Parser.pm 2015-10-02 14:43:32 UTC (rev 6665)
+++ trunk/tp/Texinfo/Parser.pm 2015-10-02 14:54:49 UTC (rev 6666)
@@ -3443,9 +3443,6 @@
$current->{'type'} = 'index_entry_command';
}
}
- if (defined($command_structuring_level{$command})) {
- $current->{'level'} = $command_structuring_level{$command};
- }
}
$current = $current->{'parent'};
if ($end_command) {
@@ -4715,10 +4712,12 @@
$misc = { 'cmdname' => $command, 'parent' => $current,
'line_nr' => $line_nr };
push @{$current->{'contents'}}, $misc;
- if ($self->{'sections_level'} and $root_commands{$command}
- and $command ne 'node' and $command ne 'part') {
- $current->{'contents'}->[-1]->{'extra'}->{'sections_level'}
- = $self->{'sections_level'};
+ if ($sectioning_commands{$command}) {
+ if ($self->{'sections_level'}) {
+ $current->{'contents'}->[-1]->{'extra'}->{'sections_level'}
+ = $self->{'sections_level'};
+ }
+ $misc->{'level'} = _section_level($misc);
}
# def*x
if ($def_commands{$command}) {
@@ -5593,7 +5592,30 @@
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 2015-10-02 14:43:32 UTC (rev 6665)
+++ trunk/tp/Texinfo/Structuring.pm 2015-10-02 14:54:49 UTC (rev 6666)
@@ -156,30 +156,7 @@
$unnumbered_commands{'centerchap'} = 1;
$unnumbered_commands{'part'} = 1;
-my $min_level = $command_structuring_level{'chapter'};
-my $max_level = $command_structuring_level{'subsubsection'};
-
-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;
-}
# sets:
-# 'level'
# 'number'
# 'section_childs'
# 'section_up'
@@ -222,8 +199,11 @@
$section_top = $content;
}
}
- my $level = _section_level($content);
- $content->{'level'} = $level;
+ my $level = $content->{'level'};
+ if (!defined($level)) {
+ warn "bug: level not defined for $content->{'cmdname'}\n";
+ $level = $content->{'level'} = 0;
+ }
if ($previous_section) {
# new command is below
@@ -439,11 +419,11 @@
next;
}
my $current_section = shift @sections_list;
- my $current_section_level = _section_level($current_section);
+ my $current_section_level = $current_section->{'level'};
my $next_section = $sections_list[0];
if (defined($next_section)) {
- my $next_section_level = _section_level($next_section);
+ my $next_section_level = $next_section->{'level'};
if ($next_section_level - $current_section_level > 1) {
my @correct_level_offset_commands = _correct_level($next_section,
$contents[-1]);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6666] lower and raisesections for @heading commands,
Gavin D. Smith <=