texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: Protect node in index entry if INFO_SPECIAL_CHARS


From: Patrice Dumas
Subject: branch master updated: Protect node in index entry if INFO_SPECIAL_CHARS_QUOTE is set
Date: Mon, 15 Aug 2022 11:00:35 -0400

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 f5697cbf26 Protect node in index entry if INFO_SPECIAL_CHARS_QUOTE is 
set
f5697cbf26 is described below

commit f5697cbf26806d5ea402e5c59e5a0e106aa68c64
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Aug 15 16:59:41 2022 +0200

    Protect node in index entry if INFO_SPECIAL_CHARS_QUOTE is set
    
    * tp/Texinfo/Convert/Plaintext.pm (process_printindex): protect
    node name in index if INFO_SPECIAL_CHARS_QUOTE is set.  Protect
    characters that need to be protected in menu node entry after
    menu entry name and also :, as the Info readers should consider
    text up to : to be part of the index entry.
---
 ChangeLog                                          |  10 +++++++
 tp/Texinfo/Convert/Plaintext.pm                    |  29 +++++++++++++++++++--
 .../res_info/colons_in_index_entries_and_node.info | Bin 1556 -> 1568 bytes
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6063aa470c..5c2e35a87f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,16 @@
        (Info Format Regular Nodes, Info Format Printindex):
        Do not use @kbd for DEL.  From Patrice.
 
+2022-08-15  Patrice Dumas  <pertusus@free.fr>
+
+       Protect node in index entry if INFO_SPECIAL_CHARS_QUOTE is set
+
+       * tp/Texinfo/Convert/Plaintext.pm (process_printindex): protect
+       node name in index if INFO_SPECIAL_CHARS_QUOTE is set.  Protect
+       characters that need to be protected in menu node entry after
+       menu entry name and also :, as the Info readers should consider
+       text up to : to be part of the index entry.
+
 2022-08-15  Patrice Dumas  <pertusus@free.fr>
 
        Set INFO_SPECIAL_CHARS_WARNING in Info to 1
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index ce25946f3b..7f8bd15378 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -401,6 +401,8 @@ sub converter_initialize($)
      = %default_preformatted_context_commands;
   $self->{'footnote_index'} = 0;
   $self->{'pending_footnotes'} = [];
+  $self->{'index_entry_node_colon'} = {};
+  $self->{'index_entries_no_node'} = {};
 
   foreach my $format (keys(%format_raw_commands)) {
     $self->{'ignored_commands'}->{$format} = 1 
@@ -1329,7 +1331,10 @@ sub process_printindex($$;$)
 
     next if ($entry_text !~ /\S/);
 
-    # FIXME protect instead
+    # No need for protection, the Info readers should find the last : on
+    # the line.  : in the node following the index entry node should be
+    # protected, however, as done below, such that : in the node are not
+    # mistaken as being part of the index entry.
     if ($entry_text =~ /:/ and $self->get_conf('INDEX_SPECIAL_CHARS_WARNING')) 
{
       $self->line_warn ($self,
         sprintf(__("Index entry in \@%s with : produces invalid Info: %s"),
@@ -1385,8 +1390,28 @@ sub process_printindex($$;$)
       }
     } else {
       my ($node_line, $byte_count) = $self->node_line($node);
-      $entry_line_addition .= $node_line;
       $self->{'count_context'}->[-1]->{'bytes'} += $byte_count;
+      # protect characters that need to be protected in menu node entry
+      # after menu entry name and also :, as the Info readers
+      # should consider text up to : to be part of the index entry.
+      if ($node_line =~ /([,\t:]|\.\s)/) {
+        if ($self->{'info_special_chars_warning'}) {
+          # Warn only once
+          if (! $self->{'index_entry_node_colon'}->{$node_line}) {
+            $self->line_warn($self, __(
+             "node name with index entries should not contain `$1'"),
+                           $node->{'source_info'});
+          }
+          $self->{'index_entry_node_colon'}->{$node_line} = 1;
+        }
+        if ($self->{'info_special_chars_quote'}) {
+          my $pre_quote = "\x{7f}";
+          my $post_quote = $pre_quote;
+          $self->{'count_context'}->[-1]->{'bytes'} += 2;
+          $node_line = $pre_quote . $node_line . $post_quote;
+        }
+      }
+      $entry_line_addition .= $node_line;
     }
     $entry_line_addition .= '.';
     add_text_count($self, '.');
diff --git 
a/tp/t/results/info_tests/colons_in_index_entries_and_node/res_info/colons_in_index_entries_and_node.info
 
b/tp/t/results/info_tests/colons_in_index_entries_and_node/res_info/colons_in_index_entries_and_node.info
index 96f8d0c810..61f8200b29 100644
Binary files 
a/tp/t/results/info_tests/colons_in_index_entries_and_node/res_info/colons_in_index_entries_and_node.info
 and 
b/tp/t/results/info_tests/colons_in_index_entries_and_node/res_info/colons_in_index_entries_and_node.info
 differ



reply via email to

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