[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Use array of array reference pairs for attributes
From: |
Patrice Dumas |
Subject: |
branch master updated: Use array of array reference pairs for attributes. Other fixes. |
Date: |
Sat, 10 Sep 2022 19:56:45 -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 f29a2af9ee Use array of array reference pairs for attributes. Other
fixes.
f29a2af9ee is described below
commit f29a2af9ee6193a9cca091a5f6ab8f78cb17b358
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Sep 11 01:56:04 2022 +0200
Use array of array reference pairs for attributes. Other fixes.
---
tp/Texinfo/Convert/IXIN.pm | 178 +++++++++++++++++++++++----------------------
1 file changed, 92 insertions(+), 86 deletions(-)
diff --git a/tp/Texinfo/Convert/IXIN.pm b/tp/Texinfo/Convert/IXIN.pm
index 9c6277b3c9..21cabb6ae4 100644
--- a/tp/Texinfo/Convert/IXIN.pm
+++ b/tp/Texinfo/Convert/IXIN.pm
@@ -108,13 +108,17 @@ sub _ixin_attributes($$$)
my $attributes = shift;
my $result = '';
if ($attributes) {
- for (my $i = 0; $i < scalar(@$attributes); $i += 2) {
+ foreach my $attribute_spec (@$attributes) {
+ if (ref($attribute_spec) ne 'ARRAY') {
+ cluck "attribute_spec not an array($attribute_spec).";
+ }
+
if ($attribute_string_names{$name}
- and $attribute_string_names{$name}->{$attributes->[$i]}) {
+ and $attribute_string_names{$name}->{$attribute_spec->[0]}) {
$result .= '"'
-
.Texinfo::Convert::TexinfoSXML->protect_text($attributes->[$i+1]).'"';
+
.Texinfo::Convert::TexinfoSXML->protect_text($attribute_spec->[1]).'"';
} else {
- $result .= $attributes->[$i+1];
+ $result .= $attribute_spec->[1];
}
$result .= ' ';
}
@@ -267,7 +271,7 @@ sub output_ixin($$)
my $self = shift;
my $root = shift;
- my ($outfile, $destination_directory) =
$self->determine_files_and_directory();
+ my ($output_file, $destination_directory) =
$self->determine_files_and_directory();
my ($encoded_destination_directory, $dir_encoding)
= $self->encoded_output_file_name($destination_directory);
@@ -299,10 +303,10 @@ sub output_ixin($$)
$result .= $self->ixin_open_element('meta');
$result .= $self->ixin_open_element('xid');
- my $output_file = $self->ixin_none_element('filename');
- if ($output_file ne '') {
+ my $output_file_name = $self->ixin_none_element('filename');
+ if ($output_file_name ne '') {
$result .= $self->ixin_list_element('filename',
- ['name', $output_file]);
+ [['name', $output_file_name]]);
}
my $lang = $self->get_conf('documentlanguage');
#my $lang_code = $lang;
@@ -312,9 +316,9 @@ sub output_ixin($$)
# $region_code = $2;
#}
$result .= ' ';
- $result .= $self->ixin_list_element('lang', ['name', $lang]);
+ $result .= $self->ixin_list_element('lang', [['name', $lang]]);
# FIXME title: use simpletitle or fulltitle
-
+
if ($self->{'parser_info'}->{'dircategory_direntry'}) {
my $current_category;
foreach my $dircategory_direntry
(@{$self->{'parser_info'}->{'dircategory_direntry'}}) {
@@ -325,7 +329,7 @@ sub output_ixin($$)
$current_category = $dircategory_direntry;
$result .= $self->ixin_open_element('category');
# FIXME wait for Thien-Thi input on renderable or string.
- } elsif ($dircategory_direntry->{'cmdname'}
+ } elsif ($dircategory_direntry->{'cmdname'}
and $dircategory_direntry->{'cmdname'} eq 'direntry') {
# FIXME wait for Thien-Thi input on renderable or string and node
# rendering
@@ -355,14 +359,14 @@ sub output_ixin($$)
and !$global_misc_not_setting_commands{$global_command}) {
if (ref($self->{'global_commands'}->{$global_command}) eq 'ARRAY') {
if
(defined($Texinfo::Common::document_settable_multiple_at_commands{$global_command}))
{
- $setting_commands_defaults{$global_command}
+ $setting_commands_defaults{$global_command}
=
$Texinfo::Common::document_settable_multiple_at_commands{$global_command};
}
foreach my $command (@{$self->{'global_commands'}->{$global_command}})
{
my ($element, $root_command) = _get_element($self, $command);
# before first node
- if (!defined($root_command->{'extra'})
- and !defined($root_command->{'extra'}->{'normalized'})) {
+ if (!defined($root_command->{'extra'})
+ or !defined($root_command->{'extra'}->{'normalized'})) {
$setting_commands{$global_command} = $command;
} else {
# register the setting value at the end of the node
@@ -374,7 +378,7 @@ sub output_ixin($$)
} else {
# FIXME the value is reset just after, this is useless...
if
(defined($Texinfo::Common::document_settable_unique_at_commands{$global_command}))
{
- $setting_commands_defaults{$global_command}
+ $setting_commands_defaults{$global_command}
=
$Texinfo::Common::document_settable_unique_at_commands{$global_command};
}
$setting_commands{$global_command} =
$self->{'global_commands'}->{$global_command};
@@ -384,13 +388,14 @@ sub output_ixin($$)
my %settings;
foreach my $setting_command_name (keys(%setting_commands)) {
my $setting_command = $setting_commands{$setting_command_name};
- $setting_command_name = 'shortcontents'
+ $setting_command_name = 'shortcontents'
if ($setting_command_name eq 'summarycontents');
- my $value = $self->_informative_command_value($setting_command);
+ # FIXME should use set_informative_command_value and get_conf instead
+ my $value = Texinfo::Common::_informative_command_value($setting_command);
#print STDERR "$setting_command_name $value\n";
# do not register settings if sete at the default value.
- if (defined($value)
- and !(defined($setting_commands_defaults{$setting_command_name})
+ if (defined($value)
+ and !(defined($setting_commands_defaults{$setting_command_name})
and $setting_commands_defaults{$setting_command_name} eq
$value)) {
$settings{$setting_command_name} = $value;
}
@@ -404,8 +409,8 @@ sub output_ixin($$)
$result .= $self->ixin_symbol_element('settingname', $command_name);
$result .= ' ';
if ($Texinfo::Common::misc_commands{$command_name} eq 'lineraw') {
- $result .= $self->ixin_list_element('settingvalue',
- ['value', $settings{$command_name}]);
+ $result .= $self->ixin_list_element('settingvalue',
+ [['value', $settings{$command_name}]]);
} else {
$result .= $self->ixin_symbol_element('settingvalue',
$settings{$command_name});
}
@@ -455,19 +460,20 @@ sub output_ixin($$)
$document_output .= $node_result;
# get node length.
- $node_byte_sizes{$normalized_node_name}
+ $node_byte_sizes{$normalized_node_name}
= $self->_count_bytes($node_result);
# update current settings
if (defined($end_of_nodes_setting_commands{$normalized_node_name})) {
foreach my $setting_command_name
(keys(%{$end_of_nodes_setting_commands{$normalized_node_name}})) {
- my $value = $self->_informative_command_value(
+ # FIXME should use Texinfo::Common::set_informative_command_value
and get_conf
+ my $value =
Texinfo::Common::_informative_command_value_informative_command_value(
$end_of_nodes_setting_commands{$normalized_node_name}->{$setting_command_name});
- if ((defined($settings{$setting_command_name})
+ if ((defined($settings{$setting_command_name})
and $settings{$setting_command_name} eq $value)
or (!defined($settings{$setting_command_name})
and
defined($setting_commands_defaults{$setting_command_name})
and $setting_commands_defaults{$setting_command_name} eq
$value)) {
- delete $current_settings{$setting_command_name};
+ delete $current_settings{$setting_command_name};
} else {
$current_settings{$setting_command_name} = $value;
}
@@ -482,24 +488,24 @@ sub output_ixin($$)
foreach my $node (@nodes) {
my $normalized_node_name = $node->{'extra'}->{'normalized'};
# FIXME name should be a renderable sequence
- my @attributes = ('name', $normalized_node_name,
- 'length', $node_byte_sizes{$normalized_node_name});
+ my @attributes = (['name', $normalized_node_name],
+ ['length', $node_byte_sizes{$normalized_node_name}]);
foreach my $direction (@node_directions) {
if ($node->{'node_'.lc($direction)}) {
my $node_direction = $node->{'node_'.lc($direction)};
if ($node_direction->{'extra'}->{'manual_content'}) {
# FIXME?
- push @attributes, ('node'.lc($direction), -2);
+ push @attributes, ['node'.lc($direction), -2];
} else {
- push @attributes, ('node'.lc($direction),
-
$node_label_number{$node_direction->{'extra'}->{'normalized'}})
+ push @attributes, ['node'.lc($direction),
+
$node_label_number{$node_direction->{'extra'}->{'normalized'}}]
}
} else {
- push @attributes, ('node'.lc($direction), -1);
+ push @attributes, ['node'.lc($direction), -1];
}
}
$nodes_index .= $self->ixin_open_element('nodeentry', \@attributes);
-
+
if ($node_tweaks{$normalized_node_name}) {
$nodes_index .= $self->ixin_open_element('nodetweaks');
foreach my $command_name
(sort(keys(%{$node_tweaks{$normalized_node_name}}))) {
@@ -507,14 +513,13 @@ sub output_ixin($$)
$nodes_index .= $self->ixin_symbol_element('nodetweakname',
$command_name);
$nodes_index .= ' ';
if ($Texinfo::Common::misc_commands{$command_name} eq 'lineraw') {
- $nodes_index .= $self->ixin_list_element('nodetweakvalue',
- ['value', $node_tweaks{$normalized_node_name}->{$command_name}]);
+ $nodes_index .= $self->ixin_list_element('nodetweakvalue',
+ [['value', $node_tweaks{$normalized_node_name}->{$command_name}]]);
} else {
- $nodes_index .= $self->ixin_symbol_element('nodetweakvalue',
+ $nodes_index .= $self->ixin_symbol_element('nodetweakvalue',
$node_tweaks{$normalized_node_name}->{$command_name});
}
$nodes_index .= $self->ixin_close_element('nodetweak');
-
}
$nodes_index .= $self->ixin_close_element('nodetweaks');
}
@@ -532,10 +537,10 @@ sub output_ixin($$)
my $section = $top_section;
SECTION:
while ($section) {
- my $associated_node_id = $self->_associated_node_id($section,
+ my $associated_node_id = $self->_associated_node_id($section,
\%node_label_number);
- my @attributes = ('nodeid', $associated_node_id, 'type',
-
Texinfo::Structuring::section_level_adjusted_command_name($section));
+ my @attributes = (['nodeid', $associated_node_id], ['type',
+
Texinfo::Structuring::section_level_adjusted_command_name($section)]);
$sectioning_tree .= $self->ixin_open_element('sectionentry',
\@attributes);
$sectioning_tree .= $self->ixin_open_element('sectiontitle');
@@ -590,11 +595,11 @@ sub output_ixin($$)
my $command = $self->{'labels'}->{$label};
next if ($command->{'cmdname'} eq 'node');
$labels_nr++;
- my $associated_node_id = $self->_associated_node_id($command,
+ my $associated_node_id = $self->_associated_node_id($command,
\%node_label_number);
- $non_node_labels_text .= $self->ixin_element('label', ['name', $label,
- 'nodeid', $associated_node_id,
- 'type', $command->{'cmdname'}]);
+ $non_node_labels_text .= $self->ixin_element('label', [['name', $label],
+ ['nodeid', $associated_node_id],
+ ['type', $command->{'cmdname'}]]);
# register floats to avoid doing it twice for the float specific index
if ($command->{'cmdname'} eq 'float') {
@@ -602,16 +607,16 @@ sub output_ixin($$)
}
}
}
-
- my $labels_text = $self->ixin_open_element('labels', ['count', $labels_nr]);
+
+ my $labels_text = $self->ixin_open_element('labels', [['count',
$labels_nr]]);
foreach my $node (@nodes) {
- $labels_text .= $self->ixin_list_element('nodelabel', ['name',
- $node->{'extra'}->{'normalized'}]);
+ $labels_text .= $self->ixin_list_element('nodelabel', [['name',
+ $node->{'extra'}->{'normalized'}]]);
$labels_text .= ' ';
}
- $labels_text .= $non_node_labels_text
+ $labels_text .= $non_node_labels_text
. $self->ixin_close_element('labels')."\n";
-
+
# do document-term sets (indices counts and indices)
my %dts_information;
@@ -621,8 +626,8 @@ sub output_ixin($$)
my $merged_index_entries
= Texinfo::Structuring::merge_indices($index_names);
my ($entries, $index_entries_sort_strings)
- = $self->Texinfo::Structuring::sort_indices($self,
- $self, $merged_index_entries);
+ = Texinfo::Structuring::sort_indices($self,
+ $self, $merged_index_entries);
# first do the dts_text as the counts are needed for the dts index
foreach my $index_name (sort(keys(%$entries))) {
my $dts_text_result = '';
@@ -638,23 +643,23 @@ sub output_ixin($$)
$associated_node_id = -1;
}
my $entry = $self->convert_tree({'contents' =>
$dts_entry->{'content'}});
- $dts_text_result .= $self->ixin_open_element('dtsentry',
- ['nodeid',
$associated_node_id]);
+ $dts_text_result .= $self->ixin_open_element('dtsentry',
+ [['nodeid',
$associated_node_id]]);
$dts_text_result .= $self->ixin_open_element('dtsterm');
$dts_text_result .= $entry;
$dts_text_result .= $self->ixin_close_element('dtsterm');
if ($dts_entry->{'in_code'} != $dts_in_code) {
my $font_name = $self->_index_font_name($dts_entry->{'in_code'});
$dts_text_result .= ' ';
- $dts_text_result .= $self->ixin_list_element('dtsfont', ['font',
-
$font_name]);
+ $dts_text_result .= $self->ixin_list_element('dtsfont', [['font',
+
$font_name]]);
}
$dts_text_result .= $self->ixin_close_element('dtsentry');
$dts_entries_nr++;
}
- my $dts_opening = $self->ixin_open_element('dts', ['count',
$dts_entries_nr,
- 'font',
$self->_index_font_name($dts_in_code)]);
- $dts_text_result = $dts_opening . $dts_text_result
+ my $dts_opening = $self->ixin_open_element('dts', [['count',
$dts_entries_nr],
+ ['font',
$self->_index_font_name($dts_in_code)]]);
+ $dts_text_result = $dts_opening . $dts_text_result
. $self->ixin_close_element('dts') . "\n";
$dts_information{$index_name}->{'dts_text'} = $dts_text_result;
}
@@ -663,7 +668,7 @@ sub output_ixin($$)
# Gather information on printindex @-commands associated node id
if ($self->{'global_commands'}->{'printindex'}) {
foreach my $command (@{$self->{'global_commands'}->{'printindex'}}) {
- my $associated_node_id = $self->_associated_node_id($command,
+ my $associated_node_id = $self->_associated_node_id($command,
\%node_label_number);
if ($command->{'extra'} and $command->{'extra'}->{'misc_args'}
and defined($command->{'extra'}->{'misc_args'}->[0])) {
@@ -679,15 +684,14 @@ sub output_ixin($$)
foreach my $index_name (sort(keys(%dts_information))) {
my $dts_len = 0;
if (exists($dts_information{$index_name}->{'dts_text'})) {
-
$dts_len =
$self->_count_bytes($dts_information{$index_name}->{'dts_text'});
$dts_text .= $dts_information{$index_name}->{'dts_text'};
}
- my @attributes = ('name', $index_name, 'dtslen', $dts_len);
+ my @attributes = (['name', $index_name], ['dtslen', $dts_len]);
$dts_index .= $self->ixin_open_element('dtsindexentry', \@attributes);
if ($dts_information{$index_name}->{'node_id'}) {
foreach my $node_id
(sort(@{$dts_information{$index_name}->{'node_id'}})) {
- $dts_index .= $self->ixin_list_element('dtsnodeid', ['nodeid',
$node_id]);
+ $dts_index .= $self->ixin_list_element('dtsnodeid', [['nodeid',
$node_id]]);
$dts_index .= ' ';
}
}
@@ -697,8 +701,8 @@ sub output_ixin($$)
$dts_text .= $self->ixin_close_element('dtssets') ."\n";
if ($dts_index ne '') {
- $dts_index = $self->ixin_open_element('dtsindex', ['dtsindexlen',
- $self->_count_bytes($dts_text)])
+ $dts_index = $self->ixin_open_element('dtsindex', [['dtsindexlen',
+ $self->_count_bytes($dts_text)]])
. $dts_index . $self->ixin_close_element('dtsindex');
} else {
$dts_index = $self->ixin_none_element('dtsindex')
@@ -718,12 +722,12 @@ sub output_ixin($$)
# collect listoffloats information
if ($self->{'global_commands'}->{'listoffloats'}) {
foreach my $command (@{$self->{'global_commands'}->{'listoffloats'}}) {
- my $associated_node_id = $self->_associated_node_id($command,
+ my $associated_node_id = $self->_associated_node_id($command,
\%node_label_number);
my $type = $command->{'extra'}->{'type'}->{'normalized'};
if ($command->{'extra'}->{'type'}->{'content'}) {
- $floats_information{$type}->{'type'}
- = $self->convert_tree({'contents'
+ $floats_information{$type}->{'type'}
+ = $self->convert_tree({'contents'
=> $command->{'extra'}->{'type'}->{'content'}});
}
push @{$floats_information{$type}->{'node_id'}}, $associated_node_id;
@@ -745,21 +749,21 @@ sub output_ixin($$)
if (exists($floats_associated_node_id{$float})) {
$associated_node_id = $floats_associated_node_id{$float};
} else {
- $associated_node_id = $self->_associated_node_id($float,
+ $associated_node_id = $self->_associated_node_id($float,
\%node_label_number);
}
- my @attribute = ('nodeid', $associated_node_id);
+ my @attribute = (['nodeid', $associated_node_id]);
$float_text .= $self->ixin_open_element('floatentry', \@attribute);
if ($float->{'extra'}->{'normalized'}) {
- $float_text .= $self->ixin_list_element('floatlabel',
- ['name', $float->{'extra'}->{'normalized'}]);
+ $float_text .= $self->ixin_list_element('floatlabel',
+ [['name',
$float->{'extra'}->{'normalized'}]]);
$float_text .= ' ';
} else {
$float_text .= $self->ixin_none_element('floatlabel');
}
if ($float->{'extra'}->{'node_content'}) {
$float_text .= $self->ixin_open_element('floatname');
- $float_text .= $self->convert_tree({'contents'
+ $float_text .= $self->convert_tree({'contents'
=> $float->{'extra'}->{'node_content'}});
$float_text .= $self->ixin_close_element('floatname');
} else {
@@ -774,7 +778,7 @@ sub output_ixin($$)
}
$float_text .= $self->ixin_close_element('floatentry')."\n";
}
- $float_text = $self->ixin_open_element('floatset', ['count', $float_nr])
+ $float_text = $self->ixin_open_element('floatset', [['count',
$float_nr]])
. $float_text .$self->ixin_close_element('floatset')."\n";
$float_text_len = $self->_count_bytes($float_text);
$floats_text .= $float_text;
@@ -791,7 +795,7 @@ sub output_ixin($$)
}
}
}
- my @attribute = ('type', $type, 'floatentrylen', $float_text_len);
+ my @attribute = (['type', $type], ['floatentrylen', $float_text_len]);
$floats_index .= $self->ixin_open_element('floatindex', \@attribute);
if ($floats_information{$type}->{'type'}) {
$floats_index .= $self->ixin_open_element('floatindextype');
@@ -804,7 +808,7 @@ sub output_ixin($$)
foreach my $associated_node_id
(@{$floats_information{$type}->{'node_id'}}) {
$floats_index .= ' ';
$floats_index .= $self->ixin_list_element('floatindexnode',
- ['nodeid', $associated_node_id]);
+ [['nodeid', $associated_node_id]]);
}
}
$floats_index .= $self->ixin_close_element('floatindex');
@@ -812,8 +816,8 @@ sub output_ixin($$)
$floats_text .= $self->ixin_close_element('floatsset')."\n";
if ($floats_index ne '') {
- $floats_index = $self->ixin_open_element('floatsindex', ['floatsindexlen',
- $self->_count_bytes($floats_text)])
+ $floats_index = $self->ixin_open_element('floatsindex', [['floatsindexlen',
+ $self->_count_bytes($floats_text)]])
.$floats_index .$self->ixin_close_element('floatsindex');
} else {
$floats_index = $self->ixin_none_element('floatsindex');
@@ -837,6 +841,8 @@ sub output_ixin($$)
{'contents' => $command->{'args'}->[0]->{'contents'}},
{'code' => 1,
Texinfo::Convert::Text::copy_options_for_convert_text($self, 1)});
+ } else {
+ next;
}
if (defined($command->{'args'}->[4])
and @{$command->{'args'}->[4]->{'contents'}}) {
@@ -857,7 +863,7 @@ sub output_ixin($$)
$blob_nr++;
if ($extension eq 'txt') {
binmode($filehandle, ":encoding("
- .$self->{'parser_info'}->{'input_perl_encoding'})
+ .$self->{'parser_info'}->{'input_perl_encoding'}.")")
if (defined($self->{'parser_info'}->{'input_perl_encoding'}));
}
my $file_content;
@@ -876,8 +882,8 @@ sub output_ixin($$)
$mime_type = $extension_mime_mapping{''};
}
$blobs_index .= $self->ixin_element('blobentry',
- ['bloblen', $blob_len, 'encoding', 'base64',
- 'mimetype', $mime_type, 'filename', $file_name_text]) ."\n";
+ [['bloblen', $blob_len], ['encoding', 'base64'],
+ ['mimetype', $mime_type], ['filename', $file_name_text]]) ."\n";
}
}
}
@@ -885,14 +891,14 @@ sub output_ixin($$)
}
}
$blobs_index = $self->ixin_open_element('blobsindex',
- ['count', $blob_nr])
+ [['count', $blob_nr]])
.$blobs_index.$self->ixin_close_element('blobsindex')."\n";
- my @counts_attributes = ('nodeindexlen', $self->_count_bytes($nodes_index),
- 'nodecounts', $node_nr,
- 'sectioningtreelen', $self->_count_bytes($sectioning_tree),
- 'labelslen', $self->_count_bytes($labels_text),
- 'blobsindexlen', $self->_count_bytes($blobs_index));
+ my @counts_attributes = (['nodeindexlen', $self->_count_bytes($nodes_index)],
+ ['nodecounts', $node_nr],
+ ['sectioningtreelen',
$self->_count_bytes($sectioning_tree)],
+ ['labelslen', $self->_count_bytes($labels_text)],
+ ['blobsindexlen', $self->_count_bytes($blobs_index)]);
my $output = $self->write_or_return($result, $fh);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Use array of array reference pairs for attributes. Other fixes.,
Patrice Dumas <=