texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Sat, 23 Dec 2023 06:34:39 -0500 (EST)

branch: master
commit d6ded40e4a87aa01267c6c86bee0b6e6445b403b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Dec 23 10:59:07 2023 +0100

    * tp/Texinfo/Convert/HTML.pm (_convert_footnote_command): distinguish
    footnote id and docid and output footid and docid after disambiguation
    for footnote elements converted more than once.
---
 ChangeLog                  |  6 ++++++
 tp/Texinfo/Convert/HTML.pm | 30 +++++++++++++++++++-----------
 2 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 774a549b94..af52567931 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-12-23  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (_convert_footnote_command): distinguish
+       footnote id and docid and output footid and docid after disambiguation
+       for footnote elements converted more than once.
+
 2023-12-22  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/HTML.pm (_convert_anchor_command): get id only if
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index f46fe286b7..d48319f7c9 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -3402,35 +3402,43 @@ sub _convert_footnote_command($$$$)
   return "($footnote_mark)" if (in_string($self));
 
   #print STDERR "FOOTNOTE $command\n";
-  my $footid = $self->command_id($command);
+  my $footnote_id = $self->command_id($command);
 
   # happens for bogus footnotes
-  if (!defined($footid)) {
+  if (!defined($footnote_id)) {
     return '';
   }
   # ID for linking back to the main text from the footnote.
-  my $docid = $self->footnote_location_target($command);
+  my $footnote_docid = $self->footnote_location_target($command);
+
+  # id used in output
+  my $footid;
+  my $docid;
 
   my $multiple_expanded_footnote = 0;
   my $multi_expanded_region = in_multi_expanded($self);
   if (defined($multi_expanded_region)) {
     # to avoid duplicate names, use a prefix that cannot happen in anchors
     my $target_prefix = "t_f";
-    $footid = $target_prefix.$multi_expanded_region.'_'.$footid.'_'.$$foot_num;
-    $docid = $target_prefix.$multi_expanded_region.'_'.$docid.'_'.$$foot_num;
+    $footid = $target_prefix.$multi_expanded_region.'_'
+                    .$footnote_id.'_'.$$foot_num;
+    $docid = $target_prefix.$multi_expanded_region.'_'
+                     .$footnote_docid.'_'.$$foot_num;
   } else {
     my $footnote_id_numbers
       = $self->shared_conversion_state('footnote_id_numbers', {});
-    if (!defined($footnote_id_numbers->{$footid})) {
-      $footnote_id_numbers->{$footid} = $$foot_num;
+    if (!defined($footnote_id_numbers->{$footnote_id})) {
+      $footnote_id_numbers->{$footnote_id} = $$foot_num;
+      $footid = $footnote_id;
+      $docid = $footnote_docid;
     } else {
       # This should rarely happen, except for @footnote in @copying and
       # multiple @insertcopying...
       # Here it is not checked that there is no clash with another anchor.
       # However, unless there are more than 1000 footnotes this should not
-      # happen.
-      $footid .= '_'.$$foot_num;
-      $docid .= '_'.$$foot_num;
+      # happen at all, and even in that case it is very unlikely.
+      $footid = $footnote_id.'_'.$$foot_num;
+      $docid = $footnote_docid.'_'.$$foot_num;
       $multiple_expanded_footnote = 1;
     }
   }
@@ -3443,7 +3451,7 @@ sub _convert_footnote_command($$$$)
     # formatted (in general the first one, but it depends if it is in a
     # tree element or not, for instance in @titlepage).
     # With footnotestyle end, considering that the footnote is in the same file
-    # has a better change of being correct.
+    # has a better chance of being correct.
     $footnote_href = "#$footid";
   } else {
     $footnote_href = $self->command_href($command, undef, undef, $footid);



reply via email to

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