[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Index entry line count adjustment
From: |
Gavin D. Smith |
Subject: |
branch master updated: Index entry line count adjustment |
Date: |
Sat, 18 Jan 2025 13:33:03 -0500 |
This is an automated email from the git hooks/post-receive script.
gavin pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new d613f00f28 Index entry line count adjustment
d613f00f28 is described below
commit d613f00f28c3a5db2f1e5dfc9808862b6af51846
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sat Jan 18 18:32:30 2025 +0000
Index entry line count adjustment
* tp/Texinfo/Convert/Plaintext.pm (_adjust_final_location):
New function, to decrement index entry line count at the end of
a node.
(convert_output_unit): Call it after processing footnotes.
(_convert) <contents>: Do not save current element on a
'current_roots' array.
(_convert) <index entry>: Do not check 'current_roots' array
for saved location at the end of a node.
This is arguably simpler and slightly quicker. This change has
minor consequences. If several index entries occur together at
the end of a node, they will all be adjusted. If an automatic
"*Menu" block is output at the end of a node, there will be
no adjustment. Adjustment in "plaintext" output is more limited.
---
ChangeLog | 20 ++++++
tp/Texinfo/Convert/Plaintext.pm | 75 ++++++++-------------
.../conversion_with_undef_customization.info | Bin 799 -> 799 bytes
.../converters_tests/sections_and_printindex.pl | 2 +-
tp/t/results/indices/double_index_entry.pl | 2 +-
tp/t/results/indices/index_and_node_same_name.pl | 2 +-
.../indices/index_nodes/res_plaintext/a-node.txt | 4 +-
.../index_nodes_no_split_no_use_nodes.txt | 4 +-
.../indices/printindex_between_node_section.pl | 12 ++--
.../indices/printindex_between_part_chapter.pl | 8 +--
tp/t/results/indices/sorted_subentries.pl | 44 ++++++------
.../res_parser/formatting_info/formatting.info | 2 +-
.../res_parser/formatting_plaintext/formatting.txt | 2 +-
.../res_parser/formatting_fr_info/formatting.info | 2 +-
.../formatting.info | 2 +-
.../formatting.info | 2 +-
.../formatting.txt | 2 +-
17 files changed, 92 insertions(+), 93 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 77f093be8e..30225a4854 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2025-01-18 Gavin Smith <gavinsmith0123@gmail.com>
+
+ Index entry line count adjustment
+
+ * tp/Texinfo/Convert/Plaintext.pm (_adjust_final_location):
+ New function, to decrement index entry line count at the end of
+ a node.
+ (convert_output_unit): Call it after processing footnotes.
+
+ (_convert) <contents>: Do not save current element on a
+ 'current_roots' array.
+ (_convert) <index entry>: Do not check 'current_roots' array
+ for saved location at the end of a node.
+
+ This is arguably simpler and slightly quicker. This change has
+ minor consequences. If several index entries occur together at
+ the end of a node, they will all be adjusted. If an automatic
+ "*Menu" block is output at the end of a node, there will be
+ no adjustment. Adjustment in "plaintext" output is more limited.
+
2025-01-18 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/utils.c (splitdir): add.
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 3e2e69e946..f6609b21c8 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -625,6 +625,7 @@ sub convert_output_unit($$)
}
$self->count_context_bug_message('', $output_unit);
$self->process_footnotes($output_unit);
+ _adjust_final_locations($self);
$self->count_context_bug_message('footnotes ', $output_unit);
return _stream_result($self);
@@ -1040,6 +1041,31 @@ sub add_location($$)
return $location;
}
+# Used at the end of an output unit. Decrement any location line counters
+# if equal to the current line count, as this could be past the end of a
+# node.
+sub _adjust_final_locations($)
+{
+ my $self = shift;
+ my $locations = $self->{'count_context'}->[-1]->{'locations'};
+ if (scalar(@$locations) > 0) {
+ my $i = @$locations - 1;
+ my $final_lines = $self->{'count_context'}->[-1]->{'lines'};
+ # return if $final_lines == 0;
+ my $last_location;
+ while ($i >= 0) {
+ if ($locations->[$i]->{'lines'} == $final_lines) {
+ $locations->[$i]->{'lines'}--;
+ $i--;
+ } else {
+ last;
+ }
+ }
+ }
+}
+
+
+
sub add_image($$$$;$)
{
my ($self, $element, $lines_count, $image_width, $no_align) = @_;
@@ -2830,52 +2856,7 @@ sub _convert($$)
if ($element->{'extra'} and $element->{'extra'}->{'index_entry'}
and !$self->{'multiple_pass'} and !$self->{'in_copying_header'}) {
my $location = $self->add_location($element);
- # remove a 'lines' from $location if at the very end of a node
- # since it will lead to the next node otherwise.
- if ($element->{'type'} and $element->{'type'} eq 'index_entry_command') {
- my $following_not_empty;
- # NOTE we cannot use the chain of $element->{'parent'} if a
- # converted element copies another element contents list
- # (as is the case for @insertcopying conversion or float caption in
- # listoffloats). Indeed, in that case, the elements parent will
- # be the original tree element, and not the element being converted.
- my $parents = $self->{'current_roots'};
- my $parents_nr = scalar(@$parents);
- my $current_child = $element;
- for (my $i = $parents_nr - 1; $i >= 0; $i--) {
- my $parent = $parents->[$i];
- my $parent_content = $parent->{'contents'};
-
- if ($parent->{'type'} and $parent->{'type'} eq 'paragraph') {
- $following_not_empty = 1;
- last;
- }
- my $n = scalar(@$parent_content);
- while ($n > 0) {
- $n--;
- my $following_content = $parent_content->[$n];
- last if $following_content == $current_child;
-
- unless (($following_content->{'type'}
- and ($following_content->{'type'} eq 'empty_line'
- or
$ignorable_space_types{$following_content->{'type'}}))
- or ($following_content->{'cmdname'}
- and ($following_content->{'cmdname'} eq 'c'
- or $following_content->{'cmdname'} eq 'comment'))) {
- $following_not_empty = 1;
- last;
- }
- }
- last if $following_not_empty;
- if ($parent->{'cmdname'} and $root_commands{$parent->{'cmdname'}}) {
- last;
- }
- $current_child = $parent;
- }
- if (! $following_not_empty) {
- $location->{'lines'}--;
- }
- }
+
# this covers the special case for index entry not associated with a
# node but seen. this will be an index entry in @copying,
# in @insertcopying.
@@ -4200,11 +4181,9 @@ sub _convert($$)
# The processing of contents is done here.
# $element->{'contents'} undef may happen for some empty commands/containers
if ($element->{'contents'}) {
- push @{$self->{'current_roots'}}, $element;
for my $content (@{$element->{'contents'}}) {
_convert($self, $content);
}
- pop @{$self->{'current_roots'}};
}
# now closing. First, close types.
diff --git
a/tp/t/results/converters_tests/conversion_with_undef_customization/res_info/conversion_with_undef_customization.info
b/tp/t/results/converters_tests/conversion_with_undef_customization/res_info/conversion_with_undef_customization.info
index 0900b859cb..678f7d471f 100644
Binary files
a/tp/t/results/converters_tests/conversion_with_undef_customization/res_info/conversion_with_undef_customization.info
and
b/tp/t/results/converters_tests/conversion_with_undef_customization/res_info/conversion_with_undef_customization.info
differ
diff --git a/tp/t/results/converters_tests/sections_and_printindex.pl
b/tp/t/results/converters_tests/sections_and_printindex.pl
index ab0817dfef..8c59c28059 100644
--- a/tp/t/results/converters_tests/sections_and_printindex.pl
+++ b/tp/t/results/converters_tests/sections_and_printindex.pl
@@ -612,7 +612,7 @@ Appendix A App
* Menu:
* entry1: node. (line 5)
-* entry2: sec. (line 8)
+* entry2: sec. (line 9)
';
diff --git a/tp/t/results/indices/double_index_entry.pl
b/tp/t/results/indices/double_index_entry.pl
index b3421e2ffc..e4703864a7 100644
--- a/tp/t/results/indices/double_index_entry.pl
+++ b/tp/t/results/indices/double_index_entry.pl
@@ -532,7 +532,7 @@ $result_converted{'plaintext'}->{'double_index_entry'} =
'Text
* Menu:
* aaa: Top. (line 0)
-* aaa <1>: Top. (line 2)
+* aaa <1>: Top. (line 1)
* aaa <2>: chap other node. (line 2)
';
diff --git a/tp/t/results/indices/index_and_node_same_name.pl
b/tp/t/results/indices/index_and_node_same_name.pl
index bffc543d11..ccbbaba2b9 100644
--- a/tp/t/results/indices/index_and_node_same_name.pl
+++ b/tp/t/results/indices/index_and_node_same_name.pl
@@ -438,7 +438,7 @@ in index node node, with the same name than index entry.
[index ]
* Menu:
-* node: Top. (line 7)
+* node: Top. (line 8)
Tag Table:
diff --git a/tp/t/results/indices/index_nodes/res_plaintext/a-node.txt
b/tp/t/results/indices/index_nodes/res_plaintext/a-node.txt
index 7552750cb2..1430eb63a9 100644
--- a/tp/t/results/indices/index_nodes/res_plaintext/a-node.txt
+++ b/tp/t/results/indices/index_nodes/res_plaintext/a-node.txt
@@ -7,7 +7,7 @@
* entry after printindex: a node. (line 49)
* entry in node: chap first. (line 30)
* entry in node <1>: chap first. (line 30)
-* something: another. (line 49)
+* something: another. (line 48)
* Menu:
@@ -18,5 +18,5 @@
* entry after printindex: a node. (line 49)
* entry in node: chap first. (line 30)
* entry in node <1>: chap first. (line 30)
-* something: another. (line 49)
+* something: another. (line 48)
diff --git
a/tp/t/results/indices/index_nodes_no_split_no_use_nodes/res_plaintext/index_nodes_no_split_no_use_nodes.txt
b/tp/t/results/indices/index_nodes_no_split_no_use_nodes/res_plaintext/index_nodes_no_split_no_use_nodes.txt
index d0d894d372..9ab85439be 100644
---
a/tp/t/results/indices/index_nodes_no_split_no_use_nodes/res_plaintext/index_nodes_no_split_no_use_nodes.txt
+++
b/tp/t/results/indices/index_nodes_no_split_no_use_nodes/res_plaintext/index_nodes_no_split_no_use_nodes.txt
@@ -51,7 +51,7 @@ Text and then index entries
* ! entry in node: chap first. (line 30)
* a concept a node: a node. (line 0)
-* another: another. (line 48)
+* another: another. (line 49)
* entry a: Top. (line 0)
* entry after printindex: a node. (line 49)
* entry in node: chap first. (line 30)
@@ -62,7 +62,7 @@ Text and then index entries
* ! entry in node: chap first. (line 30)
* a concept a node: a node. (line 60)
-* another: another. (line 48)
+* another: another. (line 49)
* entry a: Top. (line 0)
* entry after printindex: a node. (line 49)
* entry in node: chap first. (line 30)
diff --git a/tp/t/results/indices/printindex_between_node_section.pl
b/tp/t/results/indices/printindex_between_node_section.pl
index 0072d0355c..62af5beaea 100644
--- a/tp/t/results/indices/printindex_between_node_section.pl
+++ b/tp/t/results/indices/printindex_between_node_section.pl
@@ -729,9 +729,9 @@ File: , Node: node sec1, Up: node chap1
* Menu:
* aop1: Top. (line 6)
-* aop1 <1>: Top. (line 5)
+* aop1 <1>: Top. (line 6)
* chap1: node chap1. (line 6)
-* chap1 <1>: node chap1. (line 5)
+* chap1 <1>: node chap1. (line 6)
* top1: Top. (line 6)
* top1 <1>: Top. (line 6)
@@ -761,12 +761,12 @@
$result_converted{'plaintext'}->{'printindex_between_node_section'} = 'top
* Menu:
-* aop1: Top. (line 3)
+* aop1: Top. (line 2)
* aop1 <1>: Top. (line 2)
-* chap1: node chap1. (line 6)
+* chap1: node chap1. (line 5)
* chap1 <1>: node chap1. (line 5)
-* top1: Top. (line 3)
-* top1 <1>: Top. (line 3)
+* top1: Top. (line 2)
+* top1 <1>: Top. (line 2)
1.1 section1
============
diff --git a/tp/t/results/indices/printindex_between_part_chapter.pl
b/tp/t/results/indices/printindex_between_part_chapter.pl
index 46403c3d79..885900c559 100644
--- a/tp/t/results/indices/printindex_between_part_chapter.pl
+++ b/tp/t/results/indices/printindex_between_part_chapter.pl
@@ -813,7 +813,7 @@ Part: Part 1
* Menu:
* aop1: Top. (line 6)
-* aop1 <1>: Top. (line 5)
+* aop1 <1>: Top. (line 6)
* chap2: node chap2. (line 4)
* chap2 <1>: node chap2. (line 4)
* top1: Top. (line 6)
@@ -851,12 +851,12 @@
$result_converted{'plaintext'}->{'printindex_between_part_chapter'} = 'top
* Menu:
-* aop1: Top. (line 3)
+* aop1: Top. (line 2)
* aop1 <1>: Top. (line 2)
* chap2: node chap2. (line 0)
* chap2 <1>: node chap2. (line 0)
-* top1: Top. (line 3)
-* top1 <1>: Top. (line 3)
+* top1: Top. (line 2)
+* top1 <1>: Top. (line 2)
1 chapter 1
***********
diff --git a/tp/t/results/indices/sorted_subentries.pl
b/tp/t/results/indices/sorted_subentries.pl
index 642f40734e..2d4ba9211d 100644
--- a/tp/t/results/indices/sorted_subentries.pl
+++ b/tp/t/results/indices/sorted_subentries.pl
@@ -2106,24 +2106,24 @@ File: , Node: chapter second, Prev: chapter one, Up:
Top
[index ]
* Menu:
-* aa, bb: chapter one. (line 6)
-* aa, dd: chapter one. (line 6)
-* ab, cc: chapter one. (line 6)
-* bb, cc: chapter one. (line 6)
-* hhh: chapter one. (line 6)
+* aa, bb: chapter one. (line 5)
+* aa, dd: chapter one. (line 5)
+* ab, cc: chapter one. (line 5)
+* bb, cc: chapter one. (line 5)
+* hhh: chapter one. (line 5)
* hhh <1>: chapter second. (line 6)
-* hhh, : chapter one. (line 6)
-* hhh, jjj: chapter one. (line 6)
+* hhh, : chapter one. (line 5)
+* hhh, jjj: chapter one. (line 5)
* hhh, jjj <1>: chapter second. (line 6)
* hhh, jjj, lll: chapter second. (line 6)
-* hhh, jjj, lll <1>: chapter one. (line 6)
+* hhh, jjj, lll <1>: chapter one. (line 5)
* hhh, jjj, lll <2>: chapter second. (line 6)
-* hhh, jjj, lll, ppp: chapter one. (line 6)
+* hhh, jjj, lll, ppp: chapter one. (line 5)
* hhh, JJJ, mymail <jjj>: chapter second. (line 6)
-* hhh, k: chapter one. (line 6)
+* hhh, k: chapter one. (line 5)
* hhh, k, nnn: chapter second. (line 6)
* hhh, l, third: chapter second. (line 6)
-* hhh jjj: chapter one. (line 6)
+* hhh jjj: chapter one. (line 5)
Tag Table:
@@ -2148,24 +2148,24 @@ $result_converted{'plaintext'}->{'sorted_subentries'} =
'1 one
* Menu:
-* aa, bb: chapter one. (line 3)
-* aa, dd: chapter one. (line 3)
-* ab, cc: chapter one. (line 3)
-* bb, cc: chapter one. (line 3)
-* hhh: chapter one. (line 3)
+* aa, bb: chapter one. (line 2)
+* aa, dd: chapter one. (line 2)
+* ab, cc: chapter one. (line 2)
+* bb, cc: chapter one. (line 2)
+* hhh: chapter one. (line 2)
* hhh <1>: chapter second. (line 6)
-* hhh, : chapter one. (line 3)
-* hhh, jjj: chapter one. (line 3)
+* hhh, : chapter one. (line 2)
+* hhh, jjj: chapter one. (line 2)
* hhh, jjj <1>: chapter second. (line 6)
* hhh, jjj, lll: chapter second. (line 6)
-* hhh, jjj, lll <1>: chapter one. (line 3)
+* hhh, jjj, lll <1>: chapter one. (line 2)
* hhh, jjj, lll <2>: chapter second. (line 6)
-* hhh, jjj, lll, ppp: chapter one. (line 3)
+* hhh, jjj, lll, ppp: chapter one. (line 2)
* hhh, JJJ, mymail <jjj>: chapter second. (line 6)
-* hhh, k: chapter one. (line 3)
+* hhh, k: chapter one. (line 2)
* hhh, k, nnn: chapter second. (line 6)
* hhh, l, third: chapter second. (line 6)
-* hhh jjj: chapter one. (line 3)
+* hhh jjj: chapter one. (line 2)
';
diff --git a/tp/tests/coverage/res_parser/formatting_info/formatting.info
b/tp/tests/coverage/res_parser/formatting_info/formatting.info
index 3e286b3372..011becfa2f 100644
--- a/tp/tests/coverage/res_parser/formatting_info/formatting.info
+++ b/tp/tests/coverage/res_parser/formatting_info/formatting.info
@@ -3430,7 +3430,7 @@ chapter 2
* b <1>: chapter. (line 1223)
* b <2>: chapter. (line 2056)
* b--b, c--c: chapter. (line 2281)
-* counting entry: chapter. (line 2636)
+* counting entry: chapter. (line 2637)
* d--dd, e--ee, f--ff: chapter. (line 2281)
* d--efcv_name: chapter. (line 366)
* d--efcv_name <1>: chapter. (line 369)
diff --git a/tp/tests/coverage/res_parser/formatting_plaintext/formatting.txt
b/tp/tests/coverage/res_parser/formatting_plaintext/formatting.txt
index c700ce2f39..ee7b78c976 100644
--- a/tp/tests/coverage/res_parser/formatting_plaintext/formatting.txt
+++ b/tp/tests/coverage/res_parser/formatting_plaintext/formatting.txt
@@ -2646,7 +2646,7 @@ chapter 2
* b <1>: chapter. (line 1211)
* b <2>: chapter. (line 2042)
* b--b, c--c: chapter. (line 2267)
-* counting entry: chapter. (line 2609)
+* counting entry: chapter. (line 2610)
* d--dd, e--ee, f--ff: chapter. (line 2267)
* d--efcv_name: chapter. (line 366)
* d--efcv_name <1>: chapter. (line 369)
diff --git a/tp/tests/layout/res_parser/formatting_fr_info/formatting.info
b/tp/tests/layout/res_parser/formatting_fr_info/formatting.info
index 46a8253b3f..eda94ed478 100644
--- a/tp/tests/layout/res_parser/formatting_fr_info/formatting.info
+++ b/tp/tests/layout/res_parser/formatting_fr_info/formatting.info
@@ -3430,7 +3430,7 @@ chapter 2
* b <1>: chapter. (line 1223)
* b <2>: chapter. (line 2056)
* b--b, c--c: chapter. (line 2281)
-* counting entry: chapter. (line 2636)
+* counting entry: chapter. (line 2637)
* d--dd, e--ee, f--ff: chapter. (line 2281)
* d--efcv_name: chapter. (line 366)
* d--efcv_name <1>: chapter. (line 369)
diff --git
a/tp/tests/layout/res_parser/formatting_info_ascii_punctuation/formatting.info
b/tp/tests/layout/res_parser/formatting_info_ascii_punctuation/formatting.info
index 94dc9fab26..8da4ee27bc 100644
---
a/tp/tests/layout/res_parser/formatting_info_ascii_punctuation/formatting.info
+++
b/tp/tests/layout/res_parser/formatting_info_ascii_punctuation/formatting.info
@@ -3430,7 +3430,7 @@ chapter 2
* b <1>: chapter. (line 1223)
* b <2>: chapter. (line 2056)
* b--b, c--c: chapter. (line 2281)
-* counting entry: chapter. (line 2636)
+* counting entry: chapter. (line 2637)
* d--dd, e--ee, f--ff: chapter. (line 2281)
* d--efcv_name: chapter. (line 366)
* d--efcv_name <1>: chapter. (line 369)
diff --git
a/tp/tests/layout/res_parser/formatting_info_disable_encoding/formatting.info
b/tp/tests/layout/res_parser/formatting_info_disable_encoding/formatting.info
index d71c04366e..bcc5156ed0 100644
---
a/tp/tests/layout/res_parser/formatting_info_disable_encoding/formatting.info
+++
b/tp/tests/layout/res_parser/formatting_info_disable_encoding/formatting.info
@@ -3430,7 +3430,7 @@ chapter 2
* b <1>: chapter. (line 1223)
* b <2>: chapter. (line 2056)
* b--b, c--c: chapter. (line 2281)
-* counting entry: chapter. (line 2636)
+* counting entry: chapter. (line 2637)
* d--dd, e--ee, f--ff: chapter. (line 2281)
* d--efcv_name: chapter. (line 366)
* d--efcv_name <1>: chapter. (line 369)
diff --git
a/tp/tests/layout/res_parser/formatting_plaintext_ascii_punctuation/formatting.txt
b/tp/tests/layout/res_parser/formatting_plaintext_ascii_punctuation/formatting.txt
index 980ba80743..b55ba46083 100644
---
a/tp/tests/layout/res_parser/formatting_plaintext_ascii_punctuation/formatting.txt
+++
b/tp/tests/layout/res_parser/formatting_plaintext_ascii_punctuation/formatting.txt
@@ -2646,7 +2646,7 @@ chapter 2
* b <1>: chapter. (line 1211)
* b <2>: chapter. (line 2042)
* b--b, c--c: chapter. (line 2267)
-* counting entry: chapter. (line 2609)
+* counting entry: chapter. (line 2610)
* d--dd, e--ee, f--ff: chapter. (line 2267)
* d--efcv_name: chapter. (line 366)
* d--efcv_name <1>: chapter. (line 369)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Index entry line count adjustment,
Gavin D. Smith <=