texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: * doc/texi2any_api.texi (Simple Customization of


From: Patrice Dumas
Subject: branch master updated: * doc/texi2any_api.texi (Simple Customization of Containers), tp/Texinfo/Config.pm (texinfo_register_type_code), (texinfo_register_type_pre_class, GNUT_get_types_code_info), (GNUT_get_types_pre_class), tp/Texinfo/Convert/HTML.pm (_XS_html_converter_get_customization, converter_initialize), tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_get_customization_sv), tp/Texinfo/XS/convert/get_html_perl_info.c (html_converter_get_customization_sv), tp/t/init/cvs.init: split texinfo_register_type [...]
Date: Sun, 19 Jan 2025 10:54:05 -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 e00a8f7000 * doc/texi2any_api.texi (Simple Customization of 
Containers), tp/Texinfo/Config.pm (texinfo_register_type_code), 
(texinfo_register_type_pre_class, GNUT_get_types_code_info), 
(GNUT_get_types_pre_class), tp/Texinfo/Convert/HTML.pm 
(_XS_html_converter_get_customization, converter_initialize), 
tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_get_customization_sv), 
tp/Texinfo/XS/convert/get_html_perl_info.c 
(html_converter_get_customization_sv), tp/t/init/cvs.init: split  [...]
e00a8f7000 is described below

commit e00a8f70002bf65e94e102368602d66befbe5adc
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jan 19 16:54:12 2025 +0100

    * doc/texi2any_api.texi (Simple Customization of Containers),
    tp/Texinfo/Config.pm (texinfo_register_type_code),
    (texinfo_register_type_pre_class, GNUT_get_types_code_info),
    (GNUT_get_types_pre_class), tp/Texinfo/Convert/HTML.pm
    (_XS_html_converter_get_customization, converter_initialize),
    tp/Texinfo/XS/convert/ConvertXS.xs
    (html_converter_get_customization_sv),
    tp/Texinfo/XS/convert/get_html_perl_info.c
    (html_converter_get_customization_sv), tp/t/init/cvs.init:
    split texinfo_register_type_format_info in two functions,
    texinfo_register_type_code and texinfo_register_type_pre_class.
    Update setting customization and passing customization through XS to
    C.
---
 ChangeLog                                  |  16 +++++
 doc/texi2any_api.texi                      |  34 ++++++----
 tp/Texinfo/Config.pm                       |  29 +++++---
 tp/Texinfo/Convert/HTML.pm                 |  28 +++++---
 tp/Texinfo/XS/convert/ConvertXS.xs         |   5 +-
 tp/Texinfo/XS/convert/get_html_perl_info.c | 103 +++++++++++++++++------------
 tp/Texinfo/XS/convert/get_html_perl_info.h |   3 +-
 tp/t/init/cvs.init                         |   3 +-
 8 files changed, 141 insertions(+), 80 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6e7e6765d3..7a95ca9dcf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2025-01-19  Patrice Dumas  <pertusus@free.fr>
+
+       * doc/texi2any_api.texi (Simple Customization of Containers),
+       tp/Texinfo/Config.pm (texinfo_register_type_code),
+       (texinfo_register_type_pre_class, GNUT_get_types_code_info),
+       (GNUT_get_types_pre_class), tp/Texinfo/Convert/HTML.pm
+       (_XS_html_converter_get_customization, converter_initialize),
+       tp/Texinfo/XS/convert/ConvertXS.xs
+       (html_converter_get_customization_sv),
+       tp/Texinfo/XS/convert/get_html_perl_info.c
+       (html_converter_get_customization_sv), tp/t/init/cvs.init:
+       split texinfo_register_type_format_info in two functions,
+       texinfo_register_type_code and texinfo_register_type_pre_class.
+       Update setting customization and passing customization through XS to
+       C.
+
 2025-01-19  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/ParserNonXS.pm (_next_text): simplify code, as
