texinfo-commits
[Top][All Lists]
Advanced

[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) (GNUT_get_formatting_references, GNUT_get_commands_conversion) (GNUT_get_types_conversion), tp/Texinfo/Convert/HTML.pm: use a proper interface between Texinfo::Config and Texinfo::Convert::HTML for handlers.
Date: Wed, 01 Sep 2021 06:27:13 -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 6e27e61  * tp/Texinfo/Config.pm (GNUT_get_stage_handlers) 
(GNUT_get_formatting_references, GNUT_get_commands_conversion) 
(GNUT_get_types_conversion), tp/Texinfo/Convert/HTML.pm: use a proper interface 
between Texinfo::Config and Texinfo::Convert::HTML for handlers.
6e27e61 is described below

commit 6e27e6190014f99eec3e53c1236bcebeec0658ea
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Sep 1 12:27:05 2021 +0200

    * tp/Texinfo/Config.pm (GNUT_get_stage_handlers)
    (GNUT_get_formatting_references, GNUT_get_commands_conversion)
    (GNUT_get_types_conversion), tp/Texinfo/Convert/HTML.pm:
    use a proper interface between Texinfo::Config and
    Texinfo::Convert::HTML for handlers.
---
 ChangeLog                  |  8 ++++++++
 tp/Texinfo/Config.pm       | 51 +++++++++++++++++++++++++++++++++++++---------
 tp/Texinfo/Convert/HTML.pm | 29 ++++++++++++++------------
 3 files changed, 65 insertions(+), 23 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 171957f..4a16c10 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2021-09-01  Patrice Dumas  <pertusus@free.fr>
 
