[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/Converter.pm (converter), tp
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Convert/Converter.pm (converter), tp/Texinfo/Convert/HTML.pm (_load_htmlxref_files, output), tp/Texinfo/Convert/IXIN.pm (output_ixin), tp/Texinfo/Convert/Info.pm (output, _info_header), tp/Texinfo/Convert/Text.pm (converter, output): rename 'info' as 'parser_info' in converter. |
Date: |
Sun, 29 Aug 2021 07:08:11 -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 16ff6e5 * tp/Texinfo/Convert/Converter.pm (converter),
tp/Texinfo/Convert/HTML.pm (_load_htmlxref_files, output),
tp/Texinfo/Convert/IXIN.pm (output_ixin), tp/Texinfo/Convert/Info.pm (output,
_info_header), tp/Texinfo/Convert/Text.pm (converter, output): rename 'info' as
'parser_info' in converter.
16ff6e5 is described below
commit 16ff6e53257e8f2eb30fc736704a0e33a8296956
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Aug 29 13:08:01 2021 +0200
* tp/Texinfo/Convert/Converter.pm (converter),
tp/Texinfo/Convert/HTML.pm (_load_htmlxref_files, output),
tp/Texinfo/Convert/IXIN.pm (output_ixin),
tp/Texinfo/Convert/Info.pm (output, _info_header),
tp/Texinfo/Convert/Text.pm (converter, output): rename 'info'
as 'parser_info' in converter.
* tp/Texinfo/Structuring.pm (warn_non_empty_parts)
(set_menus_node_directions, complete_node_tree_with_menus)
(nodes_tree, elements_directions, setup_index_entry_keys_formatting)
(do_index_keys, sort_indices, sort_indices_by_letter),
tp/texi2any.pl, tp/Texinfo/Convert/HTML.pm, tp/Texinfo/Convert/IXIN.pm,
tp/Texinfo/Convert/LaTeX.pm, tp/Texinfo/Convert/Plaintext.pm,
tp/init/chm.pm: pass explicitly parser informations and configuration
informations.
---
ChangeLog | 18 +++++
tp/Texinfo/Convert/Converter.pm | 10 +--
tp/Texinfo/Convert/HTML.pm | 9 +--
tp/Texinfo/Convert/IXIN.pm | 12 ++--
tp/Texinfo/Convert/Info.pm | 8 +--
tp/Texinfo/Convert/LaTeX.pm | 3 +-
tp/Texinfo/Convert/Plaintext.pm | 4 +-
tp/Texinfo/Convert/Text.pm | 19 +++--
tp/Texinfo/Structuring.pm | 123 ++++++++++++++++++++------------
tp/init/chm.pm | 3 +-
tp/t/automatic_nodes.t | 19 +++--
tp/t/do_master_menu.t | 16 +++--
tp/t/results/indices/def_syn_indices.pl | 2 +-
tp/t/results/indices/ftable_vtable.pl | 2 +-
tp/t/test_sort.t | 8 ++-
tp/texi2any.pl | 17 +++--
16 files changed, 178 insertions(+), 95 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 66f3a26..76cd53a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2021-08-29 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/Converter.pm (converter),
+ tp/Texinfo/Convert/HTML.pm (_load_htmlxref_files, output),
+ tp/Texinfo/Convert/IXIN.pm (output_ixin),
+ tp/Texinfo/Convert/Info.pm (output, _info_header),
+ tp/Texinfo/Convert/Text.pm (converter, output): rename 'info'
+ as 'parser_info' in converter.
+
+ * tp/Texinfo/Structuring.pm (warn_non_empty_parts)
+ (set_menus_node_directions, complete_node_tree_with_menus)
+ (nodes_tree, elements_directions, setup_index_entry_keys_formatting)
+ (do_index_keys, sort_indices, sort_indices_by_letter),
+ tp/texi2any.pl, tp/Texinfo/Convert/HTML.pm, tp/Texinfo/Convert/IXIN.pm,
+ tp/Texinfo/Convert/LaTeX.pm, tp/Texinfo/Convert/Plaintext.pm,
+ tp/init/chm.pm: pass explicitly parser informations and configuration
+ informations.
+
2021-08-28 Gavin Smith <gavinsmith0123@gmail.com>
* tp/Texinfo/ParserNonXS.pm (_parse_texi): avoid "invalid
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 401f2b2..9343b6f 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -204,7 +204,7 @@ sub converter(;$)
$converter->{'parser'} = $conf->{'parser'};
$converter->{'extra'}
= $converter->{'parser'}->global_commands_information();
- $converter->{'info'} = $converter->{'parser'}->global_informations();
+ $converter->{'parser_info'} =
$converter->{'parser'}->global_informations();
my $floats = $converter->{'parser'}->floats_information();
my ($labels, $targets_list, $nodes_list)
= $converter->{'parser'}->labels_information();
@@ -237,8 +237,8 @@ sub converter(;$)
}
}
$converter->set_conf('OUTPUT_ENCODING_NAME',
- $converter->{'info'}->{'input_encoding_name'})
- if ($converter->{'info'}->{'input_encoding_name'});
+ $converter->{'parser_info'}->{'input_encoding_name'})
+ if ($converter->{'parser_info'}->{'input_encoding_name'});
if (!$converter->get_conf('OUTPUT_PERL_ENCODING')
and $converter->get_conf('OUTPUT_ENCODING_NAME')) {
my $perl_encoding
@@ -379,10 +379,10 @@ sub _set_outfile($$$)
# determine input file base name
my $input_basename;
- if (defined($self->{'info'}->{'input_file_name'})) {
+ if (defined($self->{'parser_info'}->{'input_file_name'})) {
my ($directories, $suffix);
($input_basename, $directories, $suffix)
- = fileparse($self->{'info'}->{'input_file_name'});
+ = fileparse($self->{'parser_info'}->{'input_file_name'});
} else {
# This could happen if called on a piece of texinfo
$input_basename = '';
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index d01e5a5..bf4500d 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -5073,7 +5073,7 @@ sub _load_htmlxref_files {
# directories if TEST is set.
@htmlxref_dirs = File::Spec->catdir($curdir, '.texinfo');
- my $input_directory = $self->{'info'}->{'input_directory'};
+ my $input_directory = $self->{'parser_info'}->{'input_directory'};
if (defined($input_directory)
and $input_directory ne '.' and $input_directory ne '') {
unshift @htmlxref_dirs, $input_directory;
@@ -6104,7 +6104,8 @@ sub _prepare_index_entries($)
my $merged_index_entries
= Texinfo::Structuring::merge_indices($index_names);
$self->{'index_entries_by_letter'}
- = Texinfo::Structuring::sort_indices_by_letter ($self->{'parser'},
+ = Texinfo::Structuring::sort_indices_by_letter ($self->{'parser'}, $self,
+ $self->{'parser_info'},
$merged_index_entries, $index_names);
$self->{'index_entries'} = $merged_index_entries;
@@ -7398,7 +7399,7 @@ sub output($$)
$self->_prepare_contents_elements();
# do element directions.
- Texinfo::Structuring::elements_directions($self, $elements);
+ Texinfo::Structuring::elements_directions($self, $self, $elements);
# do element directions related to files.
# FIXME do it here or before? Here it means that
@@ -7486,7 +7487,7 @@ sub output($$)
'title_string');
$self->file_line_warn(__(
"must specify a title with a title command or \@top"),
- $self->{'info'}->{'input_file_name'});
+ $self->{'parser_info'}->{'input_file_name'});
} else {
$self->{'title_string'} = $html_title_string;
}
diff --git a/tp/Texinfo/Convert/IXIN.pm b/tp/Texinfo/Convert/IXIN.pm
index 33f853b..061e489 100644
--- a/tp/Texinfo/Convert/IXIN.pm
+++ b/tp/Texinfo/Convert/IXIN.pm
@@ -314,9 +314,9 @@ sub output_ixin($$)
$result .= $self->ixin_list_element('lang', ['name', $lang]);
# FIXME title: use simpletitle or fulltitle
- if ($self->{'info'}->{'dircategory_direntry'}) {
+ if ($self->{'parser_info'}->{'dircategory_direntry'}) {
my $current_category;
- foreach my $dircategory_direntry
(@{$self->{'info'}->{'dircategory_direntry'}}) {
+ foreach my $dircategory_direntry
(@{$self->{'parser_info'}->{'dircategory_direntry'}}) {
if ($dircategory_direntry->{'cmdname'} and
$dircategory_direntry->{'cmdname'} eq 'dircategory') {
if ($current_category) {
$result .= $self->ixin_close_element('category');
@@ -616,8 +616,8 @@ sub output_ixin($$)
my $merged_index_entries
= Texinfo::Structuring::merge_indices($index_names);
my $entries
- = $self->Texinfo::Structuring::sort_indices($self->{'parser'},
- $merged_index_entries, $index_names);
+ = $self->Texinfo::Structuring::sort_indices($self->{'parser'}, $self,
+ $self->{'parser_info'}, $merged_index_entries, $index_names);
# 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 = '';
@@ -848,8 +848,8 @@ sub output_ixin($$)
$blob_nr++;
if ($extension eq 'txt') {
binmode($filehandle, ":encoding("
- .$self->{'info'}->{'input_perl_encoding'}
- if (defined($self->{'info'}->{'input_perl_encoding'});
+ .$self->{'parser_info'}->{'input_perl_encoding'}
+ if (defined($self->{'parser_info'}->{'input_perl_encoding'});
}
my $file_content;
if (-z $file) {
diff --git a/tp/Texinfo/Convert/Info.pm b/tp/Texinfo/Convert/Info.pm
index 8420eb2..38cb3d8 100644
--- a/tp/Texinfo/Convert/Info.pm
+++ b/tp/Texinfo/Convert/Info.pm
@@ -103,7 +103,7 @@ sub output($)
my @indirect_files;
if (!defined($elements) or $elements->[0]->{'extra'}->{'no_node'}) {
$self->file_line_warn(__("document without nodes"),
- $self->{'info'}->{'input_file_name'});
+ $self->{'parser_info'}->{'input_file_name'});
my $output = $header.$self->_convert($root);
$self->_count_context_bug_message('no element ');
@@ -120,7 +120,7 @@ sub output($)
unless ($self->{'structuring'} and $self->{'structuring'}->{'top_node'}
and $self->{'structuring'}->{'top_node'}->{'extra'}->{'normalized'} eq
'Top') {
$self->file_line_warn(__("document without Top node"),
- $self->{'info'}->{'input_file_name'});
+ $self->{'parser_info'}->{'input_file_name'});
}
$out_file_nr = 1;
my $first_node = 0;
@@ -332,9 +332,9 @@ sub _info_header($)
$result .= $self->_footnotes();
delete $self->{'in_copying_header'};
}
- if ($self->{'info'}->{'dircategory_direntry'}) {
+ if ($self->{'parser_info'}->{'dircategory_direntry'}) {
$self->{'ignored_commands'}->{'direntry'} = 0;
- foreach my $command (@{$self->{'info'}->{'dircategory_direntry'}}) {
+ foreach my $command (@{$self->{'parser_info'}->{'dircategory_direntry'}}) {
if ($command->{'cmdname'} eq 'dircategory') {
if ($command->{'args'} and @{$command->{'args'}}
and defined($command->{'args'}->[0]->{'contents'})) {
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 457da6f..b92da08 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -1603,7 +1603,8 @@ sub _index_entry($$)
# may change dynamically. But the current code does not set the
# values dynamically for now. Actually not set at all...
my ($options, $ignore_chars)
- = Texinfo::Structuring::setup_index_entry_keys_formatting($self);
+ = Texinfo::Structuring::setup_index_entry_keys_formatting($self, $self,
+ $self->{'parser_info'});
my $current_entry = $root;
my $current_sortas;
my $subentry_commands = [$root];
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 7e26a40..2bf2462 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -1206,8 +1206,8 @@ sub _printindex_formatted($$;$)
my $merged_index_entries
= Texinfo::Structuring::merge_indices($index_names);
$self->{'index_entries'}
- = Texinfo::Structuring::sort_indices($self->{'parser'},
- $merged_index_entries, $index_names);
+ = Texinfo::Structuring::sort_indices($self->{'parser'}, $self,
+ $self->{'parser_info'}, $merged_index_entries, $index_names);
$self->{'index_names'} = $index_names;
}
if (!$self->{'index_entries'} or !$self->{'index_entries'}->{$index_name}
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index 53561e3..3a3a85b 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -295,9 +295,9 @@ sub heading($$$;$$)
my $numbered = shift;
my $indent_length = shift;
- # REMARK to get the numberig right in case of an indented text, the
+ # REMARK to get the numbering right in case of an indented text, the
# indentation should be given here. But this should never happen as
- # the only @-commands allowed in indented context are not number.
+ # the only @-commands allowed in indented context are not numbered.
$text = Texinfo::Common::numbered_heading($converter, $current, $text,
$numbered);
return '' if ($text !~ /\S/);
@@ -371,6 +371,12 @@ sub _convert($;$)
if (defined($root->{'text'})) {
if ($root->{'type'} and $root->{'type'} eq 'untranslated'
and $options and $options->{'converter'}) {
+ # FIXME here converter is both a source for the documentlanguage
+ # information, modified for the translation and used for the
+ # translation itself. It is wrong on two levels
+ # * configuration and other functions should be seprated
+ # * there should not be a need to modify internal converter
+ # state to get the translation
my $save_lang = $options->{'converter'}->get_conf('documentlanguage');
$options->{'converter'}->{'documentlanguage'}
= $root->{'extra'}->{'documentlanguage'};
@@ -616,7 +622,7 @@ sub converter($)
my $expanded_formats = $converter->{'expanded_formats'};;
if ($converter->{'parser'}) {
- $converter->{'info'} = $converter->{'parser'}->global_informations();
+ $converter->{'parser_info'} =
$converter->{'parser'}->global_informations();
$converter->{'extra'} =
$converter->{'parser'}->global_commands_information();
foreach my $global_command ('documentencoding') {
if (defined($converter->{'extra'}->{$global_command})) {
@@ -669,10 +675,10 @@ sub output($$)
my $tree = shift;
#print STDERR "OUTPUT\n";
my $input_basename;
- if (defined($self->{'info'}->{'input_file_name'})) {
+ if (defined($self->{'parser_info'}->{'input_file_name'})) {
my ($directories, $suffix);
($input_basename, $directories, $suffix)
- = fileparse($self->{'info'}->{'input_file_name'});
+ = fileparse($self->{'parser_info'}->{'input_file_name'});
} else {
# This could happen if called on a piece of texinfo
$input_basename = '';
@@ -767,8 +773,9 @@ Texinfo::Convert::Text - Convert Texinfo tree to simple text
=head1 DESCRIPTION
Texinfo::Convert::Text is a simple backend that converts a Texinfo tree
-to simple text. It is used for some command argument expansion in
+to simple text. It is used for some command argument expansion in
C<Texinfo::Parser>, for instance the file names, or encoding names.
+It is also used in some converters, especially for file names.
The converter is very simple, and, in the default case, cannot handle
output strings translation or error handling.
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index 32facab..f5021d9 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -310,6 +310,7 @@ sub sectioning_structure($$)
return $sec_root;
}
+# for debugging
sub _print_sectioning_tree($);
sub _print_sectioning_tree($)
{
@@ -322,10 +323,11 @@ sub _print_sectioning_tree($)
}
-sub warn_non_empty_parts($)
+sub warn_non_empty_parts($$)
{
my $self = shift;
- my $global_commands = $self->global_commands_information();
+ my $global_commands = shift;
+
if ($global_commands->{'part'}) {
foreach my $part (@{$global_commands->{'part'}}) {
if (!Texinfo::Common::is_content_empty($part)) {
@@ -452,16 +454,19 @@ sub check_nodes_are_referenced
}
# set menu directions
-sub set_menus_node_directions($$$)
+sub set_menus_node_directions($$$$$$)
{
my $self = shift;
+ my $configuration_informations = shift;
+ my $parser_informations = shift;
+ my $global_commands = shift;
my $nodes_list = shift;
my $labels = shift;
return undef unless ($nodes_list and scalar(@{$nodes_list}));
- my $check_menu_entries = (!$self->{'info'}->{'novalidate'}
- and $self->get_conf('FORMAT_MENU') eq 'menu');
+ my $check_menu_entries = (!$parser_informations->{'novalidate'}
+ and $configuration_informations->get_conf('FORMAT_MENU') eq 'menu');
# First go through all the menus and set menu_up, menu_next and menu_prev,
# and warn for unknown nodes.
@@ -524,7 +529,6 @@ sub set_menus_node_directions($$$)
}
# Check @detailmenu
if ($check_menu_entries) {
- my $global_commands = $self->global_commands_information();
if ($global_commands->{'detailmenu'}) {
foreach my $detailmenu (@{$global_commands->{'detailmenu'}}) {
foreach my $menu_content (@{$detailmenu->{'contents'}}) {
@@ -565,9 +569,10 @@ sub _section_direction_associated_node($$)
# complete automatic directions with menus (and first node
# for Top node).
# Checks on structure related to menus.
-sub complete_node_tree_with_menus($$$)
+sub complete_node_tree_with_menus($$$$)
{
my $self = shift;
+ my $configuration_informations = shift;
my $nodes_list = shift;
my $top_node = shift;
@@ -598,7 +603,7 @@ sub complete_node_tree_with_menus($$$)
my $direction_associated_node
= _section_direction_associated_node($section, $direction);
if ($direction_associated_node) {
- if ($self->get_conf('CHECK_NORMAL_MENU_STRUCTURE')) {
+ if
($configuration_informations->get_conf('CHECK_NORMAL_MENU_STRUCTURE')) {
if ($section->{'section_up'}{'extra'}
and $section->{'section_up'}{'extra'}{'associated_node'}
and $section->{'section_up'}{'extra'}{'associated_node'}{'menus'}
@@ -620,7 +625,7 @@ sub complete_node_tree_with_menus($$$)
if (!$node->{'node_'.$direction}
and $node->{'menu_'.$direction}
and !$node->{'menu_'.$direction}->{'extra'}->{'manual_content'})
{
- if ($self->get_conf('CHECK_NORMAL_MENU_STRUCTURE')
+ if
($configuration_informations->get_conf('CHECK_NORMAL_MENU_STRUCTURE')
and $node->{'extra'}->{'associated_section'}) {
$self->line_warn(sprintf(
__("node `%s' is %s for `%s' in menu but not in sectioning"),
@@ -658,7 +663,7 @@ sub complete_node_tree_with_menus($$$)
# check consistency between node pointer and node entries menu order
if ($node->{'extra'}->{'normalized'} ne 'Top') {
foreach my $direction (@node_directions) {
- if ($self->get_conf('CHECK_NORMAL_MENU_STRUCTURE')
+ if
($configuration_informations->get_conf('CHECK_NORMAL_MENU_STRUCTURE')
and $node->{'node_'.$direction}
and $node->{'menu_'.$direction}
and $node->{'menu_'.$direction}
@@ -677,7 +682,7 @@ sub complete_node_tree_with_menus($$$)
}
# check for node up / menu up mismatch
- if ($self->get_conf('CHECK_NORMAL_MENU_STRUCTURE')
+ if ($configuration_informations->get_conf('CHECK_NORMAL_MENU_STRUCTURE')
and $node->{'node_up'}
# No check if node up is an external manual
and (!$node->{'node_up'}->{'extra'}->{'manual_content'})
@@ -699,9 +704,10 @@ sub complete_node_tree_with_menus($$$)
# set node directions based on sectioning and @node explicit directions
-sub nodes_tree($$$)
+sub nodes_tree($$$$)
{
my $self = shift;
+ my $parser_informations = shift;
my $nodes_list = shift;
my $labels = shift;
return undef unless ($nodes_list and @{$nodes_list});
@@ -769,7 +775,7 @@ sub nodes_tree($$$)
= $labels->{$node_direction->{'normalized'}};
$node->{'node_'.$direction} = $node_target;
- if (!$self->{'info'}->{'novalidate'}
+ if (!$parser_informations->{'novalidate'}
and !_check_node_same_texinfo_code($node_target,
$node_direction)) {
$self->line_warn(sprintf(
@@ -782,7 +788,7 @@ sub nodes_tree($$$)
$node->{'line_nr'});
}
} else {
- if ($self->{'info'}->{'novalidate'}) {
+ if ($parser_informations->{'novalidate'}) {
$node->{'node_'.$direction} = { 'extra' => $node_direction };
} else {
$self->line_error(sprintf(
@@ -984,9 +990,10 @@ sub _node_element($)
# Do element directions (like in texi2html) and store them
# in 'extra'->'directions'.
-sub elements_directions($$)
+sub elements_directions($$$)
{
my $self = shift;
+ my $configuration_informations = shift;
my $elements = shift;
return if (!$elements or !@$elements);
@@ -1117,7 +1124,7 @@ sub elements_directions($$)
}
# Use node up for Up if there is no section up.
# Not done in the default case.
- if ($self->get_conf('USE_UP_NODE_FOR_ELEMENT_UP')
+ if ($configuration_informations->get_conf('USE_UP_NODE_FOR_ELEMENT_UP')
and !$directions->{'Up'} and $element->{'extra'}->{'node'}
and $element->{'extra'}->{'node'}->{'node_up'}
and (!$node_top or ($element->{'extra'}->{'node'} ne $node_top))) {
@@ -1285,9 +1292,10 @@ sub _unsplit($)
# For each internal reference command, set the 'label' key in the 'extra'
# hash of the reference tree element to the associated labeled tree element.
-sub associate_internal_references($$$)
+sub associate_internal_references($$$$)
{
my $self = shift;
+ my $parser_informations = shift;
my $labels = shift;
my $refs = shift;
@@ -1315,7 +1323,7 @@ sub associate_internal_references($$$)
$node_arg->{'normalized'} = $normalized;
}
if (!defined($labels->{$node_arg->{'normalized'}})) {
- if (!$self->{'info'}->{'novalidate'}) {
+ if (!$parser_informations->{'novalidate'}) {
$self->line_error(sprintf(__("\@%s reference to nonexistent node
`%s'"),
$ref->{'cmdname'}, node_extra_to_texi($node_arg)),
$ref->{'line_nr'});
@@ -1323,7 +1331,7 @@ sub associate_internal_references($$$)
} else {
my $node_target = $labels->{$node_arg->{'normalized'}};
$ref->{'extra'}->{'label'} = $node_target;
- if (!$self->{'info'}->{'novalidate'}
+ if (!$parser_informations->{'novalidate'}
and !_check_node_same_texinfo_code($node_target, $node_arg)) {
$self->line_warn(sprintf(
__("\@%s to `%s', different from %s name `%s'"),
@@ -1583,9 +1591,12 @@ sub _sort_index_entries_in_letter($$)
return $res;
}
-sub setup_index_entry_keys_formatting($)
+sub setup_index_entry_keys_formatting($$$)
{
my $self = shift;
+ my $configuration_informations = shift;
+ my $parser_informations = shift;
+
my $ignore_chars = '';
# '-' must come first to avoid e.g. [<-@] looking like a character range
@@ -1599,13 +1610,16 @@ sub setup_index_entry_keys_formatting($)
if defined $self->{'values'}->{'txiindexatsignignore'};
my $options = {'sort_string' => 1,
- Texinfo::Common::_convert_text_options($self)};
-
- # FIXME really useful? Already set according to OUTPUT_ENCODING_NAME
- if ($self->get_conf('ENABLE_ENCODING')
- and $self->{'info'}->{'input_encoding_name'}
+
Texinfo::Common::_convert_text_options($configuration_informations)};
+
+ # FIXME really useful and not incorrect? Should be already set according
+ # to OUTPUT_ENCODING_NAME. May not be set because parser configuration
+ # is used instead of converter configuration, but this does not make
+ # it right to set the input encoding.
+ if ($configuration_informations->get_conf('ENABLE_ENCODING')
+ and $parser_informations->{'input_encoding_name'}
and not defined($options->{'enabled_encoding'})) {
- $options->{'enabled_encoding'} = $self->{'info'}->{'input_encoding_name'};
+ $options->{'enabled_encoding'} =
$parser_informations->{'input_encoding_name'};
}
return $options, $ignore_chars;
}
@@ -1643,12 +1657,15 @@ sub index_key($$$$;$)
# Go through all the index entries and set 'key', the sort key, on
# each one.
-sub do_index_keys($$)
+sub do_index_keys($$$$)
{
my $self = shift;
+ my $configuration_informations = shift;
+ my $parser_informations = shift;
my $index_names = shift;
- my ($options, $ignore_chars) = setup_index_entry_keys_formatting($self);
+ my ($options, $ignore_chars) = setup_index_entry_keys_formatting($self,
+ $configuration_informations, $parser_informations);
foreach my $index_name (keys(%$index_names)) {
foreach my $entry (@{$index_names->{$index_name}->{'index_entries'}}) {
@@ -1663,13 +1680,17 @@ sub do_index_keys($$)
}
}
-sub sort_indices($$$)
+sub sort_indices($$$$$)
{
my $self = shift;
+ my $configuration_informations = shift;
+ my $parser_informations = shift;
my $index_entries = shift;
my $index_names = shift;
+
my $sorted_index_entries;
- do_index_keys($self, $index_names);
+ do_index_keys($self, $configuration_informations, $parser_informations,
+ $index_names);
foreach my $index_name (keys(%$index_entries)) {
@{$sorted_index_entries->{$index_name}} =
sort _sort_index_entries
@@ -1678,13 +1699,17 @@ sub sort_indices($$$)
return $sorted_index_entries;
}
-sub sort_indices_by_letter($$$)
+sub sort_indices_by_letter($$$$$)
{
my $self = shift;
+ my $configuration_informations = shift;
+ my $parser_informations = shift;
my $index_entries = shift;
my $index_names = shift;
+
my $indices_sorted_by_letters;
- do_index_keys($self, $index_names);
+ do_index_keys($self, $configuration_informations, $parser_informations,
+ $index_names);
foreach my $index_name (keys(%$index_entries)) {
my $index_letter_hash;
foreach my $index_entry (@{$index_entries->{$index_name}}) {
@@ -1741,11 +1766,13 @@ Texinfo::Structuring - information on Texinfo::Parser
tree
elements_file_directions);
# $tree is a Texinfo document tree. $parser is a Texinfo::Parser object.
my $sections_root = sectioning_structure ($parser, $tree);
- my $nodes_list = $parser->nodes_list();
- my $labels = $parser->labels_information();
- set_menus_node_directions($parser, $nodes_list, $labels);
+ my ($labels, $targets_list, $nodes_list) = $parser->labels_information();
+ my $parser_informations = $parser->global_informations();
+ my $global_commands = $parser->global_commands_information();
+ set_menus_node_directions($parser, $parser, $parser_informations,
+ $global_commands, $nodes_list, $labels);
my $top_node = nodes_tree($parser, $nodes_list, $labels);
- complete_node_tree_with_menus($parser, $nodes_list, $top_node);
+ complete_node_tree_with_menus($parser, $parser, $nodes_list, $top_node);
my $refs = $parser->internal_references_information();
check_nodes_are_referenced($parser, $nodes_list, $top_node, $labels, $refs);
number_floats($parser->floats_information());
@@ -1757,7 +1784,7 @@ Texinfo::Structuring - information on Texinfo::Parser tree
$elements = split_by_section($tree);
}
split_pages($elements, $split);
- elements_directions($parser, $elements);
+ elements_directions($parser, $parser, $elements);
elements_file_directions($parser, $elements);
my $index_names = $parser->indices_information();
@@ -1765,11 +1792,11 @@ Texinfo::Structuring - information on Texinfo::Parser
tree
= merge_indices($index_names);
my $index_entries_sorted;
if ($sort_by_letter) {
- $index_entries_sorted = sort_indices_by_letter($parser,
+ $index_entries_sorted = sort_indices_by_letter($parser, $parser,
$parser_informations,
$merged_index_entries, $index_names);
} else {
- $index_entries_sorted = sort_indices($parser, $merged_index_entries,
- $index_names);
+ $index_entries_sorted = sort_indices($parser, $parser,
$parser_informations,
+ $merged_index_entries, $index_names);
}
@@ -1863,7 +1890,7 @@ account C<@part> elements.
=back
-=item set_menus_node_directions($parser, $nodes_list, $labels)
+=item set_menus_node_directions($parser, $configuration_informations,
$parser_informations, $global_commands, $nodes_list, $labels);
Goes through menu and set directions.
@@ -1904,7 +1931,7 @@ Up, next and previous directions for the node.
=back
-=item complete_node_tree_with_menus($parser, $nodes_list, $top_node)
+=item complete_node_tree_with_menus($parser, $configuration_informations,
$nodes_list, $top_node)
Complete nodes directions with menu directions. Check consistency
of menus, sectionning and nodes direction structures.
@@ -1927,9 +1954,11 @@ fourth of fifth argument) have an associated node,
anchor or float.
Set the I<label> key in the I<extra> hash of the reference tree
element to the associated labeled tree element.
-=item warn_non_empty_parts($parser)
+=item warn_non_empty_parts($parser, $global_commands)
-Register a warning in C<$parser> for each C<@part> that is not empty.
+Register a warning in C<$parser> for each C<@part> that is not empty
+in C<$global_commands> information (obtained by calling
+C<global_commands_information()> on a parser).
=item $elements = split_by_node($tree)
@@ -1999,7 +2028,7 @@ No splitting, only one page is returned, holding all the
elements.
=back
-=item elements_directions($parser, $elements)
+=item elements_directions($parser, $configuration_informations, $elements)
Directions are set up for the elements in the array reference given in
argument. The corresponding hash reference is in
@@ -2088,9 +2117,9 @@ The I<$merged_entries> returned is a hash reference whose
keys are the index names and values arrays of index entry structures
described in details in L<Texinfo::Parser/index_entries>.
-=item $index_entries_sorted = sort_indices_by_letter($parser,
$merged_index_entries, $index_names)
+=item $index_entries_sorted = sort_indices_by_letter($parser,
$configuration_informations, $parser_informations, $merged_index_entries,
$index_names)
-=item $index_entries_sorted = sort_indices($parser, $merged_index_entries,
$index_names)
+=item $index_entries_sorted = sort_indices($parser,
$configuration_informations, $parser_informations, $merged_index_entries,
$index_names)
These functions first sets a plain text key for each index entry, used for
sorting. In both cases, a hash reference with index names as keys is returned.
diff --git a/tp/init/chm.pm b/tp/init/chm.pm
index e6e236c..67a918e 100644
--- a/tp/init/chm.pm
+++ b/tp/init/chm.pm
@@ -235,7 +235,8 @@ sub chm_init($)
}
print $hhk_fh "</OBJECT>\n";
- my $index_entries = Texinfo::Structuring::sort_indices($self,
+ my $index_entries = Texinfo::Structuring::sort_indices($self, $self,
+ $self->{'parser_info'},
$self->{'index_entries'},
$self->{'index_names'});
if ($index_entries) {
diff --git a/tp/t/automatic_nodes.t b/tp/t/automatic_nodes.t
index 99e1efc..d368cfd 100644
--- a/tp/t/automatic_nodes.t
+++ b/tp/t/automatic_nodes.t
@@ -25,8 +25,10 @@ sub test_new_node($$$$)
my $parser = Texinfo::Parser::parser();
my $line = $parser->parse_texi_line ($in);
my ($labels, $targets_list, $nodes_list) = $parser->labels_information();
+ my $parser_informations = $parser->global_informations();
my $refs = $parser->internal_references_information();
- Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
+ Texinfo::Structuring::associate_internal_references($parser,
$parser_informations,
+ $labels, $refs);
# $labels, $nodes_list, $targets_list are modified
my $node = Texinfo::Transformations::_new_node($parser, $line,
$nodes_list, $targets_list, $labels);
@@ -35,7 +37,8 @@ sub test_new_node($$$$)
if (defined($node)) {
$texi_result = Texinfo::Convert::Texinfo::convert_to_texinfo($node);
my $refs = $parser->internal_references_information();
- Texinfo::Structuring::associate_internal_references($parser, $labels,
$refs);
+ Texinfo::Structuring::associate_internal_references($parser,
$parser_informations,
+ $labels, $refs);
$normalized = $node->{'extra'}->{'normalized'};
my @labels = sort(keys(%$labels));
if (scalar(@labels) != 1) {
@@ -75,8 +78,10 @@ my $tree = $parser->parse_texi_text('@node a node
');
my $line_tree = Texinfo::Parser::parse_texi_line (undef, 'a node');
my ($labels, $targets_list, $nodes_list) = $parser->labels_information();
+my $parser_informations = $parser->global_informations();
my $refs = $parser->internal_references_information();
-Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
+Texinfo::Structuring::associate_internal_references($parser,
$parser_informations,
+ $labels, $refs);
my $node = Texinfo::Transformations::_new_node($parser, $line_tree,
$nodes_list, $targets_list, $labels);
is ('@node a node 1
@@ -149,8 +154,10 @@ Text.
$parser = Texinfo::Parser::parser();
$tree = $parser->parse_texi_text ($sections_text);
($labels, $targets_list, $nodes_list) = $parser->labels_information();
+ $parser_informations = $parser->global_informations();
$refs = $parser->internal_references_information();
- Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
+ Texinfo::Structuring::associate_internal_references($parser,
$parser_informations,
+ $labels, $refs);
my ($new_content, $added_nodes)
= Texinfo::Transformations::insert_nodes_for_sectioning_commands($parser,
$tree, $nodes_list, $targets_list, $labels);
@@ -172,8 +179,10 @@ $tree = $parser->parse_texi_text ('@node Top
@end menu
');
($labels, $targets_list, $nodes_list) = $parser->labels_information();
+$parser_informations = $parser->global_informations();
$refs = $parser->internal_references_information();
-Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
+Texinfo::Structuring::associate_internal_references($parser,
$parser_informations,
+ $labels, $refs);
($new_content, $added_nodes)
= Texinfo::Transformations::insert_nodes_for_sectioning_commands($parser,
$tree, $nodes_list, $targets_list, $labels);
diff --git a/tp/t/do_master_menu.t b/tp/t/do_master_menu.t
index a8ecc05..3b3e576 100644
--- a/tp/t/do_master_menu.t
+++ b/tp/t/do_master_menu.t
@@ -124,8 +124,10 @@ my $no_detailmenu = _get_in('');
my $parser = Texinfo::Parser::parser();
my $tree = $parser->parse_texi_text($in_detailmenu);
my ($labels, $targets_list, $nodes_list) = $parser->labels_information();
+my $parser_informations = $parser->global_informations();
my $refs = $parser->internal_references_information();
-Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
+Texinfo::Structuring::associate_internal_references($parser,
$parser_informations,
+ $labels, $refs);
my $master_menu = Texinfo::Transformations::new_master_menu($parser, $labels);
my $out = Texinfo::Convert::Texinfo::convert_to_texinfo($master_menu);
@@ -166,8 +168,10 @@ is ($out, $reference, 'master menu');
$parser = Texinfo::Parser::parser();
$tree = $parser->parse_texi_text($no_detailmenu);
($labels, $targets_list, $nodes_list) = $parser->labels_information();
+$parser_informations = $parser->global_informations();
$refs = $parser->internal_references_information();
-Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
+Texinfo::Structuring::associate_internal_references($parser,
$parser_informations,
+ $labels, $refs);
$master_menu = Texinfo::Transformations::new_master_menu($parser, $labels);
$out = Texinfo::Convert::Texinfo::convert_to_texinfo($master_menu);
is ($out, $reference, 'master menu no detailmenu');
@@ -175,8 +179,10 @@ is ($out, $reference, 'master menu no detailmenu');
$parser = Texinfo::Parser::parser();
$tree = $parser->parse_texi_text($in_detailmenu);
($labels, $targets_list, $nodes_list) = $parser->labels_information();
+$parser_informations = $parser->global_informations();
$refs = $parser->internal_references_information();
-Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
+Texinfo::Structuring::associate_internal_references($parser,
$parser_informations,
+ $labels, $refs);
Texinfo::Transformations::regenerate_master_menu($parser, $labels);
$out = Texinfo::Convert::Texinfo::convert_to_texinfo($tree);
@@ -187,8 +193,10 @@ is ($out, _get_in($reference), 'regenerate with existing
detailmenu');
$parser = Texinfo::Parser::parser();
$tree = $parser->parse_texi_text($no_detailmenu);
($labels, $targets_list, $nodes_list) = $parser->labels_information();
+$parser_informations = $parser->global_informations();
$refs = $parser->internal_references_information();
-Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
+Texinfo::Structuring::associate_internal_references($parser,
$parser_informations,
+ $labels, $refs);
Texinfo::Transformations::regenerate_master_menu($parser, $labels);
$out = Texinfo::Convert::Texinfo::convert_to_texinfo($tree);
diff --git a/tp/t/results/indices/def_syn_indices.pl
b/tp/t/results/indices/def_syn_indices.pl
index d44609d..7778f73 100644
--- a/tp/t/results/indices/def_syn_indices.pl
+++ b/tp/t/results/indices/def_syn_indices.pl
@@ -487,7 +487,7 @@ $result_trees{'def_syn_indices'} = {
'index_at_command' => 'codeidxindex',
'index_name' => 'codeidx',
'index_type_command' => 'codeidxindex',
- 'key' => "a index entry t\x{1ebd} \x{ee}",
+ 'key' => 'a index entry te~ i^',
'node' => {},
'number' => 1
},
diff --git a/tp/t/results/indices/ftable_vtable.pl
b/tp/t/results/indices/ftable_vtable.pl
index 5cc2dc6..8d59363 100644
--- a/tp/t/results/indices/ftable_vtable.pl
+++ b/tp/t/results/indices/ftable_vtable.pl
@@ -354,7 +354,7 @@ $result_trees{'ftable_vtable'} = {
'index_at_command' => 'item',
'index_name' => 'vr',
'index_type_command' => 'vtable',
- 'key' => 'var1 error-->',
+ 'key' => 'var1 error->',
'node' => {},
'number' => 1
},
diff --git a/tp/t/test_sort.t b/tp/t/test_sort.t
index 5a49e2b..7c7a63a 100644
--- a/tp/t/test_sort.t
+++ b/tp/t/test_sort.t
@@ -43,8 +43,10 @@ $tree = $parser->parse_texi_text('@node Top
my ($index_names, $merged_indices) =
$parser->indices_information();
my $index_entries = Texinfo::Structuring::merge_indices($index_names);
+my $parser_informations = $parser->global_informations();
my $sorted_index_entries
- = Texinfo::Structuring::sort_indices($parser, $index_entries, $index_names);
+ = Texinfo::Structuring::sort_indices($parser, $parser, $parser_informations,
+ $index_entries, $index_names);
my @entries = ();
foreach my $entry (@{$sorted_index_entries->{'cp'}}) {
@@ -59,8 +61,8 @@ my @entries_ref = ('!', '"', 'aaaaaaaaaaaa', 'e', 'E', 'ł',
'ẽ');
cmp_deeply (\@entries, \@entries_ref, 'sorted index entries');
my $sorted_index_entries_by_letter
- = Texinfo::Structuring::sort_indices_by_letter($parser, $index_entries,
- $index_names);
+ = Texinfo::Structuring::sort_indices_by_letter($parser, $parser,
$parser_informations,
+ $index_entries, $index_names);
my @letter_entries_ref = (
{'!' => [ '!' ]},
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index ceca263..aab794a 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -324,6 +324,8 @@ package Texinfo::Config;
#use Carp;
+
+
# passed from main program through _load_config
my $cmdline_options;
my $default_options;
@@ -1300,14 +1302,17 @@ while(@input_files) {
}
my $refs = $parser->internal_references_information();
- Texinfo::Structuring::associate_internal_references($parser, $labels, $refs);
+ my $parser_informations = $parser->global_informations();
+ Texinfo::Structuring::associate_internal_references($parser,
+ $parser_informations, $labels, $refs);
# every format needs the sectioning structure
my $structure = Texinfo::Structuring::sectioning_structure($parser, $tree);
+ my $global_commands = $parser->global_commands_information();
if ($structure
and !$formats_table{$format}->{'no_warn_non_empty_parts'}) {
- Texinfo::Structuring::warn_non_empty_parts($parser);
+ Texinfo::Structuring::warn_non_empty_parts($parser, $global_commands);
}
if ($tree_transformations{'complete_tree_nodes_menus'}) {
@@ -1333,13 +1338,15 @@ while(@input_files) {
# for instance if format is structure.
if (not defined($parser_options->{'FORMAT_MENU'})
or $parser_options->{'FORMAT_MENU'} eq 'menu') {
- Texinfo::Structuring::set_menus_node_directions($parser, $nodes_list,
$labels);
+ Texinfo::Structuring::set_menus_node_directions($parser, $parser,
+ $parser_informations, $global_commands, $nodes_list, $labels);
}
- $top_node = Texinfo::Structuring::nodes_tree($parser, $nodes_list,
$labels);
+ $top_node = Texinfo::Structuring::nodes_tree($parser, $parser_informations,
+ $nodes_list,
$labels);
if (not defined($parser_options->{'FORMAT_MENU'})
or $parser_options->{'FORMAT_MENU'} eq 'menu') {
if (defined($nodes_list)) {
- Texinfo::Structuring::complete_node_tree_with_menus($parser,
+ Texinfo::Structuring::complete_node_tree_with_menus($parser, $parser,
$nodes_list, $top_node);
Texinfo::Structuring::check_nodes_are_referenced($parser,
$nodes_list, $top_node,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Convert/Converter.pm (converter), tp/Texinfo/Convert/HTML.pm (_load_htmlxref_files, output), tp/Texinfo/Convert/IXIN.pm (output_ixin), tp/Texinfo/Convert/Info.pm (output, _info_header), tp/Texinfo/Convert/Text.pm (converter, output): rename 'info' as 'parser_info' in converter.,
Patrice Dumas <=
- Prev by Date:
branch master updated: * Pod-Simple-Texinfo/pod2texi.pl (_fix_texinfo_tree) tp/texi2any.pl, tp/Texinfo/Common.pm (register_label, set_nodes_list_labels), tp/Texinfo/ParserNonXS.pm (labels_information, _register_label) (_end_line, _parse_texi), tp/Texinfo/XS/parsetexi/Parsetexi.pm (_complete_node_menus) (get_parser_info, parse_texi_line, labels_information) tp/Texinfo/Structuring.pm (_check_menu_entry) (_check_referenced_nodes, check_nodes_are_referenced) (set_menus_node_directions, complete_node_tree_with_menus) [...]
- Next by Date:
branch master updated: test file missed in previous commit.
- Previous by thread:
branch master updated: * Pod-Simple-Texinfo/pod2texi.pl (_fix_texinfo_tree) tp/texi2any.pl, tp/Texinfo/Common.pm (register_label, set_nodes_list_labels), tp/Texinfo/ParserNonXS.pm (labels_information, _register_label) (_end_line, _parse_texi), tp/Texinfo/XS/parsetexi/Parsetexi.pm (_complete_node_menus) (get_parser_info, parse_texi_line, labels_information) tp/Texinfo/Structuring.pm (_check_menu_entry) (_check_referenced_nodes, check_nodes_are_referenced) (set_menus_node_directions, complete_node_tree_with_menus) [...]
- Next by thread:
branch master updated: test file missed in previous commit.
- Index(es):