texinfo-commits
[Top][All Lists]
Advanced

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

[7707] texi2any @set txiindex...ignore


From: gavinsmith0123
Subject: [7707] texi2any @set txiindex...ignore
Date: Sat, 1 Apr 2017 16:47:55 -0400 (EDT)

Revision: 7707
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7707
Author:   gavin
Date:     2017-04-01 16:47:55 -0400 (Sat, 01 Apr 2017)
Log Message:
-----------
texi2any @set txiindex...ignore

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/tp/Texinfo/Structuring.pm

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2017-04-01 20:44:15 UTC (rev 7706)
+++ trunk/ChangeLog     2017-04-01 20:47:55 UTC (rev 7707)
@@ -1,5 +1,12 @@
 2017-04-01  Gavin Smith  <address@hidden>
 
+       * tp/Texinfo/Structuring.pm (do_index_keys): Strip '-', '\',
+       '<', '@' if there has been @set txiindexhyphenignore,
+       txiindexbackslashignore, txiindexlessthanignore,
+       or txiindexatsignignore respectively.
+
+2017-04-01  Gavin Smith  <address@hidden>
+
        * tp/Texinfo/Parser.pm (%command_ignore_space_after): Add 
        'sortas', in order to ignore spaces after its argument.
 

Modified: trunk/tp/Texinfo/Structuring.pm
===================================================================
--- trunk/tp/Texinfo/Structuring.pm     2017-04-01 20:44:15 UTC (rev 7706)
+++ trunk/tp/Texinfo/Structuring.pm     2017-04-01 20:47:55 UTC (rev 7707)
@@ -1422,6 +1422,26 @@
   my $index_names = shift;
   my $parser;
 
+  if (!defined $parser) {
+    # FIXME: sometimes $self is a converter object, sometimes it
+    # is Texinfo::Parser.  This is very confusing.
+    if (defined $self->{'parser'}) {
+      $parser = $self->{'parser'};
+    } else {
+      $parser = $self;
+    }
+  }
+  my $ignore_chars = '';
+  # '-' must come first to avoid e.g. [<address@hidden looking like a 
character range
+  $ignore_chars .= '-'
+    if defined $parser->{'values'}->{'txiindexhyphenignore'};
+  $ignore_chars .= '\\\\' # string with 2 \s, for escaping inside regex
+    if defined $parser->{'values'}->{'txiindexbackslashignore'};
+  $ignore_chars .= '<'
+    if defined $parser->{'values'}->{'txiindexlessthanignore'};
+  $ignore_chars .= '@'
+    if defined $parser->{'values'}->{'txiindexatsignignore'};
+
   my $options = {'sort_string' => 1};
   if ($self->get_conf('ENABLE_ENCODING') 
       and $self->get_conf('INPUT_ENCODING_NAME')) {
@@ -1439,15 +1459,6 @@
       # index entry until now to avoid needing Texinfo::Report::gdt
       # in Parser.pm.
       if (!defined $entry->{'content'}) {
-        if (!defined $parser) {
-          # FIXME: sometimes $self is a converter object, sometimes it
-          # is Texinfo::Parser.  This is very confusing.
-          if (defined $self->{'parser'}) {
-            $parser = $self->{'parser'};
-          } else {
-            $parser = $self;
-          }
-        }
         my $def_command = $entry->{'command'}->{'extra'}->{'def_command'};
 
         my $def_parsed_hash = 
$entry->{'command'}->{'extra'}->{'def_parsed_hash'}; 
@@ -1498,6 +1509,9 @@
       } else {
         $entry->{'key'} = Texinfo::Convert::Text::convert(
                               {'contents' => $entry->{'content'}}, $options);
+        if ($ignore_chars) {
+          $entry->{'key'} =~ s/[$ignore_chars]//g;
+        }
       }
       if ($entry->{'key'} !~ /\S/) {
         $self->line_warn(sprintf($self->__("empty index key in 
address@hidden"), 




reply via email to

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