diff --git a/doc/texi2any_api.texi b/doc/texi2any_api.texi
index 236caa1611..510386e554 100644
--- a/doc/texi2any_api.texi
+++ b/doc/texi2any_api.texi
@@ -788,30 +788,40 @@ texinfo_register_accent_command_formatting('dotless', 
'nodot', 'ij');
 
 Texinfo tree elements that are not text container nor directly associated with
 an @@-command can have information set on their formatting.  The first piece of
-information is whether their contents should be considered in code context 
(@pxref{Init
-File Expansion Contexts}).  The other piece of information is the type of
+information is whether their contents should be considered in code context
+(@pxref{Init File Expansion Contexts}).
+
+Call @code{texinfo_register_type_code} to set code context for an element:
+
+@defun texinfo_register_type_code ($type, $code_type)
+@var{$type} is the type of the container.  If @var{$code_type} is set, the
+container contents are assumed to be in code context. @xref{Init File Expansion
+Contexts}.
+@end defun
+
+The other piece of information is the type of
 preformatted environment they are, analogous with the @@-command names of
 @code{@@example} or @code{@@display}@footnote{Note that setting the type of 
preformatted environment does not
 make sure that there are preformatted containers used for the formatting of 
their
 contents instead of paragraph containers, since this is determined in the very
 first step of parsing the Texinfo code, which cannot be customized.}.
 
-The function used is @code{texinfo_register_type_format_info}:
+Call @code{texinfo_register_type_pre_class} to set preformatted class:
 
-@defun texinfo_register_type_format_info ($type, $code_type, $pre_class_type)
-@var{$type} is the type of the container.  If @var{$code_type} is set, the 
container
-contents are assumed to be in code context. @xref{Init File Expansion
-Contexts}. If @var{$pre_class_type} is set, the HTML @code{<pre>} elements
-class attribute are based on @var{$pre_class_type}, if there are such HTML
-elements output for preformatted content of @var{$type} containers.
+@defun texinfo_register_type_pre_class ($type, $pre_class_type)
+@var{$type} is the type of the container.  If @var{$pre_class_type} is set, the
+HTML @code{<pre>} elements class attribute are based on @var{$pre_class_type},
+if there are such HTML elements output for preformatted content of @var{$type}
+containers.
 @end defun
 
 For example, to set content appearing in-between node links in @code{@@menu},
-which is in the @code{menu_comment} container type
-to be formatted in a code context, with preformatted type @samp{menu-between}, 
use:
+which is in the @code{menu_comment} container type to be formatted in a code
+context, with preformatted type @samp{menu-between}, use:
 
 @example
-texinfo_register_type_format_info('menu_comment', 1, 'menu-between');
+texinfo_register_type_code('menu_comment', 1);
+texinfo_register_type_pre_class('menu_comment', 'menu-between');
 @end example
 
 @xref{Texinfo::Parser Types of container elements,,,texi2any_internals}, for a
diff --git a/tp/Texinfo/Config.pm b/tp/Texinfo/Config.pm
index 79439e310e..63dc1999af 100644
--- a/tp/Texinfo/Config.pm
+++ b/tp/Texinfo/Config.pm
@@ -493,7 +493,8 @@ my $GNUT_upper_case_commands = {};
 my $GNUT_no_arg_commands_formatting_strings = {};
 my $GNUT_style_commands_formatting_info = {};
 my $GNUT_accent_command_formatting_info = {};
-my $GNUT_types_formatting_info = {};
+my $GNUT_types_code_info = {};
+my $GNUT_types_pre_class = {};
 my $GNUT_global_directions = {};
 my $GNUT_direction_string_info = {};
 my $GNUT_special_unit_info = {};
@@ -799,22 +800,30 @@ sub GNUT_get_accent_command_formatting($)
   return (undef, undef);
 }
 
