[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Structuring.pm (index_entry_element_
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Structuring.pm (index_entry_element_sort_string) (_index_entry_element_sort_string_key, setup_sortable_index_entries): replace index_entry_sort_string by index_entry_element_sort_string, using the element associated to the index entry or @subentry as argument, and determining the sortas and content in the function. Update callers. |
Date: |
Sun, 07 Jan 2024 08:25:28 -0500 |
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 45dff4526f * tp/Texinfo/Structuring.pm
(index_entry_element_sort_string) (_index_entry_element_sort_string_key,
setup_sortable_index_entries): replace index_entry_sort_string by
index_entry_element_sort_string, using the element associated to the index
entry or @subentry as argument, and determining the sortas and content in the
function. Update callers.
45dff4526f is described below
commit 45dff4526f1d9b7236d49fa0dcd38c9df6e3458f
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jan 7 14:25:28 2024 +0100
* tp/Texinfo/Structuring.pm (index_entry_element_sort_string)
(_index_entry_element_sort_string_key, setup_sortable_index_entries):
replace index_entry_sort_string by index_entry_element_sort_string,
using the element associated to the index entry or @subentry as
argument, and determining the sortas and content in the function.
Update callers.
* tp/Texinfo/Convert/LaTeX.pm (_index_entry): simplify code by using
only an array of index entry element commands, for the main entry and
the @subentry. Rename variables.
---
ChangeLog | 13 ++++++++++
tp/Texinfo/Convert/LaTeX.pm | 44 +++++++++++++-------------------
tp/Texinfo/Structuring.pm | 61 ++++++++++++++++++++++++---------------------
3 files changed, 62 insertions(+), 56 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a61311bb0f..f4b45139ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-01-07 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Structuring.pm (index_entry_element_sort_string)
+ (_index_entry_element_sort_string_key, setup_sortable_index_entries):
+ replace index_entry_sort_string by index_entry_element_sort_string,
+ using the element associated to the index entry or @subentry as
+ argument, and determining the sortas and content in the function.
+ Update callers.
+
+ * tp/Texinfo/Convert/LaTeX.pm (_index_entry): simplify code by using
+ only an array of index entry element commands, for the main entry and
+ the @subentry. Rename variables.
+
2024-01-07 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/get_html_perl_info.c
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index a404809230..3d35ec8b18 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -2431,42 +2431,32 @@ sub _index_entry($$)
}
my $options
= Texinfo::Structuring::setup_index_entry_keys_formatting($self);
- my $current_entry = $element;
- my $current_sortas;
- my $subentry_commands = [$element];
- if (exists($element->{'extra'}->{'sortas'})) {
- $current_sortas = $element->{'extra'}->{'sortas'};
- }
- my $subentries = [[Texinfo::Common::index_content_element($element, 1),
- $current_sortas]];
- while ($current_entry->{'extra'}
- and $current_entry->{'extra'}->{'subentry'}) {
- $current_entry = $current_entry->{'extra'}->{'subentry'};
- my $current_sortas;
- if (exists($current_entry->{'extra'}->{'sortas'})) {
- $current_sortas = $current_entry->{'extra'}->{'sortas'};
- }
- push @$subentries, [$current_entry->{'args'}->[0], $current_sortas];
- push @$subentry_commands, $current_entry;
+ my @subindex_commands = ($element);
+ my $current_element = $element;
+ while ($current_element->{'extra'}
+ and $current_element->{'extra'}->{'subentry'}) {
+ $current_element = $current_element->{'extra'}->{'subentry'};
+ push @subindex_commands, $current_element;
}
_push_new_context($self, 'index_entry');
$self->{'formatting_context'}->[-1]->{'index'} = 1;
my @result;
- foreach my $subentry_entry_and_sortas (@$subentries) {
- my ($subentry, $subentry_sortas) = @$subentry_entry_and_sortas;
+ foreach my $subindex_command (@subindex_commands) {
+ my $content
+ = Texinfo::Common::index_content_element($subindex_command, 1);
if ($in_code) {
push @{$self->{'formatting_context'}->[-1]->{'code'}}, 1;
}
- my $index_entry = _convert($self, $subentry);
+ my $index_entry = _convert($self, $content);
if ($in_code) {
pop @{$self->{'formatting_context'}->[-1]->{'code'}};
}
# always setup a string to sort with as we may use commands
my $convert_to_text_options = {%$options, 'code' => $in_code};
my $sort_string
- = Texinfo::Structuring::index_entry_sort_string($entry,
- $subentry, $subentry_sortas,
- $convert_to_text_options);
+ = Texinfo::Structuring::index_entry_element_sort_string($entry,
+ $subindex_command,
+ $convert_to_text_options, 1);
my $result = '';
if (defined($sort_string)) {
# | in sort key breaks with hyperref
@@ -2484,12 +2474,12 @@ sub _index_entry($$)
}
my $seeresult = '';
SEEENTRY:
- foreach my $subentry_command (@$subentry_commands) {
+ foreach my $subindex_command (@subindex_commands) {
foreach my $seecommand (('seeentry', 'seealso')) {
- if ($subentry_command->{'extra'}->{$seecommand}
- and $subentry_command->{'extra'}->{$seecommand}->{'args'}->[0]) {
+ if ($subindex_command->{'extra'}->{$seecommand}
+ and $subindex_command->{'extra'}->{$seecommand}->{'args'}->[0]) {
my $seeconverted = _convert($self,
- $subentry_command->{'extra'}->{$seecommand}->{'args'}->[0]);
+ $subindex_command->{'extra'}->{$seecommand}->{'args'}->[0]);
$seeresult = '|'.$LaTeX_see_index_commands_text{$seecommand}.'{'
.$seeconverted.'}';
last SEEENTRY;
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index 6bcdd2b0f6..89baa4ee2a 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -114,6 +114,9 @@ our %XS_overrides = (
"Texinfo::Structuring::_XS_unsplit"
=> "Texinfo::StructTransfXS::unsplit",
+# "Texinfo::Structuring::index_entry_element_sort_string"
+# => "Texinfo::StructTransfXS::index_entry_element_sort_string",
+
# Not useful for HTML as functions, as the calling functions are
# already overriden
# Could be readded when other converters than HTML are done in C
@@ -2279,17 +2282,21 @@ sub setup_index_entry_keys_formatting($)
}
# can be used for subentries
-sub index_entry_sort_string($$$$)
+sub index_entry_element_sort_string($$$;$)
{
my $main_entry = shift;
- my $entry_tree_element = shift;
- my $sortas = shift;
+ my $index_entry_element = shift;
my $options = shift;
+ my $prefer_reference_element = shift;
my $sort_string;
- if (defined($sortas)) {
- $sort_string = $sortas;
+ if ($index_entry_element->{'extra'}
+ and defined($index_entry_element->{'extra'}->{'sortas'})) {
+ $sort_string = $index_entry_element->{'extra'}->{'sortas'};
} else {
+ my $entry_tree_element
+ = Texinfo::Common::index_content_element($index_entry_element,
+ $prefer_reference_element);
$sort_string = Texinfo::Convert::Text::convert_to_text(
$entry_tree_element, $options);
# FIXME do that for sortas too?
@@ -2305,16 +2312,17 @@ sub index_entry_sort_string($$$$)
return $sort_string;
}
-sub _index_entry_sort_string_key($$$$;$)
+sub _index_entry_element_sort_string_key($$$$;$)
{
my $main_entry = shift;
- my $entry_tree_element = shift;
- my $sortas = shift;
+ my $index_entry_element = shift;
my $options = shift;
my $collator = shift;
+ my $prefer_reference_element = shift;
- my $sort_string = index_entry_sort_string ($main_entry, $entry_tree_element,
- $sortas, $options);
+ my $sort_string = index_entry_element_sort_string ($main_entry,
+ $index_entry_element,
+ $options, $prefer_reference_element);
# This avoids varying results depending on whether the string is
# represented internally in UTF-8. See 'the "Unicode bug"' in the
@@ -2458,15 +2466,11 @@ sub setup_sortable_index_entries($$$$$;$)
foreach my $index_entry (@{$index_entries->{$index_name}}) {
my $entry_index_name = $index_entry->{'index_name'};
my $main_entry_element = $index_entry->{'entry_element'};
- my $main_entry_sortas;
my $convert_to_text_options = {%$options,
'code' => $indices_information->{$entry_index_name}->{'in_code'}};
- $main_entry_sortas = $main_entry_element->{'extra'}->{'sortas'}
- if ($main_entry_element->{'extra'});
my ($entry_key, $sort_entry_key)
- = _index_entry_sort_string_key($index_entry,
- Texinfo::Common::index_content_element($main_entry_element),
- $main_entry_sortas,
+ = _index_entry_element_sort_string_key($index_entry,
+ $main_entry_element,
$convert_to_text_options, $entries_collator);
my @entry_keys;
my @sort_entry_keys;
@@ -2494,11 +2498,9 @@ sub setup_sortable_index_entries($$$$$;$)
$subentry_nr ++;
$subentry = $subentry->{'extra'}->{'subentry'};
my ($subentry_key, $sort_subentry_key)
- = _index_entry_sort_string_key($index_entry,
- {'contents' => $subentry->{'args'}->[0]->{'contents'}},
- $subentry->{'extra'}->{'sortas'},
- $convert_to_text_options,
- $entries_collator);
+ = _index_entry_element_sort_string_key($index_entry,
+ $subentry, $convert_to_text_options,
+ $entries_collator);
if ($subentry_key !~ /\S/) {
my $entry_cmdname = $main_entry_element->{'cmdname'};
$entry_cmdname
@@ -2877,17 +2879,18 @@ I<$node> is a node tree element. Find the node
I<$node> children based
on the sectioning structure. For the node associated with C<@top>
sectioning command, the sections associated with parts are considered.
-=item $entry_key = index_entry_sort_string($main_entry, $entry_tree_element,
$sortas, $options)
-X<C<index_entry_sort_string>>
+=item $sort_string = index_entry_element_sort_string($main_entry,
$index_entry_element, $options, $prefer_reference_element)
+X<C<index_entry_element_sort_string>>
Return a string suitable as a sort string, for index entries.
-The index entry processed is I<$entry_tree_element>, and can be a
-C<@subentry>. I<$main_entry> is the main index entry tree element
-that can be used to gather information. I<$sortas> can be given to
-override the sort string (typically obtained from C<@sortas>). The
-I<$options> are options used for Texinfo to text conversion for
-the generation of the sort string, typically obtained from
+The tree element index entry processed is I<$index_entry_element>,
+and can be a C<@subentry>. I<$main_entry> is the main index entry
+that can be used to gather information. The I<$options> are options
+used for Texinfo to text conversion for the generation of the sort
+string, typically obtained from
L<setup_index_entry_keys_formatting|/$option =
setup_index_entry_keys_formatting($customization_information)>.
+If I<$prefer_reference_element> is set, prefer an untranslated
+element for the formatting as sort string.
=item $merged_entries = merge_indices($indices_information)
X<C<merge_indices>>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Structuring.pm (index_entry_element_sort_string) (_index_entry_element_sort_string_key, setup_sortable_index_entries): replace index_entry_sort_string by index_entry_element_sort_string, using the element associated to the index entry or @subentry as argument, and determining the sortas and content in the function. Update callers.,
Patrice Dumas <=