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 (texinfo_register_no_arg_c


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Config.pm (texinfo_register_no_arg_command_formatting) (GNUT_get_no_arg_command_formatting) (texinfo_register_style_command_formatting) (GNUT_get_style_command_formatting), tp/Texinfo/Convert/HTML.pm, tp/init/chm.pm, tp/init/html32.pm: setup an API for registering formatting of no_arg_commands and style_commands.
Date: Fri, 03 Sep 2021 15:50:32 -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 783c460  * tp/Texinfo/Config.pm 
(texinfo_register_no_arg_command_formatting) 
(GNUT_get_no_arg_command_formatting) 
(texinfo_register_style_command_formatting) 
(GNUT_get_style_command_formatting), tp/Texinfo/Convert/HTML.pm, 
tp/init/chm.pm, tp/init/html32.pm: setup an API for registering formatting of 
no_arg_commands and style_commands.
783c460 is described below

commit 783c460c60d2361980706cad920f274a9c54a768
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Sep 3 21:50:23 2021 +0200

    * tp/Texinfo/Config.pm (texinfo_register_no_arg_command_formatting)
    (GNUT_get_no_arg_command_formatting)
    (texinfo_register_style_command_formatting)
    (GNUT_get_style_command_formatting), tp/Texinfo/Convert/HTML.pm,
    tp/init/chm.pm, tp/init/html32.pm: setup an API for registering
    formatting of no_arg_commands and style_commands.
---
 ChangeLog                  |  9 +++++
 tp/TODO                    |  2 -
 tp/Texinfo/Config.pm       | 97 ++++++++++++++++++++++++++++++++++++++++++----
 tp/Texinfo/Convert/HTML.pm | 12 ++++--
 tp/init/chm.pm             |  5 +--
 tp/init/html32.pm          | 19 +++++----
 6 files changed, 119 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0c55504..e29b579 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2021-09-03  Patrice Dumas  <pertusus@free.fr>
 
+       * tp/Texinfo/Config.pm (texinfo_register_no_arg_command_formatting)
+       (GNUT_get_no_arg_command_formatting)
+       (texinfo_register_style_command_formatting)
+       (GNUT_get_style_command_formatting), tp/Texinfo/Convert/HTML.pm,
+       tp/init/chm.pm, tp/init/html32.pm: setup an API for registering
+       formatting of no_arg_commands and style_commands.
+
+2021-09-03  Patrice Dumas  <pertusus@free.fr>
+
        * tp/maintain/lib/libintl-perl/: synchronize with code archive
        by removing generated files and adding files that were not present.
        None of the added/removed files are used/installed in Texinfo.
diff --git a/tp/TODO b/tp/TODO
index 4b4aaf7..adab38e 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -18,8 +18,6 @@ do not remove documentlanguage in index entries in 
complete_indices
 
 Rename _set_global_multiple_commands
 
-Real API for Texinfo::Config used in html32.pm.
-
 check @{$converter_options->{'INCLUDE_DIRECTORIES'}} with more 
 than one output file
 FIXME isn't that done for each output file?
diff --git a/tp/Texinfo/Config.pm b/tp/Texinfo/Config.pm
index dfb3cbb..69556e1 100644
--- a/tp/Texinfo/Config.pm
+++ b/tp/Texinfo/Config.pm
@@ -227,6 +227,8 @@ sub texinfo_add_valid_option($)
   return Texinfo::Common::add_valid_option($option);
 }
 
