texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/HTML.pm (_new_sectioning_com


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/HTML.pm (_new_sectioning_command_target): align contents and shhortcontents targets code on C code.
Date: Tue, 05 Dec 2023 02:48:01 -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 3e9a5b8a8d * tp/Texinfo/Convert/HTML.pm 
(_new_sectioning_command_target): align contents and shhortcontents targets 
code on C code.
3e9a5b8a8d is described below

commit 3e9a5b8a8d52a20c9627731dd927a3f4f99e54fb
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Dec 5 08:47:50 2023 +0100

    * tp/Texinfo/Convert/HTML.pm (_new_sectioning_command_target): align
    contents and shhortcontents targets code on C code.
    
    * tp/Texinfo/Convert/HTML.pm (_new_sectioning_command_target),
    tp/Texinfo/XS/convert/convert_html.c (new_sectioning_command_target):
    if @top is empty, set the normalized to be the target base for
    contents_target and shortcontents_target. put contents_target and
    shortcontents_target in seen_ids.
---
 ChangeLog                                          | 11 +++++++++++
 tp/Texinfo/Convert/HTML.pm                         | 17 +++++++++--------
 tp/Texinfo/XS/convert/convert_html.c               | 12 ++++++++++--
 tp/t/results/converters_tests/ref_in_sectioning.pl |  2 +-
 4 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 89f121084f..31c64f424b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-12-05  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (_new_sectioning_command_target): align
+       contents and shhortcontents targets code on C code.
+
+       * tp/Texinfo/Convert/HTML.pm (_new_sectioning_command_target),
+       tp/Texinfo/XS/convert/convert_html.c (new_sectioning_command_target):
+       if @top is empty, set the normalized to be the target base for
+       contents_target and shortcontents_target. put contents_target and
+       shortcontents_target in seen_ids.
+
 2023-12-04  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/converter_types.h (FILE_NUMBER_NAME): rename
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 0b15ce89d1..eb58f3bd01 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -9039,6 +9039,7 @@ sub _new_sectioning_command_target($$)
   if ($target_base !~ /\S/ and $command->{'cmdname'} eq 'top') {
     # @top is allowed to be empty.  In that case it gets this target name
     $target_base = 'SEC_Top';
+    $normalized_name = $target_base;
   }
   my $nr=1;
   my $target = $target_base;
@@ -9056,23 +9057,21 @@ sub _new_sectioning_command_target($$)
   my $target_shortcontents;
   if ($sectioning_heading_commands{$command->{'cmdname'}}) {
     if ($target ne '') {
-      my $target_base_contents = $target;
-      $target_base_contents = $normalized_name;
-      $target_contents = 'toc-'.$target_base_contents;
+      my $target_base_contents = 'toc-'.$normalized_name;
+      $target_contents = $target_base_contents;
       my $toc_nr = $nr -1;
       while ($self->{'seen_ids'}->{$target_contents}) {
-        $target_contents = 'toc-'.$target_base_contents.'-'.$toc_nr;
+        $target_contents = $target_base_contents.'-'.$toc_nr;
         $toc_nr++;
         # Avoid integer overflow
         die if ($toc_nr == 0);
       }
 
-      $target_shortcontents = 'stoc-'.$target_base_contents;
-      my $target_base_shortcontents = $target_base;
-      $target_base_shortcontents =~ s/^g_t//;
+      my $target_base_shortcontents = 'stoc-'.$normalized_name;
+      $target_shortcontents = $target_base_shortcontents;
       my $stoc_nr = $nr -1;
       while ($self->{'seen_ids'}->{$target_shortcontents}) {
-        $target_shortcontents = 'stoc-'.$target_base_shortcontents
+        $target_shortcontents = $target_base_shortcontents
                                    .'-'.$stoc_nr;
         $stoc_nr++;
         # Avoid integer overflow
@@ -9100,12 +9099,14 @@ sub _new_sectioning_command_target($$)
   $self->{'seen_ids'}->{$target} = 1;
   if (defined($target_contents)) {
     $self->{'targets'}->{$command}->{'contents_target'} = $target_contents;
+    $self->{'seen_ids'}->{$target_contents} = 1;
   } else {
     $self->{'targets'}->{$command}->{'contents_target'} = '';
   }
   if (defined($target_shortcontents)) {
     $self->{'targets'}->{$command}->{'shortcontents_target'}
        = $target_shortcontents;
+    $self->{'seen_ids'}->{$target_shortcontents} = 1;
   } else {
     $self->{'targets'}->{$command}->{'shortcontents_target'} = '';
   }
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 02626e9e65..944b8d0c75 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -1640,6 +1640,8 @@ new_sectioning_command_target (CONVERTER *self, const 
ELEMENT *command)
       /* @top is allowed to be empty.  In that case it gets this target name */
       free (target_base);
       target_base = strdup ("SEC_Top");
+      free (normalized_name);
+      normalized_name = strdup (target_base);
     }
 
   if (strlen (target_base))
@@ -1696,12 +1698,18 @@ new_sectioning_command_target (CONVERTER *self, const 
ELEMENT *command)
   free (target);
 
   if (target_contents)
-    element_target->contents_target = target_contents;
+    {
+      element_target->contents_target = target_contents;
+      add_string (target_contents, &self->seen_ids);
+    }
   else
     element_target->contents_target = strdup ("");
 
   if (target_shortcontents)
-    element_target->shortcontents_target = target_shortcontents;
+    {
+      element_target->shortcontents_target = target_shortcontents;
+      add_string (target_shortcontents, &self->seen_ids);
+    }
   else
     element_target->shortcontents_target = strdup ("");
 }
diff --git a/tp/t/results/converters_tests/ref_in_sectioning.pl 
b/tp/t/results/converters_tests/ref_in_sectioning.pl
index 173b2d5551..17d4771e6c 100644
--- a/tp/t/results/converters_tests/ref_in_sectioning.pl
+++ b/tp/t/results/converters_tests/ref_in_sectioning.pl
@@ -2346,7 +2346,7 @@ $result_converted{'html_text'}->{'ref_in_sectioning'} = '
   <li><a id="toc-node_002e" href="#node">1 See <a data-manual="file name" 
href="file%20name.html#node">title</a> in <cite 
class="cite">Manual</cite>.</a></li>
   <li><a id="toc-node-just-node" href="#chap">2 <a class="ref" 
href="#node">See <a data-manual="file name" 
href="file%20name.html#node">title</a> in <cite class="cite">Manual</cite>.</a> 
just node</a>
   <ul class="toc-numbered-mark">
-    <li><a id="toc-for-example-node-_0028node_0029-_0028Top_0029" 
href="#for-example-node-_0028node_0029-_0028Top_0029-1">2.1 for example <a 
class="ref" href="#node">See <a data-manual="file name" 
href="file%20name.html#node">title</a> in <cite class="cite">Manual</cite>.</a> 
(see <a class="pxref" href="#node">See <a data-manual="file name" 
href="file%20name.html#node">title</a> in <cite 
class="cite">Manual</cite>.</a>) (see <cite class="cite"><a data-manual="file" 
href="file.html#Top">M [...]
+    <li><a id="toc-for-example-node-_0028node_0029-_0028Top_0029-1" 
href="#for-example-node-_0028node_0029-_0028Top_0029-1">2.1 for example <a 
class="ref" href="#node">See <a data-manual="file name" 
href="file%20name.html#node">title</a> in <cite class="cite">Manual</cite>.</a> 
(see <a class="pxref" href="#node">See <a data-manual="file name" 
href="file%20name.html#node">title</a> in <cite 
class="cite">Manual</cite>.</a>) (see <cite class="cite"><a data-manual="file" 
href="file.html#Top" [...]
     <li><a id="toc-node-node_002c-crossref-arg2" 
href="#node-node_002c-crossref-arg2">2.2 <a class="ref" href="#node">cross ref 
name</a>  node, crossref arg2</a></li>
     <li><a id="toc-node-code-node_002c-samptitle-arg3" 
href="#node-code-node_002c-samptitle-arg3">2.3 <a class="ref" 
href="#node">&lsquo;<samp class="samp">title</samp>&rsquo;</a>  code node, 
samptitle arg3</a></li>
     <li><a id="toc-node-code-node_002c-file-name" 
href="#node-code-node_002c-file-name">2.4 <a data-manual="file name" 
href="file%20name.html#node">(file name)<code class="code">node</code></a> code 
node, file name</a></li>



reply via email to

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