[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[7702] @sortas in texi2any
From: |
gavinsmith0123 |
Subject: |
[7702] @sortas in texi2any |
Date: |
Sat, 1 Apr 2017 14:14:32 -0400 (EDT) |
Revision: 7702
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7702
Author: gavin
Date: 2017-04-01 14:14:31 -0400 (Sat, 01 Apr 2017)
Log Message:
-----------
@sortas in texi2any
Modified Paths:
--------------
trunk/ChangeLog
trunk/tp/Texinfo/Parser.pm
trunk/tp/Texinfo/Structuring.pm
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2017-03-25 15:24:50 UTC (rev 7701)
+++ trunk/ChangeLog 2017-04-01 18:14:31 UTC (rev 7702)
@@ -1,3 +1,22 @@
+2017-04-01 Gavin Smith <address@hidden>
+
+ * tp/Texinfo/Parser.pm (_parse_texi) <close brace, @sortas>: Set
+ 'sortas' value on index entry element.
+ (_enter_index_entry): Set 'sortas' value on index entry from
+ 'extra' value on element.
+
+ * tp/Texinfo/Structuring.pm (_do_index_keys): Check for 'sortas'
+ value on index entry and, if present, use that as the sort key
+ instead of using the text of the index entry.
+
+ * tp/Texinfo/Parser.pm (%in_index_commands): New hash,
+ containing 'sortas'.
+ (_parse_line_command_args) <@defindex, @defcodeindex>: Use
+ %in_index_commands instead of %in_simple_text_commands for valid
+ nestings hash.
+ (%no_command_cmds): Add 'sortas'.
+ (%in_full_text_commands, %full_text_commands): Remove 'sortas'.
+
2017-03-25 Gavin Smith <address@hidden>
* doc/texinfo-tex-test.texi (Test of index sort keys): New example.
Modified: trunk/tp/Texinfo/Parser.pm
===================================================================
--- trunk/tp/Texinfo/Parser.pm 2017-03-25 15:24:50 UTC (rev 7701)
+++ trunk/tp/Texinfo/Parser.pm 2017-04-01 18:14:31 UTC (rev 7702)
@@ -381,6 +381,7 @@
}
delete $in_full_text_commands{'caption'};
delete $in_full_text_commands{'shortcaption'};
+delete $in_full_text_commands{'sortas'};
foreach my $block_command (keys(%block_commands)) {
$in_full_text_commands{$block_command} = 1
if ($block_commands{$block_command} eq 'conditional');
@@ -406,6 +407,12 @@
delete $in_simple_text_commands{$not_in_simple_text_command};
}
+# commands that may occur in index entries
+my %in_index_commands = %in_simple_text_commands;
+foreach my $in_index_command ('sortas') {
+ $in_index_commands{$in_index_command} = 1;
+}
+
# commands that only accept simple text as argument in any context.
my %simple_text_commands;
foreach my $misc_command(keys(%misc_commands)) {
@@ -432,7 +439,7 @@
# Commands that don't contain other @-commands.
my %no_command_commands;
-foreach my $command ('errormsg', 'U') {
+foreach my $command ('errormsg', 'U', 'sortas') {
$no_command_commands{$command} = 1;
}
@@ -441,6 +448,7 @@
foreach my $brace_command (keys (%brace_commands)) {
if ($brace_commands{$brace_command} == 1
and !$simple_text_commands{$brace_command}
+ and $brace_command ne 'sortas'
and !$context_brace_commands{$brace_command}
and !$accent_commands{$brace_command}) {
$full_text_commands{$brace_command} = 1;
@@ -460,7 +468,7 @@
# context tests, to make sure, for instance that we are testing
# @-commands on the block, misc or node @-command line and not
# in the content.
-# index entry commands are dynamically set as in_simple_text_commands
+# index entry commands are dynamically set as in_index_commands
my %default_valid_nestings;
foreach my $command (keys(%accent_commands)) {
@@ -656,7 +664,7 @@
foreach my $prefix ($index, substr($index, 0, 1)) {
$parser->{'misc_commands'}->{$prefix.'index'} = 'line';
$parser->{'no_paragraph_commands'}->{$prefix.'index'} = 1;
- $parser->{'valid_nestings'}->{$prefix.'index'} =
\%in_simple_text_commands;
+ $parser->{'valid_nestings'}->{$prefix.'index'} = \%in_index_commands;
$parser->{'command_index'}->{$prefix.'index'} = $index;
}
}
@@ -2466,6 +2474,9 @@
'command' => $current,
'number' => $number,
};
+ if (defined $current->{'extra'}->{'sortas'}) {
+ $index_entry->{'sortas'} = $current->{'extra'}->{'sortas'};
+ }
if (@{$self->{'regions_stack'}}) {
$index_entry->{'region'} = $self->{'regions_stack'}->[-1];
} elsif ($self->{'current_node'}) {
@@ -5165,6 +5176,17 @@
if (!$current->{'parent'}->{'type'});
$current->{'parent'}->{'parent'}->{'parent'}->{'extra'}->{'command_as_argument'}
= $current->{'parent'};
+ } elsif ($current->{'parent'}->{'cmdname'} eq 'sortas') {
+ my @contents = @{$current->{'contents'}};
+ _trim_spaces_comment_from_content (address@hidden);
+ my $arg = $contents[0]->{'text'};
+ if (defined($arg)) {
+ my $index_element =
$current->{'parent'}->{'parent'}->{'parent'};
+ if ($index_element->{'type'}
+ and $index_element->{'type'} eq 'index_entry_command') {
+ $index_element->{'extra'}->{'sortas'} = $arg;
+ }
+ }
}
_register_global_command($self, $current->{'parent'}->{'cmdname'},
$current->{'parent'}, $line_nr);
@@ -5653,7 +5675,7 @@
}
$self->{'misc_commands'}->{$name.'index'} = 'line';
$self->{'no_paragraph_commands'}->{$name.'index'} = 1;
- $self->{'valid_nestings'}->{$name.'index'} = \%in_simple_text_commands;
+ $self->{'valid_nestings'}->{$name.'index'} = \%in_index_commands;
$self->{'command_index'}->{$name.'index'} = $name;
}
} else {
Modified: trunk/tp/Texinfo/Structuring.pm
===================================================================
--- trunk/tp/Texinfo/Structuring.pm 2017-03-25 15:24:50 UTC (rev 7701)
+++ trunk/tp/Texinfo/Structuring.pm 2017-04-01 18:14:31 UTC (rev 7702)
@@ -1493,8 +1493,12 @@
}
$entry->{'in_code'} =
$index_names->{$entry->{'index_name'}}->{'in_code'};
$options->{'code'} = $entry->{'in_code'};
- $entry->{'key'} = Texinfo::Convert::Text::convert(
+ if (defined $entry->{'sortas'}) {
+ $entry->{'key'} = $entry->{'sortas'};
+ } else {
+ $entry->{'key'} = Texinfo::Convert::Text::convert(
{'contents' => $entry->{'content'}}, $options);
+ }
if ($entry->{'key'} !~ /\S/) {
$self->line_warn(sprintf($self->__("empty index key in
address@hidden"),
$entry->{'index_at_command'}),
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [7702] @sortas in texi2any,
gavinsmith0123 <=