texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Structuring.pm (index_entry_sort_str


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Structuring.pm (index_entry_sort_string) (_index_entry_sort_string_key): have index_entry_sort_string return only the sort_string, not the sort_key used from the collator. Add _index_entry_sort_string_key that returns both the sort_string and the sort_key, meant to be used internally only. Update callers.
Date: Sun, 07 Jan 2024 04:45:46 -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 0e871e8bd8 * tp/Texinfo/Structuring.pm (index_entry_sort_string) 
(_index_entry_sort_string_key): have index_entry_sort_string return only the 
sort_string, not the sort_key used from the collator.  Add 
_index_entry_sort_string_key that returns both the sort_string and the 
sort_key, meant to be used internally only.  Update callers.
0e871e8bd8 is described below

commit 0e871e8bd8fe8eb2a77db331f35a4571b32dc3c9
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jan 7 10:45:43 2024 +0100

    * tp/Texinfo/Structuring.pm (index_entry_sort_string)
    (_index_entry_sort_string_key): have index_entry_sort_string return
    only the sort_string, not the sort_key used from the collator.  Add
    _index_entry_sort_string_key that returns both the sort_string and the
    sort_key, meant to be used internally only.  Update callers.
    
    * tp/Texinfo/Convert/LaTeX.pm (_index_entry): rename $sortas as
    $sort_string.
---
 ChangeLog                   | 11 +++++++++++
 tp/Texinfo/Convert/LaTeX.pm |  8 ++++----
 tp/Texinfo/Structuring.pm   | 43 ++++++++++++++++++++++++++++---------------
 3 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1b6411793f..9536fe8617 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-01-07  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Structuring.pm (index_entry_sort_string)
+       (_index_entry_sort_string_key): have index_entry_sort_string return
+       only the sort_string, not the sort_key used from the collator.  Add
+       _index_entry_sort_string_key that returns both the sort_string and the
+       sort_key, meant to be used internally only.  Update callers.
+
+       * tp/Texinfo/Convert/LaTeX.pm (_index_entry): rename $sortas as
+       $sort_string.
+
 2024-01-07  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/get_perl_info.c
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index e45c20633b..a404809230 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -2463,15 +2463,15 @@ sub _index_entry($$)
       }
       # 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)
+      my $sort_string
            = Texinfo::Structuring::index_entry_sort_string($entry,
                                           $subentry, $subentry_sortas,
                                           $convert_to_text_options);
       my $result = '';
-      if (defined($sortas)) {
+      if (defined($sort_string)) {
         # | in sort key breaks with hyperref
-        $sortas =~ s/\|//g;
-        $result = _protect_text($self, $sortas);
+        $sort_string =~ s/\|//g;
+        $result = _protect_text($self, $sort_string);
         $result =~ s/\\[{}]//g; # cannot have unmatched braces in index entry
         $result = _protect_index_text($result).'@';
       }
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index a4e9c3834e..6bcdd2b0f6 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -2279,42 +2279,55 @@ sub setup_index_entry_keys_formatting($)
 }
 
 # can be used for subentries
-sub index_entry_sort_string($$$$;$)
+sub index_entry_sort_string($$$$)
 {
   my $main_entry = shift;
   my $entry_tree_element = shift;
   my $sortas = shift;
   my $options = shift;
-  my $collator = shift;
 
-  my $entry_key;
+  my $sort_string;
   if (defined($sortas)) {
-    $entry_key = $sortas;
+    $sort_string = $sortas;
   } else {
-    $entry_key = Texinfo::Convert::Text::convert_to_text(
-                          $entry_tree_element, $options);
+    $sort_string = Texinfo::Convert::Text::convert_to_text(
+                              $entry_tree_element, $options);
     # FIXME do that for sortas too?
     if (defined($main_entry->{'entry_element'}
                        ->{'extra'}->{'index_ignore_chars'})) {
       my $ignore_chars = quotemeta($main_entry->{'entry_element'}
                                   ->{'extra'}->{'index_ignore_chars'});
       if ($ignore_chars ne '') {
-        $entry_key =~ s/[$ignore_chars]//g;
+        $sort_string =~ s/[$ignore_chars]//g;
       }
     }
   }
+  return $sort_string;
+}
+
+sub _index_entry_sort_string_key($$$$;$)
+{
+  my $main_entry = shift;
+  my $entry_tree_element = shift;
+  my $sortas = shift;
+  my $options = shift;
+  my $collator = shift;
+
+  my $sort_string = index_entry_sort_string ($main_entry, $entry_tree_element,
+                                             $sortas, $options);
+
   # This avoids varying results depending on whether the string is
-  # represented internally in UTF-8.  See "the Unicode bug" in the
+  # represented internally in UTF-8.  See 'the "Unicode bug"' in the
   # "perlunicode" man page.
-  utf8::upgrade($entry_key);
-  my $sort_entry_key;
+  utf8::upgrade($sort_string);
+  my $sort_key;
   if ($collator) {
-    $sort_entry_key = $collator->getSortKey(uc($entry_key));
+    $sort_key = $collator->getSortKey(uc($sort_string));
   } else {
-    $sort_entry_key = uc($entry_key);
+    $sort_key = uc($sort_string);
   }
 
-  return ($entry_key, $sort_entry_key);
+  return ($sort_string, $sort_key);
 }
 
 # This is a stub for the Unicode::Collate module.  Although this module is
@@ -2451,7 +2464,7 @@ sub setup_sortable_index_entries($$$$$;$)
       $main_entry_sortas = $main_entry_element->{'extra'}->{'sortas'}
          if ($main_entry_element->{'extra'});
       my ($entry_key, $sort_entry_key)
-        = index_entry_sort_string($index_entry,
+        = _index_entry_sort_string_key($index_entry,
                    Texinfo::Common::index_content_element($main_entry_element),
                                   $main_entry_sortas,
                                   $convert_to_text_options, $entries_collator);
@@ -2481,7 +2494,7 @@ sub setup_sortable_index_entries($$$$$;$)
         $subentry_nr ++;
         $subentry = $subentry->{'extra'}->{'subentry'};
         my ($subentry_key, $sort_subentry_key)
-              = index_entry_sort_string($index_entry,
+              = _index_entry_sort_string_key($index_entry,
                         {'contents' => $subentry->{'args'}->[0]->{'contents'}},
                         $subentry->{'extra'}->{'sortas'},
                         $convert_to_text_options,



reply via email to

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