[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Config.pm (GNUT_get_stage_handlers),
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Config.pm (GNUT_get_stage_handlers), tp/Texinfo/Convert/HTML.pm (run_stage_handlers, output): sort handlers according to priority in GNUT_get_stage_handlers and return sorted stage handlers. Pass sorted handlers to run_stage_handlers. Call Texinfo::Config::GNUT_get_stage_handlers() in output(). |
Date: |
Mon, 29 Apr 2024 09:39:38 -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 a2310174eb * tp/Texinfo/Config.pm (GNUT_get_stage_handlers),
tp/Texinfo/Convert/HTML.pm (run_stage_handlers, output): sort handlers
according to priority in GNUT_get_stage_handlers and return sorted stage
handlers. Pass sorted handlers to run_stage_handlers. Call
Texinfo::Config::GNUT_get_stage_handlers() in output().
a2310174eb is described below
commit a2310174eb27328e58e7d32420e93b8786c408a7
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Apr 29 15:39:28 2024 +0200
* tp/Texinfo/Config.pm (GNUT_get_stage_handlers),
tp/Texinfo/Convert/HTML.pm (run_stage_handlers, output): sort handlers
according to priority in GNUT_get_stage_handlers and return sorted
stage handlers. Pass sorted handlers to run_stage_handlers. Call
Texinfo::Config::GNUT_get_stage_handlers() in output().
---
ChangeLog | 10 +++++++-
tp/Texinfo/Config.pm | 16 ++++++++++--
tp/Texinfo/Convert/HTML.pm | 64 +++++++++++++++++++++++++---------------------
3 files changed, 58 insertions(+), 32 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6869861e96..2f94061022 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-04-29 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Config.pm (GNUT_get_stage_handlers),
+ tp/Texinfo/Convert/HTML.pm (run_stage_handlers, output): sort handlers
+ according to priority in GNUT_get_stage_handlers and return sorted
+ stage handlers. Pass sorted handlers to run_stage_handlers. Call
+ Texinfo::Config::GNUT_get_stage_handlers() in output().
+
2024-04-27 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm (_handle_other_command),
@@ -35,7 +43,7 @@
* tp/Texinfo/ParserNonXS.pm (%in_full_text_commands)
(%in_basic_inline_commands): do not put in_heading_spec_commands in
%in_full_text_commands, only in %in_basic_inline_commands such that
- they can only appear in selecter @-commands (style brace @-commands).
+ they can only appear in some @-commands (style brace @-commands).
* tp/Texinfo/XS/parsetexi/parser.c (check_valid_nesting): remove an
impossible check of outer_flags & CF_heading_spec for a brace command.
diff --git a/tp/Texinfo/Config.pm b/tp/Texinfo/Config.pm
index 6c03691b27..3b3f43b1e5 100644
--- a/tp/Texinfo/Config.pm
+++ b/tp/Texinfo/Config.pm
@@ -429,10 +429,22 @@ sub texinfo_register_handler($$;$)
return 1;
}
-# called from the Converter
+# called from the Converter. Sort according to priority and return sorted
+# handlers by stage. (Return actually handler and priority pairs in case the
+# priority name information is interesting).
sub GNUT_get_stage_handlers()
{
- return $GNUT_stage_handlers;
+ my %sorted_stage_handlers;
+ foreach my $stage (keys(%$GNUT_stage_handlers)) {
+ $sorted_stage_handlers{$stage} = [];
+ my @sorted_priorities = sort keys(%{$GNUT_stage_handlers->{$stage}});
+ foreach my $priority (@sorted_priorities) {
+ foreach my $handler (@{$GNUT_stage_handlers->{$stage}->{$priority}}) {
+ push @{$sorted_stage_handlers{$stage}}, [$handler, $priority];
+ }
+ }
+ }
+ return \%sorted_stage_handlers;
}
#####################################################################
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 036e643eda..7acd101632 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -9069,7 +9069,8 @@ sub converter_initialize($)
my $type =
$self->{'translated_special_unit_info'}->{$tree_type}->[0];
my $variety_strings
= $self->{'translated_special_unit_info'}->{$tree_type}->[1];
- # we do not need both tree type and string type to pass to XS,
+ # we do not need both tree type $tree_type and $type string
+ # to pass to XS, as they both hold the same information,
# pass only the string type $type and associated varieties
information
$self->{'simplified_special_unit_info'}->{$type} = $variety_strings;
}
@@ -12302,40 +12303,38 @@ sub output_internal_links($)
}
}
-sub run_stage_handlers($$$)
+sub run_stage_handlers($$$$)
{
my $converter = shift;
+ my $stage_handlers = shift;
my $document = shift;
my $stage = shift;
- my $stage_handlers = Texinfo::Config::GNUT_get_stage_handlers();
return 0 if (!defined($stage_handlers->{$stage}));
- my @sorted_priorities = sort keys(%{$stage_handlers->{$stage}});
- foreach my $priority (@sorted_priorities) {
- my $handler_idx = 1;
- foreach my $handler (@{$stage_handlers->{$stage}->{$priority}}) {
- if ($converter->get_conf('DEBUG')) {
- print STDERR "RUN handler $handler_idx: stage $stage, priority
$priority\n";
- }
- my $status = &{$handler}($converter, $document, $stage);
- if ($status != 0) {
- if ($status < 0) {
- $converter->converter_document_error(
- sprintf(__("handler %d of stage %s priority %s failed"),
- $handler_idx, $stage, $priority));
- } else {
- # the handler is supposed to have output an error message
- # already if $status > 0
- if ($converter->get_conf('VERBOSE') or
$converter->get_conf('DEBUG')) {
- print STDERR "FAIL handler $handler_idx: stage $stage, "
- ."priority $priority\n";
- }
+ my $handler_idx = 1;
+ foreach my $handler_and_priority (@{$stage_handlers->{$stage}}) {
+ my ($handler, $priority) = @$handler_and_priority;
+ if ($converter->get_conf('DEBUG')) {
+ print STDERR "RUN handler $handler_idx: stage $stage, priority
$priority\n";
+ }
+ my $status = &{$handler}($converter, $document, $stage);
+ if ($status != 0) {
+ if ($status < 0) {
+ $converter->converter_document_error(
+ sprintf(__("handler %d of stage %s priority %s failed"),
+ $handler_idx, $stage, $priority));
+ } else {
+ # the handler is supposed to have output an error message
+ # already if $status > 0
+ if ($converter->get_conf('VERBOSE') or $converter->get_conf('DEBUG')) {
+ print STDERR "FAIL handler $handler_idx: stage $stage, "
+ ."priority $priority\n";
}
- return $status;
}
- $handler_idx++;
+ return $status;
}
+ $handler_idx++;
}
return 0;
}
@@ -12920,7 +12919,11 @@ sub output($$)
# Some information is not available yet.
$self->_reset_info();
- my $setup_status = $self->run_stage_handlers($document, 'setup');
+ # TODO call in converter_initialize
+ my $stage_handlers = Texinfo::Config::GNUT_get_stage_handlers();
+
+ my $setup_status = $self->run_stage_handlers($stage_handlers,
+ $document, 'setup');
unless ($setup_status < $handler_fatal_error_level
and $setup_status > -$handler_fatal_error_level) {
$self->conversion_finalization();
@@ -13026,7 +13029,8 @@ sub output($$)
# formatting. Some information is not available yet.
$self->_reset_info();
- my $structure_status = $self->run_stage_handlers($document, 'structure');
+ my $structure_status = $self->run_stage_handlers($stage_handlers,
+ $document, 'structure');
unless ($structure_status < $handler_fatal_error_level
and $structure_status > -$handler_fatal_error_level) {
$self->conversion_finalization();
@@ -13051,7 +13055,8 @@ sub output($$)
# TODO document that this stage handler is called with end of preamble
# documentlanguage when it is certain that this will not change ever.
- my $init_status = $self->run_stage_handlers($document, 'init');
+ my $init_status = $self->run_stage_handlers($stage_handlers,
+ $document, 'init');
unless ($init_status < $handler_fatal_error_level
and $init_status > -$handler_fatal_error_level) {
$self->conversion_finalization();
@@ -13096,7 +13101,8 @@ sub output($$)
$self->_do_js_files($destination_directory);
- my $finish_status = $self->run_stage_handlers($document, 'finish');
+ my $finish_status = $self->run_stage_handlers($stage_handlers,
+ $document, 'finish');
unless ($finish_status < $handler_fatal_error_level
and $finish_status > -$handler_fatal_error_level) {
$self->conversion_finalization();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Config.pm (GNUT_get_stage_handlers), tp/Texinfo/Convert/HTML.pm (run_stage_handlers, output): sort handlers according to priority in GNUT_get_stage_handlers and return sorted stage handlers. Pass sorted handlers to run_stage_handlers. Call Texinfo::Config::GNUT_get_stage_handlers() in output().,
Patrice Dumas <=