+       * tp/Texinfo/Config.pm (GNUT_get_stage_handlers)
+       (GNUT_get_formatting_references, GNUT_get_commands_conversion)
+       (GNUT_get_types_conversion), tp/Texinfo/Convert/HTML.pm:
+       use a proper interface between Texinfo::Config and
+       Texinfo::Convert::HTML for handlers.
+
+2021-09-01  Patrice Dumas  <pertusus@free.fr>
+
        * tp/Texinfo/Config.pm, texi2any.pl, tp/init/*.pm, tp/t/init/*.init: 
        rename _load_init_file as GNUT_load_init_file,
        _load_config as GNUT_load_config, set_from_init_file as
diff --git a/tp/Texinfo/Config.pm b/tp/Texinfo/Config.pm
index 03d3dda..d4f2bf4 100644
--- a/tp/Texinfo/Config.pm
+++ b/tp/Texinfo/Config.pm
@@ -67,7 +67,7 @@ sub texinfo_set_from_init_file($$) {
     # carp may be better, but infortunately, it points to the routine that 
     # loads the file, and not to the init file.
     main::document_warn(sprintf(__("%s: unknown variable %s"),
-                                'set_from_init_file', $var));
+                                'texinfo_set_from_init_file', $var));
     return 0;
   }
   return 0 if (defined($cmdline_options->{$var}));
@@ -84,7 +84,7 @@ sub GNUT_set_from_cmdline($$) {
   delete $default_options->{$var};
   if (!Texinfo::Common::valid_option($var)) {
     main::document_warn(sprintf(main::__("%s: unknown variable %s\n"),
-                                'set_from_cmdline', $var));
+                                'GNUT_set_from_cmdline', $var));
     return 0;
   }
   $cmdline_options->{$var} = $value;
@@ -131,13 +131,18 @@ foreach my $stage (@possible_stages) {
 
 my $default_priority = 'default';
 
-# Note that these variables are available for the Texinfo modules
-# but, in general should not be accessed directly by the users who
+# Thes variables should not be accessed directly by the users who
 # customize formatting and should use the associated functions,
 # such as texinfo_register_handler(), texinfo_register_formatting_function(),
 # texinfo_register_command_formatting() or texinfo_register_type_formatting().
-use vars qw(%texinfo_default_stage_handlers %texinfo_formatting_references
-            %texinfo_commands_conversion %texinfo_types_conversion);
+#
+# FIXME add another level with format?  Not needed now as HTML is
+# the only customizable format for now.
+my $GNUT_stage_handlers = {};
+my $GNUT_formatting_references = {};
+my $GNUT_commands_conversion = {};
+my $GNUT_types_conversion = {};
+
 
 sub texinfo_register_handler($$;$)
 {
@@ -150,10 +155,17 @@ sub texinfo_register_handler($$;$)
     return 0;
   }
   $priority = $default_priority if (!defined($priority));
-  push @{$texinfo_default_stage_handlers{$stage}->{$priority}}, $handler;
+  push @{$GNUT_stage_handlers->{$stage}->{$priority}}, $handler;
   return 1;
 }
 
+# called from the Converter
+sub GNUT_get_stage_handlers()
+{
+  return $GNUT_stage_handlers;
+}
+
+# called from init files
 sub texinfo_register_formatting_function($$)
 {
   my $thing = shift;
@@ -162,23 +174,42 @@ sub texinfo_register_formatting_function($$)
     carp ("Unknown formatting type $thing\n");
     return 0;
   }
-  $texinfo_formatting_references{$thing} = $handler;
+  $GNUT_formatting_references->{$thing} = $handler;
 }
 
+# called from the Converter
+sub GNUT_get_formatting_references()
+{
+  return $GNUT_formatting_references;
+}
+
+# called from init files
 sub texinfo_register_command_formatting($$)
 {
   my $command = shift;
   my $reference = shift;
-  $texinfo_commands_conversion{$command} = $reference;
+  $GNUT_commands_conversion->{$command} = $reference;
+}
+
+# called from the Converter
+sub GNUT_get_commands_conversion()
+{
+  return $GNUT_commands_conversion;
 }
 
+# called from init files
 sub texinfo_register_type_formatting($$)
 {
   my $command = shift;
   my $reference = shift;
-  $texinfo_types_conversion{$command} = $reference;
+  $GNUT_types_conversion->{$command} = $reference;
 }
 
+# called from the Converter
+sub GNUT_get_types_conversion()
+{
+  return $GNUT_types_conversion;
+}
 
 
 1;
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 682dc2a..96bc1ba 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -3922,8 +3922,8 @@ foreach my $small_command (keys(%small_alias)) {
 }
 
 # Keys are tree element types, values are function references to convert
-# elements of that type.  Can be overridden with
-# Texinfo::Config::texinfo_types_conversion, setup by
+# elements of that type.  Can be overridden accessing
+# Texinfo::Config::GNUT_get_types_conversion, setup by
 # Texinfo::Config::texinfo_register_type_formatting()
 my %default_types_conversion;
 
@@ -5137,9 +5137,10 @@ sub converter_initialize($)
   _load_htmlxref_files($self);
 
   foreach my $type (keys(%default_types_conversion)) {
-    if (exists($Texinfo::Config::texinfo_types_conversion{$type})) {
+    my $customized_types_conversion = 
Texinfo::Config::GNUT_get_types_conversion();
+    if (exists($customized_types_conversion->{$type})) {
       $self->{'types_conversion'}->{$type}
-          = $Texinfo::Config::texinfo_types_conversion{$type};
+          = $customized_types_conversion->{$type};
     } else {
       $self->{'types_conversion'}->{$type} 
           = $default_types_conversion{$type};
@@ -5159,9 +5160,11 @@ sub converter_initialize($)
   # FIXME put value in a category in Texinfo::Common?
   foreach my $command (keys(%misc_commands), keys(%brace_commands),
      keys (%block_commands), keys(%no_brace_commands), 'value') {
-    if (exists($Texinfo::Config::texinfo_commands_conversion{$command})) {
+    my $customized_commands_conversion
+        = Texinfo::Config::GNUT_get_commands_conversion();
+    if (exists($customized_commands_conversion->{$command})) {
       $self->{'commands_conversion'}->{$command} 
-          = $Texinfo::Config::texinfo_commands_conversion{$command};
+          = $customized_commands_conversion->{$command};
     } else {
       if ($self->get_conf('FORMAT_MENU') ne 'menu'
            and ($command eq 'menu' or $command eq 'detailmenu')) {
@@ -5245,9 +5248,10 @@ sub converter_initialize($)
   foreach my $formatting_reference (keys(%default_formatting_references)) {
     $self->{'default_formatting_functions'}->{$formatting_reference}
        = $default_formatting_references{$formatting_reference};
-    if 
(defined($Texinfo::Config::texinfo_formatting_references{$formatting_reference}))
 {
+    my $customized_formatting_references = 
Texinfo::Config::GNUT_get_formatting_references();
+    if (defined($customized_formatting_references->{$formatting_reference})) {
       $self->{$formatting_reference} 
-       =  
$Texinfo::Config::texinfo_formatting_references{$formatting_reference};
+       =  $customized_formatting_references->{$formatting_reference};
     } else {
       $self->{$formatting_reference} 
        = $default_formatting_references{$formatting_reference};
@@ -7298,11 +7302,12 @@ sub run_stage_handlers($$$)
   my $stage = shift;
   die if (!$possible_stages{$stage});
 
-  return 1 if 
(!defined($Texinfo::Config::texinfo_default_stage_handlers{$stage}));
+  my $stage_handlers = Texinfo::Config::GNUT_get_stage_handlers();
+  return 1 if (!defined($stage_handlers->{$stage}));
 
-  my @sorted_priorities = sort 
keys(%{$Texinfo::Config::texinfo_default_stage_handlers{$stage}});
+  my @sorted_priorities = sort keys(%{$stage_handlers->{$stage}});
   foreach my $priority (@sorted_priorities) {
-    foreach my $handler 
(@{$Texinfo::Config::texinfo_default_stage_handlers{$stage}->{$priority}}) {
+    foreach my $handler (@{$stage_handlers->{$stage}->{$priority}}) {
       if ($converter->get_conf('DEBUG')) {
         print STDERR "HANDLER($stage) , priority $priority: $handler\n";
       }
@@ -8144,7 +8149,6 @@ sub _convert($$;$)
     }
 
     if ($self->{'code_types'}->{$root->{'type'}}) {
-      #$self->{'document_context'}->[-1]->{'code'}++;
       push @{$self->{'document_context'}->[-1]->{'monospace'}}, 1;
     }
     if ($root->{'type'} eq '_string') {
@@ -8171,7 +8175,6 @@ sub _convert($$;$)
       $result = $content_formatted;
     }
     if ($self->{'code_types'}->{$root->{'type'}}) {
-      #$self->{'document_context'}->[-1]->{'code'}--;
       pop @{$self->{'document_context'}->[-1]->{'monospace'}};
     } 
     if ($root->{'type'} eq '_string') {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]