[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/HTML.pm (_prepare_index_entr
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Convert/HTML.pm (_prepare_index_entries), tp/Texinfo/Convert/IXIN.pm, tp/Texinfo/Convert/LaTeX.pm (_index_entry), tp/Texinfo/Convert/Plaintext.pm (process_printindex), tp/Texinfo/Structuring.pm (index_entry_sort_string, sort_indices), tp/init/chm.pm (chm_init), tp/t/test_sort.t, tp/t/test_utils.pl (test): pass indices_information to sort_indices. Set 'code' in options for text conversion before calling index_entry_sort_string, based on indices_information. |
Date: |
Wed, 08 Mar 2023 04:29:19 -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 b7396149cb * tp/Texinfo/Convert/HTML.pm (_prepare_index_entries),
tp/Texinfo/Convert/IXIN.pm, tp/Texinfo/Convert/LaTeX.pm (_index_entry),
tp/Texinfo/Convert/Plaintext.pm (process_printindex), tp/Texinfo/Structuring.pm
(index_entry_sort_string, sort_indices), tp/init/chm.pm (chm_init),
tp/t/test_sort.t, tp/t/test_utils.pl (test): pass indices_information to
sort_indices. Set 'code' in options for text conversion before calling
index_entry_sort_string, based on indices_information.
b7396149cb is described below
commit b7396149cba15c89392615d58fdf2befcd021ff7
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Mar 8 10:28:57 2023 +0100
* tp/Texinfo/Convert/HTML.pm (_prepare_index_entries),
tp/Texinfo/Convert/IXIN.pm, tp/Texinfo/Convert/LaTeX.pm
(_index_entry), tp/Texinfo/Convert/Plaintext.pm (process_printindex),
tp/Texinfo/Structuring.pm (index_entry_sort_string, sort_indices),
tp/init/chm.pm (chm_init), tp/t/test_sort.t, tp/t/test_utils.pl (test):
pass indices_information to sort_indices. Set 'code' in options for
text conversion before calling index_entry_sort_string, based on
indices_information.
* tp/Texinfo/Translations.pm (complete_indices): do not set in_code
for index entries, the information should always be taken from the
entry associated index name.
* tp/Texinfo/Structuring.pm (sort_indices): rename $entry as
$index_entry.
* tp/Texinfo/Convert/HTML.pm (_prepare_index_entries),
tp/Texinfo/Convert/Plaintext.pm (process_printindex): rename
$index_names as $indices_information.
* tp/Texinfo/Convert/TexinfoMarkup.pm (_index_entry): use associated
index information, and not the entry information to determine if index
entry is in code style.
---
ChangeLog | 26 ++++++++++++++++++++++
tp/Texinfo/Convert/HTML.pm | 15 ++++++++-----
tp/Texinfo/Convert/IXIN.pm | 11 +++++-----
tp/Texinfo/Convert/LaTeX.pm | 4 +++-
tp/Texinfo/Convert/Plaintext.pm | 9 ++++----
tp/Texinfo/Convert/TexinfoMarkup.pm | 20 ++++++++---------
tp/Texinfo/Structuring.pm | 44 +++++++++++++++++++++----------------
tp/Texinfo/Translations.pm | 4 +---
tp/init/chm.pm | 3 ++-
tp/t/test_sort.t | 7 +++---
tp/t/test_utils.pl | 3 ++-
11 files changed, 92 insertions(+), 54 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f4335f3555..f49d111d62 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2023-03-07 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/HTML.pm (_prepare_index_entries),
+ tp/Texinfo/Convert/IXIN.pm, tp/Texinfo/Convert/LaTeX.pm
+ (_index_entry), tp/Texinfo/Convert/Plaintext.pm (process_printindex),
+ tp/Texinfo/Structuring.pm (index_entry_sort_string, sort_indices),
+ tp/init/chm.pm (chm_init), tp/t/test_sort.t, tp/t/test_utils.pl (test):
+ pass indices_information to sort_indices. Set 'code' in options for
+ text conversion before calling index_entry_sort_string, based on
+ indices_information.
+
+ * tp/Texinfo/Translations.pm (complete_indices): do not set in_code
+ for index entries, the information should always be taken from the
+ entry associated index name.
+
+ * tp/Texinfo/Structuring.pm (sort_indices): rename $entry as
+ $index_entry.
+
+ * tp/Texinfo/Convert/HTML.pm (_prepare_index_entries),
+ tp/Texinfo/Convert/Plaintext.pm (process_printindex): rename
+ $index_names as $indices_information.
+
+ * tp/Texinfo/Convert/TexinfoMarkup.pm (_index_entry): use associated
+ index information, and not the entry information to determine if index
+ entry is in code style.
+
2023-03-07 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Common.pm (lookup_index_entry): lookup_index_entry also
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 7b67993241..5bdc708eef 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -9250,22 +9250,25 @@ sub _prepare_index_entries($)
{
my $self = shift;
- my $index_names = $self->{'indices_information'};
- if ($index_names) {
+ my $indices_information = $self->{'indices_information'};
+ if ($indices_information) {
my $no_unidecode;
$no_unidecode = 1 if (defined($self->get_conf('USE_UNIDECODE'))
and !$self->get_conf('USE_UNIDECODE'));
my $merged_index_entries
- = Texinfo::Structuring::merge_indices($index_names);
+ = Texinfo::Structuring::merge_indices($indices_information);
my $index_entries_sort_strings;
($self->{'index_entries_by_letter'}, $index_entries_sort_strings)
= Texinfo::Structuring::sort_indices($self,
- $self, $merged_index_entries, 'by_letter');
+ $self, $merged_index_entries,
+ $indices_information,
+ 'by_letter');
$self->{'index_entries'} = $merged_index_entries;
- foreach my $index_name (sort(keys(%$index_names))) {
- foreach my $index_entry
(@{$index_names->{$index_name}->{'index_entries'}}) {
+ foreach my $index_name (sort(keys(%$indices_information))) {
+ foreach my $index_entry (@{$indices_information->{$index_name}
+ ->{'index_entries'}}) {
my $main_entry_element = $index_entry->{'entry_element'};
# does not refer to the document
next if ($main_entry_element->{'extra'}
diff --git a/tp/Texinfo/Convert/IXIN.pm b/tp/Texinfo/Convert/IXIN.pm
index 3821cb7f5e..8264b0774d 100644
--- a/tp/Texinfo/Convert/IXIN.pm
+++ b/tp/Texinfo/Convert/IXIN.pm
@@ -678,13 +678,14 @@ sub output_ixin($$)
my %dts_information;
- my $index_names = $self->{'indices_information'};
- if ($index_names) {
+ my $indices_information = $self->{'indices_information'};
+ if ($indices_information) {
my $merged_index_entries
- = Texinfo::Structuring::merge_indices($index_names);
+ = Texinfo::Structuring::merge_indices($indices_information);
my ($entries, $index_entries_sort_strings)
- = Texinfo::Structuring::sort_indices($self,
- $self, $merged_index_entries);
+ = Texinfo::Structuring::sort_indices($self, $self,
+ $merged_index_entries,
+ $indices_information);
# first do the dts_text as the counts are needed for the dts index
foreach my $index_name (sort(keys(%$entries))) {
$dts_information{$index_name} = {};
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 6f962be3da..e45ae200c0 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -2455,9 +2455,11 @@ sub _index_entry($$)
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 ($sortas, $sort_string)
= Texinfo::Structuring::index_entry_sort_string($entry,
- $subentry, $subentry_sortas, $options);
+ $subentry, $subentry_sortas,
+ $convert_to_text_options);
my $result = '';
if (defined($sortas)) {
# | in sort key breaks with hyperref
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index bb51808a32..22a6fce3b5 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -1358,15 +1358,16 @@ sub process_printindex($$;$)
}
# this is not redone for each index, only once
- my $index_names = $self->{'indices_information'};
- if (!defined($self->{'index_entries'}) and $index_names) {
+ my $indices_information = $self->{'indices_information'};
+ if (!defined($self->{'index_entries'}) and $indices_information) {
my $merged_index_entries
- = Texinfo::Structuring::merge_indices($index_names);
+ = Texinfo::Structuring::merge_indices($indices_information);
my $index_entries_sort_strings;
($self->{'index_entries'}, $index_entries_sort_strings)
= Texinfo::Structuring::sort_indices($self, $self,
- $merged_index_entries);
+ $merged_index_entries,
+ $indices_information);
}
if (!$self->{'index_entries'} or !$self->{'index_entries'}->{$index_name}
or ! @{$self->{'index_entries'}->{$index_name}}) {
diff --git a/tp/Texinfo/Convert/TexinfoMarkup.pm
b/tp/Texinfo/Convert/TexinfoMarkup.pm
index 2f268ddad9..9656cab057 100644
--- a/tp/Texinfo/Convert/TexinfoMarkup.pm
+++ b/tp/Texinfo/Convert/TexinfoMarkup.pm
@@ -376,21 +376,19 @@ sub _index_entry($$)
if (defined($index_entry->{'entry_number'}));
# in case the index is not a default index, or the style of the
# entry (in code or not) is not the default for this index
- if ($self->{'indices_information'}) {
- my $entry_index_name = $index_entry->{'index_name'};
- my $in_code = $index_info->{'in_code'};
- if (!$Texinfo::Commands::index_names{$entry_index_name}
- or $in_code !=
$Texinfo::Commands::index_names{$entry_index_name}->{'in_code'}) {
- push @$attribute, ['incode', $in_code];
- }
- if ($index_info->{'merged_in'}) {
- push @$attribute, ['mergedindex', $index_info->{'merged_in'}];
- }
+ my $entry_index_name = $index_entry->{'index_name'};
+ my $in_code = $index_info->{'in_code'};
+ if (!$Texinfo::Commands::index_names{$entry_index_name}
+ or $in_code !=
$Texinfo::Commands::index_names{$entry_index_name}->{'in_code'}) {
+ push @$attribute, ['incode', $in_code];
+ }
+ if ($index_info->{'merged_in'}) {
+ push @$attribute, ['mergedindex', $index_info->{'merged_in'}];
}
my $result = $self->txi_markup_open_element('indexterm', $attribute);
push @{$self->{'document_context'}}, {'monospace' => [0]};
$self->{'document_context'}->[-1]->{'monospace'}->[-1] = 1
- if ($index_entry->{'in_code'});
+ if ($in_code);
$result .=
$self->_convert(Texinfo::Common::index_content_element($element));
pop @{$self->{'document_context'}};
$result .= $self->txi_markup_close_element('indexterm');
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index a6fae4d54a..88748979d4 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -1870,15 +1870,12 @@ sub index_entry_sort_string($$$$;$)
my $options = shift;
my $collator = shift;
- my $convert_to_text_options = {%$options};
- $convert_to_text_options->{'code'} = $main_entry->{'in_code'};
-
my $entry_key;
if (defined($sortas)) {
$entry_key = $sortas;
} else {
$entry_key = Texinfo::Convert::Text::convert_to_text(
- $entry_tree_element, $convert_to_text_options);
+ $entry_tree_element, $options);
# FIXME do that for sortas too?
if (defined($main_entry->{'entry_element'}
->{'extra'}->{'index_ignore_chars'})) {
@@ -1909,11 +1906,12 @@ my $default_preset_keys = 1;
# the structure returned depends on $SORT_BY_LETTER being set
# or not. It is described in the pod documentation.
-sub sort_indices($$$;$$)
+sub sort_indices($$$$;$$)
{
my $registrar = shift;
my $customization_information = shift;
my $index_entries = shift;
+ my $indices_information = shift;
my $sort_by_letter = shift;
my $preset_keys = shift;
$preset_keys = $default_preset_keys if (!defined($preset_keys));
@@ -1963,16 +1961,19 @@ sub sort_indices($$$;$$)
my $sortable_index_entries = [];
# used if $sort_by_letter
my $index_letter_hash = {};
- foreach my $entry (@{$index_entries->{$index_name}}) {
- my $main_entry_element = $entry->{'entry_element'};
+ 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($entry,
+ = index_entry_sort_string($index_entry,
Texinfo::Common::index_content_element($main_entry_element),
$main_entry_sortas,
- $options, $entries_collator);
+ $convert_to_text_options, $entries_collator);
my @entry_keys;
my @sort_entry_keys;
my $letter = '';
@@ -2011,9 +2012,11 @@ sub sort_indices($$$;$$)
$subentry_nr ++;
$subentry = $subentry->{'extra'}->{'subentry'};
my ($subentry_key, $sort_subentry_key)
- = index_entry_sort_string($entry,
- {'contents' => $subentry->{'args'}->[0]->{'contents'}},
- $subentry->{'extra'}->{'sortas'}, $options, $entries_collator);
+ = index_entry_sort_string($index_entry,
+ {'contents' => $subentry->{'args'}->[0]->{'contents'}},
+ $subentry->{'extra'}->{'sortas'},
+ $convert_to_text_options,
+ $entries_collator);
if ($subentry_key !~ /\S/) {
my $entry_cmdname = $main_entry_element->{'cmdname'};
$entry_cmdname
@@ -2033,9 +2036,10 @@ sub sort_indices($$$;$$)
}
foreach my $sub_entry_key (@sort_entry_keys) {
if ($sub_entry_key ne '') {
- my $sortable_entry = {'entry' => $entry, 'keys' => \@sort_entry_keys,
- 'number' => $entry->{'entry_number'},
- 'index_name' => $entry->{'index_name'}};
+ my $sortable_entry = {'entry' => $index_entry,
+ 'keys' => \@sort_entry_keys,
+ 'number' => $index_entry->{'entry_number'},
+ 'index_name' => $entry_index_name};
if ($sort_by_letter) {
push @{$index_letter_hash->{$letter}}, $sortable_entry;
} else {
@@ -2044,7 +2048,7 @@ sub sort_indices($$$;$$)
last;
}
}
- $index_entries_sort_strings->{$entry} = join(', ', @entry_keys);
+ $index_entries_sort_strings->{$index_entry} = join(', ', @entry_keys);
}
if ($sort_by_letter) {
# need to use directly the collator here as there is no
@@ -2150,10 +2154,12 @@ Texinfo::Structuring - information on Texinfo::Parser
tree
my $index_entries_sorted;
if ($sort_by_letter) {
$index_entries_sorted = sort_indices($registrar, $config,
- $merged_index_entries, 'by_letter');
+ $merged_index_entries, $indices_information,
+ 'by_letter');
} else {
$index_entries_sorted = sort_indices($registrar, $config,
- $merged_index_entries);
+ $merged_index_entries,
+ $indices_information);
}
@@ -2470,7 +2476,7 @@ X<C<setup_index_entry_keys_formatting>>
Return options for conversion of Texinfo to text relevant for index keys
sorting.
-=item ($index_entries_sorted, $index_entries_sort_strings) =
sort_indices($registrar, $customization_information, $merged_index_entries,
$sort_by_letter)
+=item ($index_entries_sorted, $index_entries_sort_strings) =
sort_indices($registrar, $customization_information, $merged_index_entries,
$indices_information, $sort_by_letter)
X<C<sort_indices>>
If I<$sort_by_letter> is set, sort by letter, otherwise sort all
diff --git a/tp/Texinfo/Translations.pm b/tp/Texinfo/Translations.pm
index e81f85443c..4d979c16ad 100644
--- a/tp/Texinfo/Translations.pm
+++ b/tp/Texinfo/Translations.pm
@@ -380,8 +380,7 @@ if (0) {
# In a handful of cases, we delay storing the contents of the
# index entry until now to avoid needing Texinfo::Translations::gdt
-# in the main code of Parser.pm. Also set 'in_code' value on
-# index entries.
+# in the main code of Parser.pm.
sub complete_indices($)
{
my $self = shift;
@@ -389,7 +388,6 @@ sub complete_indices($)
foreach my $index_name (sort(keys(%{$self->{'index_names'}}))) {
next if (not
defined($self->{'index_names'}->{$index_name}->{'index_entries'}));
foreach my $entry
(@{$self->{'index_names'}->{$index_name}->{'index_entries'}}) {
- $entry->{'in_code'} = $self->{'index_names'}->{$index_name}->{'in_code'};
my $main_entry_element = $entry->{'entry_element'};
if ($main_entry_element->{'extra'}
and $main_entry_element->{'extra'}->{'def_command'}
diff --git a/tp/init/chm.pm b/tp/init/chm.pm
index 916f3ffbf6..3ab95c9346 100644
--- a/tp/init/chm.pm
+++ b/tp/init/chm.pm
@@ -246,7 +246,8 @@ sub chm_init($)
my ($index_entries, $index_entries_sort_strings)
= Texinfo::Structuring::sort_indices($self, $self,
- $self->get_info('index_entries'));
+ $self->get_info('index_entries'),
+ $self->get_info('indices_information');
if ($index_entries) {
foreach my $index_name (sort(keys(%$index_entries))) {
foreach my $index_entry_ref (@{$index_entries->{$index_name}}) {
diff --git a/tp/t/test_sort.t b/tp/t/test_sort.t
index 029c560a0b..146ae4762d 100644
--- a/tp/t/test_sort.t
+++ b/tp/t/test_sort.t
@@ -50,7 +50,7 @@ my $main_configuration =
Texinfo::MainConfig::new({'ENABLE_ENCODING' => 1});
Texinfo::Common::set_output_encodings($main_configuration,
$parser_information);
my ($sorted_index_entries, $index_entries_sort_strings)
= Texinfo::Structuring::sort_indices($registrar, $main_configuration,
- $index_entries);
+ $index_entries, $indices_information);
my @entries = ();
foreach my $entry (@{$sorted_index_entries->{'cp'}}) {
@@ -66,7 +66,8 @@ cmp_deeply (\@entries, \@entries_ref, 'sorted index entries');
my ($sorted_index_entries_by_letter, $by_letter_index_entries_sort_strings)
= Texinfo::Structuring::sort_indices($registrar, $main_configuration,
- $index_entries, 'by_letter');
+ $index_entries, $indices_information,
+ 'by_letter');
my @letter_entries_ref = (
{'!' => [ '!' ]},
@@ -124,7 +125,7 @@ $registrar = $parser->registered_errors();
$index_entries = Texinfo::Structuring::merge_indices($indices_information);
($sorted_index_entries, $index_entries_sort_strings)
= Texinfo::Structuring::sort_indices($registrar, $main_configuration,
- $index_entries);
+ $index_entries, $indices_information);
@entries = ();
foreach my $entry (@{$sorted_index_entries->{'cp'}}) {
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 79fe35c921..c8da99a7b2 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -1140,7 +1140,8 @@ sub test($$)
($sorted_index_entries, $index_entries_sort_strings)
= Texinfo::Structuring::sort_indices($registrar,
$main_configuration,
- $merged_index_entries);
+ $merged_index_entries,
+ $indices_information);
$indices_sorted_sort_strings = {};
foreach my $index_name (keys(%$sorted_index_entries)) {
# index entries sort strings sorted in the order of the index entries
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Convert/HTML.pm (_prepare_index_entries), tp/Texinfo/Convert/IXIN.pm, tp/Texinfo/Convert/LaTeX.pm (_index_entry), tp/Texinfo/Convert/Plaintext.pm (process_printindex), tp/Texinfo/Structuring.pm (index_entry_sort_string, sort_indices), tp/init/chm.pm (chm_init), tp/t/test_sort.t, tp/t/test_utils.pl (test): pass indices_information to sort_indices. Set 'code' in options for text conversion before calling index_entry_sort_string, based on indices_information.,
Patrice Dumas <=