[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/Converter.pm (_in_preamble)
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Convert/Converter.pm (_in_preamble) (set_global_document_commands) tp/Texinfo/Convert/HTML.pm (_prepare_conversion_tree_units, output), tp/Texinfo/Convert/Info.pm (_info_header): modify set_global_document_commands() to take for commands location argument 'before', 'last', 'preamble' or 'preamble_or_first' taking into account the preamble appropriately. |
Date: |
Sat, 08 Jan 2022 12:22:24 -0500 |
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 5bc4c21868 * tp/Texinfo/Convert/Converter.pm (_in_preamble)
(set_global_document_commands) tp/Texinfo/Convert/HTML.pm
(_prepare_conversion_tree_units, output), tp/Texinfo/Convert/Info.pm
(_info_header): modify set_global_document_commands() to take for commands
location argument 'before', 'last', 'preamble' or 'preamble_or_first' taking
into account the preamble appropriately.
5bc4c21868 is described below
commit 5bc4c2186845e1df5e266b566d1f8486c1bd4a8e
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Jan 8 18:22:14 2022 +0100
* tp/Texinfo/Convert/Converter.pm (_in_preamble)
(set_global_document_commands)
tp/Texinfo/Convert/HTML.pm (_prepare_conversion_tree_units, output),
tp/Texinfo/Convert/Info.pm (_info_header): modify
set_global_document_commands() to take for commands location
argument 'before', 'last', 'preamble' or 'preamble_or_first'
taking into account the preamble appropriately.
---
ChangeLog | 10 ++++++
tp/Texinfo/Convert/Converter.pm | 71 ++++++++++++++++++++++++++++++-----------
tp/Texinfo/Convert/HTML.pm | 18 ++++-------
tp/Texinfo/Convert/Info.pm | 10 +++---
4 files changed, 74 insertions(+), 35 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 48af82bb9f..807499b4fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2022-01-08 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/Converter.pm (_in_preamble)
+ (set_global_document_commands)
+ tp/Texinfo/Convert/HTML.pm (_prepare_conversion_tree_units, output),
+ tp/Texinfo/Convert/Info.pm (_info_header): modify
+ set_global_document_commands() to take for commands location
+ argument 'before', 'last', 'preamble' or 'preamble_or_first'
+ taking into account the preamble appropriately.
+
2022-01-08 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/HTML.pm (register_file_information)
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index a1f63a589e..22222e19d2 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -258,11 +258,28 @@ sub _command_init($$)
}
}
-# $COMMANDS_LOCATION is 0, 1 or -1.
-# 0 means setting to the values before the document commands
+sub _in_preamble($)
+{
+ my $element = shift;
+ my $current_element = $element;
+ while ($current_element->{'parent'}) {
+ if (defined($current_element->{'parent'}->{'type'})
+ and $current_element->{'parent'}->{'type'} eq
'preamble_before_content') {
+ return 1;
+ }
+ $current_element = $current_element->{'parent'};
+ }
+ return 0;
+}
+
+# $COMMANDS_LOCATION is 'before', 'last', 'preamble' or 'preamble_or_first'
+# 'before' means setting to the values before the document commands
# (default and command-line).
-# 1 means setting to the first value for the command in the document
-# -1 means setting to the last value for the command in the document.
+# 'preamble' means setting sequentially to the values in the preamble.
+# 'first_or_preamble' means setting to the first value for the command
+# in the document if the first command is not in the preamble, else set
+# sequentially to the values in the preamble.
+# 'last' means setting to the last value for the command in the document.
#
# For unique command, the last may be considered to be the same as the first.
#
@@ -289,34 +306,52 @@ sub set_global_document_commands($$;$)
if (not defined($selected_commands)) {
$selected_commands =
[keys(%Texinfo::Common::document_settable_at_commands)];
}
- if ($commands_location == 0) {
+ if ($commands_location eq 'before') {
foreach my $global_command (@{$selected_commands}) {
# for commands not appearing in the document, this should set the
# same value, the converter initialization value
$self->set_conf($global_command, _command_init($global_command,
$init_conf));
}
} else {
+ if ($commands_location ne 'last' and $commands_location ne
'preamble_or_first'
+ and $commands_location ne 'preamble') {
+ warn "BUG: set_global_document_commands: unknown commands_location:
$commands_location";
+ }
foreach my $global_command (@{$selected_commands}) {
my $element;
+ if ($self->get_conf('DEBUG')) {
+ print STDERR "SET_global_multiple_commands($commands_location)
$global_command\n";
+ }
if (defined($self->{'global_commands'}->{$global_command})
and ref($self->{'global_commands'}->{$global_command}) eq 'ARRAY') {
- # used when $commands_location == 1
- my $index_in_global_commands = 0;
- if ($commands_location < 0) {
- $index_in_global_commands = -1;
+ if ($commands_location eq 'last')
+ {
+ $element =
+ $self->{'global_commands'}->{$global_command}->[-1];
+ $self->set_informative_command_value($element);
+ } else {
+ if ($commands_location eq 'preamble_or_first'
+ and not
_in_preamble($self->{'global_commands'}->{$global_command}->[0])) {
+ $element =
+ $self->{'global_commands'}->{$global_command}->[0];
+ $self->set_informative_command_value($element);
+ } else {
+ foreach my $command_element
(@{$self->{'global_commands'}->{$global_command}}) {
+ if (_in_preamble($command_element)) {
+ $element = $command_element;
+ $self->set_informative_command_value($element);
+ } else {
+ last;
+ }
+ }
+ }
}
- $element =
-
$self->{'global_commands'}->{$global_command}->[$index_in_global_commands];
} elsif (defined($self->{'global_commands'}->{$global_command})) {
- # unique command, first and last are the same
+ # unique command, first, preamble and last are the same
$element = $self->{'global_commands'}->{$global_command};
- }
- if ($self->get_conf('DEBUG')) {
- print STDERR "SET_global_multiple_commands($commands_location)
$global_command\n";
- }
- if (defined($element)) {
$self->set_informative_command_value($element);
- } else {
+ }
+ if (not defined($element)) {
# commands not appearing in the document, this should set the
# same value, the converter initialization value
$self->set_conf($global_command, _command_init($global_command,
$init_conf));
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index f6c1e0fba2..56707dfb6b 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -6966,19 +6966,19 @@ sub _prepare_conversion_tree_units($$$$)
# places, set it once for all here
my @contents_elements_options = grep {Texinfo::Common::valid_option($_)}
keys(%contents_command_element_type);
- $self->set_global_document_commands(-1, \@contents_elements_options);
+ $self->set_global_document_commands('last', \@contents_elements_options);
# configuration used to determine if a special element is to be done
# (in addition to contents)
my @conf_for_special_elements = ('footnotestyle');
- $self->set_global_document_commands(-1, \@conf_for_special_elements);
+ $self->set_global_document_commands('last', \@conf_for_special_elements);
# Do that before the other elements, to be sure that special page ids
# are registered before elements id are.
my $special_elements
= $self->_prepare_special_elements($tree_units, $destination_directory,
$document_name);
# reset to the default
- $self->set_global_document_commands(0, \@conf_for_special_elements);
+ $self->set_global_document_commands('before', \@conf_for_special_elements);
#if ($tree_units) {
# foreach my $element(@{$tree_units}) {
@@ -8517,17 +8517,13 @@ sub output($$)
my $structure_status = $self->run_stage_handlers($root, 'structure');
return undef unless($structure_status);
- # FIXME there is no good choice here. The language may be
- # set later on, it is wrong to use it from the beginning.
- # Best that can be done for now. Wait for Gavin answer on
- # a more explicit header for Texinfo files that would be
- # taken into account for that kind of global documents variables
- # setting
- $self->set_global_document_commands(1, ['documentlanguage']);
+ $self->set_global_document_commands('preamble_or_first',
['documentlanguage']);
$self->set_conf('BODYTEXT',
'lang="' . $self->get_conf('documentlanguage') . '"');
+ # FIXME here reset to preamble only, but need to change tests
+ #$self->set_global_document_commands('preamble', ['documentlanguage']);
# prepare title. fulltitle uses more possibility than simpletitle for
# title, including @-commands found in @titlepage only. Therefore
# simpletitle is more in line with what makeinfo in C does.
@@ -8593,7 +8589,7 @@ sub output($$)
= &{$self->{'format_comment'}}($self, $copying_comment);
}
}
- $self->set_global_document_commands(0, ['documentlanguage']);
+ $self->set_global_document_commands('before', ['documentlanguage']);
# documentdescription
if (defined($self->get_conf('documentdescription'))) {
diff --git a/tp/Texinfo/Convert/Info.pm b/tp/Texinfo/Convert/Info.pm
index aada0de132..f9f5ee7f86 100644
--- a/tp/Texinfo/Convert/Info.pm
+++ b/tp/Texinfo/Convert/Info.pm
@@ -338,12 +338,10 @@ sub _info_header($$$)
$result .= "\n";
$self->{'empty_lines_count'} = 1;
- # format @copying using the first value set for global
- # commands in the document. It may not correspond to the
- # intent of the author if the global commands appears late
- # in the document. However this is the best guess we can do.
+ # format @copying using the last value of the preamble.
my @informative_global_commands = $self->get_informative_global_commands();
- $self->set_global_document_commands(1, \@informative_global_commands);
+ # FIXME use 'preamble' instead, but need to fix tests
+ $self->set_global_document_commands('preamble_or_first',
\@informative_global_commands);
if ($self->{'global_commands'} and $self->{'global_commands'}->{'copying'}) {
print STDERR "COPYING HEADER\n" if ($self->get_conf('DEBUG'));
$self->{'in_copying_header'} = 1;
@@ -353,7 +351,7 @@ sub _info_header($$$)
$result .= $self->process_footnotes();
delete $self->{'in_copying_header'};
}
- $self->set_global_document_commands(0, \@informative_global_commands);
+ $self->set_global_document_commands('before', \@informative_global_commands);
if ($self->{'parser_info'}->{'dircategory_direntry'}) {
$self->{'ignored_commands'}->{'direntry'} = 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Convert/Converter.pm (_in_preamble) (set_global_document_commands) tp/Texinfo/Convert/HTML.pm (_prepare_conversion_tree_units, output), tp/Texinfo/Convert/Info.pm (_info_header): modify set_global_document_commands() to take for commands location argument 'before', 'last', 'preamble' or 'preamble_or_first' taking into account the preamble appropriately.,
Patrice Dumas <=