-# need to give both arguments
-# FIXME is it ok, or should there be two functions?
-sub texinfo_register_type_format_info($$$)
+sub texinfo_register_type_code($$)
 {
   my $type = shift;
   my $code_type = shift;
+
+  $GNUT_types_code_info->{$type} = $code_type;
+}
+
+sub texinfo_register_type_pre_class($$)
+{
+  my $type = shift;
   my $pre_class_type = shift;
 
-  $GNUT_types_formatting_info->{$type}
-    = {'code' => $code_type, 'pre_class' => $pre_class_type};
+  $GNUT_types_pre_class->{$type} = $pre_class_type;
+}
+
+sub GNUT_get_types_code_info()
+{
+  return { %$GNUT_types_code_info };
 }
 
-sub GNUT_get_types_formatting_info()
+sub GNUT_get_types_pre_class()
 {
-  # NOTE a deep copy could also be done if needed
-  return { %$GNUT_types_formatting_info };
+  return { %$GNUT_types_pre_class };
 }
 
 # if $NODE_TEXI_NAME is undef, the direction is a direction text not
@@ -899,7 +908,7 @@ sub GNUT_reinitialize_init_files()
      $GNUT_upper_case_commands,
      $GNUT_commands_conversion, $GNUT_commands_open, $GNUT_types_conversion,
      $GNUT_types_open, $GNUT_accent_command_formatting_info,
-     $GNUT_types_formatting_info, $GNUT_direction_string_info,
+     $GNUT_types_code_info, $GNUT_types_pre_class, $GNUT_direction_string_info,
      $GNUT_global_directions) {
     $reference = {};
   }
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index a6a1656730..97dfb6dfbe 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -8705,7 +8705,7 @@ sub _XS_html_converter_initialize_beginning($)
 {
 }
 
-sub _XS_html_converter_get_customization($$$$$$$$$$$$$$$$$$)
+sub _XS_html_converter_get_customization($$$$$$$$$$$$$$$$$$$)
 {
 }
 
@@ -8802,14 +8802,21 @@ sub converter_initialize($)
   foreach my $type (keys(%default_pre_class_types)) {
     $self->{'pre_class_types'}->{$type} = $default_pre_class_types{$type};
   }
-  my $customized_type_formatting
-    = Texinfo::Config::GNUT_get_types_formatting_info();
-  foreach my $type (keys(%$customized_type_formatting)) {
-    # Used in cvs.init.
-    $self->{'code_types'}->{$type}
-     = $customized_type_formatting->{$type}->{'code'};
-    $self->{'pre_class_types'}->{$type}
-     = $customized_type_formatting->{$type}->{'pre_class'};
+
+  my $customized_code_types = Texinfo::Config::GNUT_get_types_code_info();
+  if ($customized_code_types) {
+    foreach my $type (keys(%$customized_code_types)) {
+      $self->{'code_types'}->{$type} = $customized_code_types->{$type};
+    }
+  }
+
+  my $customized_pre_class_types
+    = Texinfo::Config::GNUT_get_types_pre_class();
+  if ($customized_pre_class_types) {
+    foreach my $type (keys(%$customized_pre_class_types)) {
+      $self->{'pre_class_types'}->{$type}
+         = $customized_pre_class_types->{$type};
+    }
   }
 
   $self->{'upper_case_commands'} = {};
@@ -9130,7 +9137,8 @@ sub converter_initialize($)
                              \%default_output_units_conversion,
                              \%defaults_format_special_unit_body_contents,
                              $customized_upper_case_commands,
-                             $customized_type_formatting,
+                             $customized_code_types,
+                             $customized_pre_class_types,
                              \%customized_accent_entities,
                              \%style_commands_customized_formatting_info,
                              $customized_no_arg_commands_formatting,
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 8730982f9f..d3b121fa72 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -783,7 +783,7 @@ html_converter_initialize_beginning (SV *converter_in)
           }
 
 void