+
+
 my @possible_stages = ('setup', 'structure', 'init', 'finish');
 my %possible_stages;
 foreach my $stage (@possible_stages) {
@@ -235,17 +237,9 @@ foreach my $stage (@possible_stages) {
 
 my $default_priority = 'default';
 
-# These 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().
-#
 # 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($$;$)
 {
@@ -268,6 +262,13 @@ sub GNUT_get_stage_handlers()
   return $GNUT_stage_handlers;
 }
 
+
+my $GNUT_formatting_references = {};
+my $GNUT_commands_conversion = {};
+my $GNUT_types_conversion = {};
+my $GNUT_no_arg_commands_formatting_strings = {};
+my $GNUT_style_commands_formatting_info = {};
+
 # called from init files
 sub texinfo_register_formatting_function($$)
 {
@@ -310,6 +311,86 @@ sub GNUT_get_types_conversion()
   return $GNUT_types_conversion;
 }
 
+my $default_formatting_context = 'normal';
+my %possible_formatting_contexts;
+foreach my $possible_formatting_context (($default_formatting_context,
+                       'preformatted', 'string')) {
+  $possible_formatting_contexts{$possible_formatting_context} = 1;
+}
+
+sub texinfo_register_no_arg_command_formatting($$;$)
+{
+  my $command = shift;
+  my $value = shift;
+  my $context = shift;
+
+  if (!defined($context)) {
+    $context = $default_formatting_context;
+  } elsif (not defined($possible_formatting_contexts{$context})) {
+    _GNUT_document_warn(sprintf(__("%s: unknown formatting context %s\n"),
+                  'texinfo_register_no_arg_command_formatting', $context));
+    return 0;
+  }
+  $GNUT_no_arg_commands_formatting_strings->{$context}->{$command} = $value;
+  return 1;
+}
+
+sub GNUT_get_no_arg_command_formatting($;$)
+{
+  my $command = shift;
+  my $context = shift;
+
+  if (!defined($context)) {
+    $context = $default_formatting_context;
+  } elsif (not defined($possible_formatting_contexts{$context})) {
+    _GNUT_document_warn(sprintf(__("%s: unknown formatting context %s\n"),
+                        'GNUT_get_no_arg_command_formatting', $context));
+    return undef;
+  }
+  if (exists($GNUT_no_arg_commands_formatting_strings->{$context})
+      and 
exists($GNUT_no_arg_commands_formatting_strings->{$context}->{$command})) {
+    return $GNUT_no_arg_commands_formatting_strings->{$context}->{$command};
+  }
+  return undef;
+}
+
+# the value should be a hash reference, possibly empty, with valid
+# keys 'attribute' and 'quote'.
+sub texinfo_register_style_command_formatting($$;$)
+{
+  my $command = shift;
+  my $value = shift;
+  my $context = shift;
+
+  if (!defined($context)) {
+    $context = $default_formatting_context;
+  } elsif (not defined($possible_formatting_contexts{$context})) {
+    _GNUT_document_warn(sprintf(__("%s: unknown formatting context %s\n"),
+                  'texinfo_register_style_command_formatting', $context));
+    return 0;
+  }
+  $GNUT_style_commands_formatting_info->{$context}->{$command} = $value;
+  return 1;
+}
+
+sub GNUT_get_style_command_formatting($;$)
+{
+  my $command = shift;
+  my $context = shift;
+
+  if (!defined($context)) {
+    $context = $default_formatting_context;
+  } elsif (not defined($possible_formatting_contexts{$context})) {
+    _GNUT_document_warn(sprintf(__("%s: unknown formatting context %s\n"),
+                        'GNUT_get_style_command_formatting', $context));
+    return undef;
+  }
+  if (exists($GNUT_style_commands_formatting_info->{$context})
+      and 
exists($GNUT_style_commands_formatting_info->{$context}->{$command})) {
+    return $GNUT_style_commands_formatting_info->{$context}->{$command};
+  }
+  return undef;
+}
 
 package Texinfo::MainConfig;
 
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index f1c38e4..bce4a42 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -5181,9 +5181,11 @@ sub converter_initialize($)
 
   foreach my $context ('normal', 'preformatted', 'string') {
     foreach my $command 
(keys(%{$default_no_arg_commands_formatting{'normal'}})) {
-      if (exists 
($Texinfo::Config::no_arg_commands_formatting{$context}->{$command})) {
+      my $no_arg_command_customized_formatting
+        = Texinfo::Config::GNUT_get_no_arg_command_formatting($command, 
$context);
+      if (defined($no_arg_command_customized_formatting)) {
         $self->{'no_arg_commands_formatting'}->{$context}->{$command}
-           = 
$Texinfo::Config::no_arg_commands_formatting{$context}->{$command};
+           = $no_arg_command_customized_formatting;
       } else {
         if 
(defined($default_no_arg_commands_formatting{$context}->{$command})) {
           if ($self->get_conf('ENABLE_ENCODING') 
@@ -5223,9 +5225,11 @@ sub converter_initialize($)
 
   foreach my $context (keys(%style_commands_formatting)) {
     foreach my $command (keys(%{$style_commands_formatting{$context}})) {
-      if (exists 
($Texinfo::Config::style_commands_formatting{$context}->{$command})) {
+      my $style_commands_formatting_info
+        = Texinfo::Config::GNUT_get_style_command_formatting($command, 
$context);
+      if (defined($style_commands_formatting_info)) {
         $self->{'style_commands_formatting'}->{$context}->{$command} 
-           = $Texinfo::Config::style_commands_formatting{$context}->{$command};
+           = $style_commands_formatting_info;
       } elsif (exists($style_commands_formatting{$context}->{$command})) {
         $self->{'style_commands_formatting'}->{$context}->{$command} 
            = $style_commands_formatting{$context}->{$command};
diff --git a/tp/init/chm.pm b/tp/init/chm.pm
index eb08883..cdfd675 100644
--- a/tp/init/chm.pm
+++ b/tp/init/chm.pm
@@ -54,7 +54,6 @@ texinfo_set_from_init_file('footnotestyle', 'end');
 #FIXME remove that later?
 texinfo_set_from_init_file('USE_NODES', 0);
 
-use vars qw(%no_arg_commands_formatting);
 texinfo_register_formatting_function('format_end_file', \&chm_format_end_file);
 texinfo_register_formatting_function('format_navigation_header', \&chm_noop);
 texinfo_register_formatting_function('format_navigation_header_panel', 
\&chm_noop);
@@ -175,8 +174,8 @@ my %hhc_global_property = (
 
 # at least kchmviewer has trouble with the corresponding textual entities
 foreach my $thing ('OE', 'oe', 'euro') {
-  $no_arg_commands_formatting{'normal'}->{$thing}
-    = $Texinfo::Convert::Unicode::unicode_entities{$thing};
+  texinfo_register_no_arg_command_formatting($thing,
+                   $Texinfo::Convert::Unicode::unicode_entities{$thing});
 }
 
 sub chm_format_end_file($)
diff --git a/tp/init/html32.pm b/tp/init/html32.pm
index 6f57a08..18b4854 100644
--- a/tp/init/html32.pm
+++ b/tp/init/html32.pm
@@ -24,9 +24,12 @@
 
#-##############################################################################
 
 use strict;
+
+use Texinfo::Common;
+
 use Texinfo::Convert::Converter qw(xml_protect_text);
+use Texinfo::Convert::Text;
 
-use vars qw(%no_arg_commands_formatting %style_commands_formatting);
 
 texinfo_set_from_init_file('COMPLEX_FORMAT_IN_TABLE', 1);
 
@@ -62,22 +65,22 @@ foreach my $command ('euro', 'geq', 'leq',
    'quotedblbase', 'quotesinglbase', 'guillemetleft', 'guillemetright',
    'guillemotleft', 'guillemotright', 'guilsinglleft', 'guilsinglright') {
   
-  $no_arg_commands_formatting{'normal'}->{$command}
-    = xml_protect_text(undef,
+  my $formatted_command = xml_protect_text(undef,
              $Texinfo::Convert::Text::text_brace_no_arg_commands{$command});
+  texinfo_register_no_arg_command_formatting($command, $formatted_command);
 }
 
-$no_arg_commands_formatting{'normal'}->{'oe'} = '&#156;';
-$no_arg_commands_formatting{'normal'}->{'OE'} = '&#140;';
+texinfo_register_no_arg_command_formatting('oe', '&#156;');
+texinfo_register_no_arg_command_formatting('OE', '&#140;');
 
 foreach my $dots ('dots', 'enddots') {
-  $no_arg_commands_formatting{'normal'}->{$dots} = '<small>...</small>';
-  $no_arg_commands_formatting{'preformatted'}->{$dots} = '...';
+  texinfo_register_no_arg_command_formatting($dots, '<small>...</small>');
+  texinfo_register_no_arg_command_formatting($dots, '...', 'preformatted');
 }
 
 foreach my $context ('preformatted', 'normal') {
   foreach my $command('sansserif', 'r') {
-    $style_commands_formatting{$context}->{$command} = {};
+    texinfo_register_style_command_formatting($command, {}, $context);
   }
 }
 



reply via email to

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