-html_converter_get_customization_sv (SV *converter_in, SV 
*default_formatting_references, SV *default_css_string_formatting_references, 
SV *default_commands_open, SV *default_commands_conversion, SV 
*default_css_string_commands_conversion, SV *default_types_open, SV 
*default_types_conversion, SV *default_css_string_types_conversion, SV 
*default_output_units_conversion, SV *default_special_unit_body, SV 
*customized_upper_case_commands, SV *customized_type_formatting, SV 
*customized_accent [...]
+html_converter_get_customization_sv (SV *converter_in, SV 
*default_formatting_references, SV *default_css_string_formatting_references, 
SV *default_commands_open, SV *default_commands_conversion, SV 
*default_css_string_commands_conversion, SV *default_types_open, SV 
*default_types_conversion, SV *default_css_string_types_conversion, SV 
*default_output_units_conversion, SV *default_special_unit_body, SV 
*customized_upper_case_commands, SV *customized_code_types, SV 
*customized_pre_class_t [...]
       PREINIT:
         CONVERTER *self;
       CODE:
@@ -811,7 +811,8 @@ html_converter_get_customization_sv (SV *converter_in, SV 
*default_formatting_re
                          default_output_units_conversion,
                          default_special_unit_body,
                          customized_upper_case_commands,
-                         customized_type_formatting,
+                         customized_code_types,
+                         customized_pre_class_types,
                          customized_accent_entities,
                          customized_style_commands,
                          customized_no_arg_commands_formatting,
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c 
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index 07f2dd5ac2..1fd860b73a 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -243,7 +243,8 @@ html_converter_get_customization_sv (SV *converter_sv,
                               SV *default_output_units_conversion,
                               SV *default_special_unit_body,
                               SV *customized_upper_case_commands,
-                              SV *customized_type_formatting,
+                              SV *customized_code_types,
+                              SV *customized_pre_class_types,
                               SV *customized_accent_entities,
                               SV *customized_style_commands,
                               SV *customized_no_arg_commands_formatting,
@@ -372,16 +373,15 @@ html_converter_get_customization_sv (SV *converter_sv,
         }
     }
 
-  if (customized_type_formatting && SvOK (customized_type_formatting))
+  if (customized_code_types && SvOK (customized_code_types))
     {
       I32 hv_number;
       I32 i;
       int code_type_idx = 0;
-      int pre_class_idx = 0;
-      HV *customized_type_formatting_hv
-        = (HV *)SvRV (customized_type_formatting);
+      HV *customized_code_types_hv
+        = (HV *)SvRV (customized_code_types);
 
-      hv_number = hv_iterinit (customized_type_formatting_hv);
+      hv_number = hv_iterinit (customized_code_types_hv);
 
       converter->html_customized_code_types
         = (TYPE_INTEGER_INFORMATION *) non_perl_malloc ((hv_number + 1)
@@ -389,6 +389,47 @@ html_converter_get_customization_sv (SV *converter_sv,
       memset (converter->html_customized_code_types, 0,
               (hv_number + 1) * sizeof (TYPE_INTEGER_INFORMATION));
 
+      for (i = 0; i < hv_number; i++)
+        {
+          enum element_type type = ET_NONE;
+          I32 retlen;
+          char *type_name;
+          SV *code_sv = hv_iternextsv (customized_code_types_hv,
+                                       &type_name, &retlen);
+          if (SvOK (code_sv))
+            {
+              type = find_element_type (type_name);
+
+              if (type == ET_NONE)
+                {
+                  fprintf (stderr, "ERROR: %s: customized type not found\n",
+                                   type_name);
+                }
+              else
+                {
+                  TYPE_INTEGER_INFORMATION *customized_code
+                    = &converter->html_customized_code_types[code_type_idx];
+                  int code_value = 0;
+                  code_value = SvIV (code_sv);
+
+                  customized_code->type = type;
+                  customized_code->integer = code_value;
+                  code_type_idx++;
+                }
+            }
+       }
+   }
+
+  if (customized_pre_class_types && SvOK (customized_pre_class_types))
+    {
+      I32 hv_number;
+      I32 i;
+      int pre_class_idx = 0;
+      HV *customized_pre_class_types_hv
+        = (HV *)SvRV (customized_pre_class_types);
+
+      hv_number = hv_iterinit (customized_pre_class_types_hv);
+
       converter->html_customized_pre_class_types
         = (PRE_CLASS_TYPE_INFO *) non_perl_malloc ((hv_number + 1)
                                   * sizeof (PRE_CLASS_TYPE_INFO));
@@ -400,9 +441,9 @@ html_converter_get_customization_sv (SV *converter_sv,
           enum element_type type = ET_NONE;
           I32 retlen;
           char *type_name;
-          SV *spec_sv = hv_iternextsv (customized_type_formatting_hv,
+          SV *pre_class_sv = hv_iternextsv (customized_pre_class_types_hv,
                                        &type_name, &retlen);
-          if (SvOK (spec_sv))
+          if (SvOK (pre_class_sv))
             {
               type = find_element_type (type_name);
 
@@ -413,42 +454,16 @@ html_converter_get_customization_sv (SV *converter_sv,
                 }
               else
                 {
-                  HV *spec_hv = (HV *)SvRV (spec_sv);
-                  SV **code_sv = hv_fetch (spec_hv, "code",
-                                           strlen("code"), 0);
-                  SV **pre_class_sv = hv_fetch (spec_hv, "pre_class",
-                                                strlen("pre_class"), 0);
-
-                  if (code_sv)
-                    {
-                      TYPE_INTEGER_INFORMATION *customized_code
-                        = 
&converter->html_customized_code_types[code_type_idx];
-                      int code_value = 0;
-
-                      if (SvOK (*code_sv))
-                        code_value = SvIV (*code_sv);
-
-                      customized_code->type = type;
-                      customized_code->integer = code_value;
-                      code_type_idx++;
-                    }
-                  if (pre_class_sv)
-                    {
-                      PRE_CLASS_TYPE_INFO *customized_pre_class
-                        = &converter->html_customized_pre_class_types
-                                                           [pre_class_idx];
-                      char *pre_class_value = 0;
-
-                      if (SvOK (*pre_class_sv))
-                        {
-                          const char *pre_class_string
-                             = SvPV_nolen (*pre_class_sv);
-                          pre_class_value = non_perl_strdup (pre_class_string);
-                        }
-                      customized_pre_class->type = type;
-                      customized_pre_class->pre_class = pre_class_value;
-                      pre_class_idx++;
-                    }
+                  PRE_CLASS_TYPE_INFO *customized_pre_class
+                    = &converter->html_customized_pre_class_types
+                                                       [pre_class_idx];
+                  const char *pre_class_string
+                    = SvPV_nolen (pre_class_sv);
+
+                  customized_pre_class->type = type;
+                  customized_pre_class->pre_class
+                    = non_perl_strdup (pre_class_string);
+                  pre_class_idx++;
                 }
             }
         }
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.h 
b/tp/Texinfo/XS/convert/get_html_perl_info.h
index 0f6af56d7b..7c86a416e8 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.h
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.h
@@ -25,7 +25,8 @@ void html_converter_get_customization_sv (SV *converter_sv,
                                   SV *default_output_units_conversion,
                                   SV *default_special_unit_body,
                                   SV *customized_upper_case_commands,
-                                  SV *customized_type_formatting,
+                                  SV *customized_code_types,
+                                  SV *customized_pre_class_types,
                                   SV *customized_accent_entities,
                                   SV *customized_style_commands,
                                   SV *customized_no_arg_commands_formatting,
diff --git a/tp/t/init/cvs.init b/tp/t/init/cvs.init
index e852470fc2..18a90fed55 100644
--- a/tp/t/init/cvs.init
+++ b/tp/t/init/cvs.init
@@ -1,2 +1,3 @@
 
-texinfo_register_type_format_info('menu_comment', 1, 'menu-comment');
+texinfo_register_type_code('menu_comment', 1);
+texinfo_register_type_pre_class('menu_comment', 'menu-comment');



reply via email to

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