texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/HTML.pm (converter_initializ


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/HTML.pm (converter_initialize), tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_initialize_sv), tp/Texinfo/XS/main/converter_types.h (CONVERTER), tp/Texinfo/XS/main/get_perl_info.c (register_formatting_reference_default) (register_formatting_reference_with_default) (html_converter_initialize_sv): pass css strings commands and types conversion to C. To setup css strings formatting references, copy the formatting references and replace with specific css functions refe [...]
Date: Fri, 03 Nov 2023 04:35:40 -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 0149142d33 * tp/Texinfo/Convert/HTML.pm (converter_initialize), 
tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_initialize_sv), 
tp/Texinfo/XS/main/converter_types.h (CONVERTER), 
tp/Texinfo/XS/main/get_perl_info.c (register_formatting_reference_default) 
(register_formatting_reference_with_default) (html_converter_initialize_sv): 
pass css strings commands and types conversion to C. To setup css strings 
formatting references, copy the formatting references and replace with specif 
[...]
0149142d33 is described below

commit 0149142d337bb211403b1545c57eb0ebc2a43158
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Nov 3 09:33:54 2023 +0100

    * tp/Texinfo/Convert/HTML.pm (converter_initialize),
    tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_initialize_sv),
    tp/Texinfo/XS/main/converter_types.h (CONVERTER),
    tp/Texinfo/XS/main/get_perl_info.c
    (register_formatting_reference_default)
    (register_formatting_reference_with_default)
    (html_converter_initialize_sv): pass css strings commands and types
    conversion to C. To setup css strings formatting references, copy the
    formatting references and replace with specific css functions
    references. Do that for formatting functions, commands and types
    conversion.
    
    * tp/Texinfo/XS/convert/convert_html.c (command_conversion)
    (type_conversion, html_initialize_output_state),
    tp/Texinfo/XS/main/call_perl_function.c (call_types_conversion)
    (call_commands_conversion), tp/Texinfo/XS/main/converter_types.h
    (CONVERTER): add current_formatting_references,
    current_commands_conversion and current_types_conversion in converter
    to be able to change formatting functions references lists as a whole.
    
    * tp/Texinfo/XS/convert/convert_html.c (html_convert_css_string)
    (reset_unset_no_arg_commands_formatting_context),
    tp/Texinfo/XS/main/build_perl_info.c (build_html_translated_names):
    implement css string conversion and pass translated css strings no arg
    commands back to perl.
---
 ChangeLog                               |  28 +++++++++
 tp/Texinfo/Convert/HTML.pm              |   4 +-
 tp/Texinfo/XS/convert/ConvertXS.xs      |   2 +-
 tp/Texinfo/XS/convert/convert_html.c    |  69 +++++++++++++++++----
 tp/Texinfo/XS/main/build_perl_info.c    |   2 +-
 tp/Texinfo/XS/main/call_perl_function.c |  56 ++++++++---------
 tp/Texinfo/XS/main/call_perl_function.h |   4 +-
 tp/Texinfo/XS/main/converter_types.h    |  11 +++-
 tp/Texinfo/XS/main/get_perl_info.c      | 104 +++++++++++++++++++++++++++-----
 tp/Texinfo/XS/main/get_perl_info.h      |   3 +
 10 files changed, 223 insertions(+), 60 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 47b315f145..6c1b9545b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2023-11-03  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (converter_initialize),
+       tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_initialize_sv),
+       tp/Texinfo/XS/main/converter_types.h (CONVERTER),
+       tp/Texinfo/XS/main/get_perl_info.c
+       (register_formatting_reference_default)
+       (register_formatting_reference_with_default)
+       (html_converter_initialize_sv): pass css strings commands and types
+       conversion to C. To setup css strings formatting references, copy the
+       formatting references and replace with specific css functions
+       references. Do that for formatting functions, commands and types
+       conversion.
+
+       * tp/Texinfo/XS/convert/convert_html.c (command_conversion)
+       (type_conversion, html_initialize_output_state),
+       tp/Texinfo/XS/main/call_perl_function.c (call_types_conversion)
+       (call_commands_conversion), tp/Texinfo/XS/main/converter_types.h
+       (CONVERTER): add current_formatting_references,
+       current_commands_conversion and current_types_conversion in converter
+       to be able to change formatting functions references lists as a whole.
+
+       * tp/Texinfo/XS/convert/convert_html.c (html_convert_css_string)
+       (reset_unset_no_arg_commands_formatting_context),
+       tp/Texinfo/XS/main/build_perl_info.c (build_html_translated_names):
+       implement css string conversion and pass translated css strings no arg
+       commands back to perl.
+
 2023-11-02  Gavin Smith <gavinsmith0123@gmail.com>
 
        * configure.ac, js/info.js, util/texi2dvi, util/texi2pdf:
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index fbde36c879..99a3075a1f 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -7980,7 +7980,7 @@ my %special_characters = (
   'non_breaking_space' => [undef, '00A0'],
 );
 
-sub _XS_converter_initialize($$$$$$$$)
+sub _XS_converter_initialize($$$$$$$$$$)
 {
 }
 
@@ -8437,8 +8437,10 @@ sub converter_initialize($)
                              \%default_css_string_formatting_references,
                              \%default_commands_open,
                              \%default_commands_conversion,
+                             \%default_css_string_commands_conversion,
                              \%default_types_open,
                              \%default_types_conversion,
+                             \%default_css_string_types_conversion,
                              \%default_output_units_conversion);
   }
 
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index e1ca6a420e..f1953fc38f 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -92,7 +92,7 @@ text_convert_tree (text_options_in, tree_in, unused=0)
         RETVAL
 
 int
-html_converter_initialize_sv (SV *converter_in, SV 
*default_formatting_references, SV *default_css_string_formatting_references, 
SV *default_commands_open, SV *default_commands_conversion, SV 
*default_types_open, SV *default_types_conversion, SV* 
default_output_units_conversion)
+html_converter_initialize_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)
 
 void set_conf(SV *converter_in, conf, SV *value)
          char *conf = (char *)SvPVbyte_nolen($arg);
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 6dcbdc8371..4a9aed6fd9 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -2042,9 +2042,13 @@ command_conversion (CONVERTER *self, enum command_id cmd,
     fprintf (stderr, "DEBUG: command conversion %s '%s'\n",
              builtin_command_data[cmd].cmdname, content);
    */
-  if (self->commands_conversion[cmd].status > 0)
-    return call_commands_conversion (self, cmd, element,
-                                     args_formatted, content);
+
+  FORMATTING_REFERENCE *formatting_reference
+    = &self->current_commands_conversion[cmd];
+
+  if (formatting_reference->status > 0)
+    return call_commands_conversion (self, cmd, formatting_reference,
+                                     element, args_formatted, content);
   return 0;
 }
 
@@ -2064,8 +2068,13 @@ type_conversion (CONVERTER *self, enum element_type type,
 {
   /* TODO call a C function if status is FRS_status_default_set
      maybe putting function references in an array */
-  if (self->types_conversion[type].status > 0)
-    return call_types_conversion (self, type, element, content);
+
+  FORMATTING_REFERENCE *formatting_reference
+    = &self->current_types_conversion[type];
+
+  if (formatting_reference->status > 0)
+    return call_types_conversion (self, type, formatting_reference,
+                                  element, content);
   return 0;
 }
 
@@ -2290,6 +2299,10 @@ html_initialize_output_state (CONVERTER *self)
         = (HTML_TARGET_LIST *) malloc (sizeof (HTML_TARGET_LIST));
       memset (self->html_special_targets[i], 0, sizeof (HTML_TARGET_LIST));
     }
+
+  self->current_formatting_references = &self->formatting_references[0];
+  self->current_commands_conversion = &self->commands_conversion[0];
+  self->current_types_conversion = &self->types_conversion[0];
 }
 
 char *
@@ -2360,6 +2373,42 @@ convert_tree_new_formatting_context (CONVERTER *self, 
ELEMENT *tree,
   return result;
 }
 
+char *
+html_convert_css_string (CONVERTER *self, ELEMENT *element, char *explanation)
+{
+  char *result;
+  HTML_DOCUMENT_CONTEXT *top_document_ctx;
+
+  FORMATTING_REFERENCE *saved_formatting_references
+     = self->current_formatting_references;
+  FORMATTING_REFERENCE *saved_commands_conversion
+     = self->current_commands_conversion;
+  FORMATTING_REFERENCE *saved_types_conversion
+     = self->current_types_conversion;
+
+  self->current_formatting_references
+    = &self->css_string_formatting_references[0];
+  self->current_commands_conversion
+    = &self->css_string_commands_conversion[0];
+  self->current_types_conversion
+    = &self->css_string_types_conversion[0];
+
+  html_new_document_context (self, "css_string", 0, 0);
+  top_document_ctx = top_document_context (self);
+  self->modified_state |= HMSF_document_context;
+  top_document_ctx->string_ctx++;
+
+  result = html_convert_tree (self, element, explanation);
+
+  html_pop_document_context (self);
+  self->modified_state |= HMSF_document_context;
+
+  self->current_formatting_references = saved_formatting_references;
+  self->current_commands_conversion = saved_commands_conversion;
+  self->current_types_conversion = saved_types_conversion;
+
+  return result;
+}
 
 static void
 reset_unset_no_arg_commands_formatting_context (CONVERTER *self,
@@ -2484,10 +2533,8 @@ reset_unset_no_arg_commands_formatting_context 
(CONVERTER *self,
         }
       else if (reset_context == HCC_type_css_string)
         {
-           /*
-          fprintf (stderr, "TODO ccs_string %s\n", 
builtin_command_data[cmd].cmdname);
-          translation_result = html_convert_css_string (self, translated_tree);
-            */
+          translation_result = html_convert_css_string (self, translated_tree,
+                                                        0);
         }
       if (no_arg_command_context->text)
         free (no_arg_command_context->text);
@@ -3101,8 +3148,8 @@ convert_to_html_internal (CONVERTER *self, ELEMENT 
*element,
                       if (arg_flags & F_AFT_url)
                         {
                           char *text;
-              /* set the encoding to UTF-8 to always have a string that is 
suitable
-                 for percent encoding. */
+           /* set the encoding to UTF-8 to always have a string that is 
suitable
+              for percent encoding. */
                           TEXT_OPTIONS *text_conv_options
                             = copy_options_for_convert_text (self, 1);
                           text_conv_options->code_state = 1;
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index be35cb0e09..bee8c65ea9 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -1921,7 +1921,7 @@ build_html_translated_names (HV *hv, CONVERTER *converter)
   /* pass all the information for each context for translated commands */
   if (converter->no_arg_formatted_cmd_translated.number)
     {
-      int max_context = HCC_type_css_string;
+      int max_context = HCC_type_css_string +1;
       int j;
       HV *no_arg_commands_formatting_hv;
       FETCH(no_arg_commands_formatting);
diff --git a/tp/Texinfo/XS/main/call_perl_function.c 
b/tp/Texinfo/XS/main/call_perl_function.c
index 24d3072026..4c95c6b1c0 100644
--- a/tp/Texinfo/XS/main/call_perl_function.c
+++ b/tp/Texinfo/XS/main/call_perl_function.c
@@ -488,14 +488,14 @@ call_formatting_function_format_title_titlepage 
(CONVERTER *self)
   char *result_ret;
   STRLEN len;
   SV *result_sv;
-  SV *formatting_reference;
+  SV *formatting_reference_sv;
 
   dTHX;
 
   if (!self->hv)
     return 0;
 
-  formatting_reference
+  formatting_reference_sv
     = self->formatting_references[FR_format_title_titlepage].sv_reference;
 
   if (self->modified_state)
@@ -515,7 +515,7 @@ call_formatting_function_format_title_titlepage (CONVERTER 
*self)
   PUSHs(sv_2mortal (newRV_inc (self->hv)));
   PUTBACK;
 
-  count = call_sv (formatting_reference,
+  count = call_sv (formatting_reference_sv,
                    G_SCALAR);
 
   SPAGAIN;
@@ -544,14 +544,14 @@ call_formatting_function_format_footnotes_segment 
(CONVERTER *self)
   char *result_ret;
   STRLEN len;
   SV *result_sv;
-  SV *formatting_reference;
+  SV *formatting_reference_sv;
 
   dTHX;
 
   if (!self->hv)
     return 0;
 
-  formatting_reference
+  formatting_reference_sv
     = self->formatting_references[FR_format_footnotes_segment].sv_reference;
 
   if (self->modified_state)
@@ -571,7 +571,7 @@ call_formatting_function_format_footnotes_segment 
(CONVERTER *self)
   PUSHs(sv_2mortal (newRV_inc (self->hv)));
   PUTBACK;
 
-  count = call_sv (formatting_reference,
+  count = call_sv (formatting_reference_sv,
                    G_SCALAR);
 
   SPAGAIN;
@@ -601,7 +601,7 @@ call_formatting_function_format_end_file (CONVERTER *self, 
char *filename,
   char *result_ret;
   STRLEN len;
   SV *result_sv;
-  SV *formatting_reference;
+  SV *formatting_reference_sv;
   SV *output_unit_sv;
 
   dTHX;
@@ -609,7 +609,7 @@ call_formatting_function_format_end_file (CONVERTER *self, 
char *filename,
   if (!self->hv)
     return 0;
 
-  formatting_reference
+  formatting_reference_sv
     = self->formatting_references[FR_format_end_file].sv_reference;
 
   if (self->modified_state)
@@ -636,7 +636,7 @@ call_formatting_function_format_end_file (CONVERTER *self, 
char *filename,
   PUSHs(sv_2mortal (output_unit_sv));
   PUTBACK;
 
-  count = call_sv (formatting_reference,
+  count = call_sv (formatting_reference_sv,
                    G_SCALAR);
 
   SPAGAIN;
@@ -666,7 +666,7 @@ call_formatting_function_format_begin_file (CONVERTER 
*self, char *filename,
   char *result_ret;
   STRLEN len;
   SV *result_sv;
-  SV *formatting_reference;
+  SV *formatting_reference_sv;
   SV *output_unit_sv;
 
   dTHX;
@@ -674,7 +674,7 @@ call_formatting_function_format_begin_file (CONVERTER 
*self, char *filename,
   if (!self->hv)
     return 0;
 
-  formatting_reference
+  formatting_reference_sv
     = self->formatting_references[FR_format_begin_file].sv_reference;
 
   if (self->modified_state)
@@ -701,7 +701,7 @@ call_formatting_function_format_begin_file (CONVERTER 
*self, char *filename,
   PUSHs(sv_2mortal (output_unit_sv));
   PUTBACK;
 
-  count = call_sv (formatting_reference,
+  count = call_sv (formatting_reference_sv,
                    G_SCALAR);
 
   SPAGAIN;
@@ -724,6 +724,7 @@ call_formatting_function_format_begin_file (CONVERTER 
*self, char *filename,
 
 char *
 call_types_conversion (CONVERTER *self, enum element_type type,
+                       FORMATTING_REFERENCE *formatting_reference,
                        ELEMENT *element, char *content)
 {
   int count;
@@ -731,7 +732,7 @@ call_types_conversion (CONVERTER *self, enum element_type 
type,
   char *result_ret;
   STRLEN len;
   SV *result_sv;
-  SV *formatting_reference;
+  SV *formatting_reference_sv;
 
   dTHX;
 
@@ -744,7 +745,7 @@ call_types_conversion (CONVERTER *self, enum element_type 
type,
       self->tree_to_build = 0;
     }
 
-  formatting_reference = self->types_conversion[type].sv_reference;
+  formatting_reference_sv = formatting_reference->sv_reference;
 
   if (self->modified_state)
     {
@@ -768,7 +769,7 @@ call_types_conversion (CONVERTER *self, enum element_type 
type,
   PUSHs(sv_2mortal (newSVpv_utf8 (content, 0)));
   PUTBACK;
 
-  count = call_sv (formatting_reference,
+  count = call_sv (formatting_reference_sv,
                    G_SCALAR);
 
   SPAGAIN;
@@ -800,7 +801,7 @@ call_types_open (CONVERTER *self, enum element_type type,
   char *result_ret;
   STRLEN len;
   SV *result_sv;
-  SV *formatting_reference;
+  SV *formatting_reference_sv;
 
   dTHX;
 
@@ -813,7 +814,7 @@ call_types_open (CONVERTER *self, enum element_type type,
   if (!self->hv)
     return 0;
 
-  formatting_reference = self->types_open[type].sv_reference;
+  formatting_reference_sv = self->types_open[type].sv_reference;
 
   if (self->modified_state)
     {
@@ -834,7 +835,7 @@ call_types_open (CONVERTER *self, enum element_type type,
   PUSHs(sv_2mortal (newRV_inc (element->hv)));
   PUTBACK;
 
-  count = call_sv (formatting_reference,
+  count = call_sv (formatting_reference_sv,
                    G_SCALAR);
 
   SPAGAIN;
@@ -859,6 +860,7 @@ call_types_open (CONVERTER *self, enum element_type type,
 
 char *
 call_commands_conversion (CONVERTER *self, enum command_id cmd,
+                          FORMATTING_REFERENCE *formatting_reference,
                           ELEMENT *element, HTML_ARGS_FORMATTED 
*args_formatted,
                           const char *content)
 {
@@ -867,7 +869,7 @@ call_commands_conversion (CONVERTER *self, enum command_id 
cmd,
   char *result_ret;
   STRLEN len;
   SV *result_sv;
-  SV *formatting_reference;
+  SV *formatting_reference_sv;
   SV *args_formatted_sv;
   char *command_name;
 
@@ -885,7 +887,7 @@ call_commands_conversion (CONVERTER *self, enum command_id 
cmd,
   /* could also be builtin_command_data[cmd].cmdname) */
   command_name = element_command_name (element);
 
-  formatting_reference = self->commands_conversion[cmd].sv_reference;
+  formatting_reference_sv = formatting_reference->sv_reference;
 
   if (self->modified_state)
     {
@@ -912,7 +914,7 @@ call_commands_conversion (CONVERTER *self, enum command_id 
cmd,
   PUSHs(sv_2mortal (newSVpv_utf8 (content, 0)));
   PUTBACK;
 
-  count = call_sv (formatting_reference,
+  count = call_sv (formatting_reference_sv,
                    G_SCALAR);
 
   SPAGAIN;
@@ -944,7 +946,7 @@ call_commands_open (CONVERTER *self, enum command_id cmd,
   char *result_ret;
   STRLEN len;
   SV *result_sv;
-  SV *formatting_reference;
+  SV *formatting_reference_sv;
   char *command_name;
 
   dTHX;
@@ -958,7 +960,7 @@ call_commands_open (CONVERTER *self, enum command_id cmd,
       self->tree_to_build = 0;
     }
 
-  formatting_reference = self->commands_open[cmd].sv_reference;
+  formatting_reference_sv = self->commands_open[cmd].sv_reference;
 
   /* could also be builtin_command_data[cmd].cmdname) */
   command_name = element_command_name (element);
@@ -982,7 +984,7 @@ call_commands_open (CONVERTER *self, enum command_id cmd,
   PUSHs(sv_2mortal (newRV_inc (element->hv)));
   PUTBACK;
 
-  count = call_sv (formatting_reference,
+  count = call_sv (formatting_reference_sv,
                    G_SCALAR);
 
   SPAGAIN;
@@ -1015,7 +1017,7 @@ call_output_units_conversion (CONVERTER *self,
   char *result_ret;
   STRLEN len;
   SV *result_sv;
-  SV *formatting_reference;
+  SV *formatting_reference_sv;
 
   dTHX;
 
@@ -1028,7 +1030,7 @@ call_output_units_conversion (CONVERTER *self,
       self->tree_to_build = 0;
     }
 
-  formatting_reference
+  formatting_reference_sv
      = self->output_units_conversion[unit_type].sv_reference;
 
   if (self->modified_state)
@@ -1053,7 +1055,7 @@ call_output_units_conversion (CONVERTER *self,
   PUSHs(sv_2mortal (newSVpv_utf8 (content, 0)));
   PUTBACK;
 
-  count = call_sv (formatting_reference,
+  count = call_sv (formatting_reference_sv,
                    G_SCALAR);
 
   SPAGAIN;
diff --git a/tp/Texinfo/XS/main/call_perl_function.h 
b/tp/Texinfo/XS/main/call_perl_function.h
index 77be421f09..5b2cea12bc 100644
--- a/tp/Texinfo/XS/main/call_perl_function.h
+++ b/tp/Texinfo/XS/main/call_perl_function.h
@@ -46,10 +46,12 @@ char *call_formatting_function_format_begin_file (CONVERTER 
*self,
                                               OUTPUT_UNIT *output_unit);
 
 char *call_types_conversion (CONVERTER *self, enum element_type type,
-                             ELEMENT *element, char *content);
+                       FORMATTING_REFERENCE *formatting_reference,
+                       ELEMENT *element, char *content);
 char *call_types_open (CONVERTER *self, enum element_type type,
                        ELEMENT *element);
 char *call_commands_conversion (CONVERTER *self, enum command_id cmd,
+                          FORMATTING_REFERENCE *formatting_reference,
                           ELEMENT *element, HTML_ARGS_FORMATTED 
*args_formatted,
                           const char *content);
 char *call_commands_open (CONVERTER *self, enum command_id cmd,
diff --git a/tp/Texinfo/XS/main/converter_types.h 
b/tp/Texinfo/XS/main/converter_types.h
index a1d538d2b7..c52d3d1620 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -418,13 +418,15 @@ typedef struct CONVERTER {
     int code_types[ET_special_unit_element+1];
     char *pre_class_types[ET_special_unit_element+1];
     FORMATTING_REFERENCE
-           formatting_references[FR_format_translate_message_string+1];
+       formatting_references[FR_format_translate_message_string+1];
     FORMATTING_REFERENCE
-           css_string_formatting_references[CSSFR_format_protect_text+1];
+       css_string_formatting_references[FR_format_translate_message_string+1];
     FORMATTING_REFERENCE commands_open[BUILTIN_CMD_NUMBER];
     FORMATTING_REFERENCE commands_conversion[BUILTIN_CMD_NUMBER];
+    FORMATTING_REFERENCE css_string_commands_conversion[BUILTIN_CMD_NUMBER];
     FORMATTING_REFERENCE types_open[ET_special_unit_element+1];
     FORMATTING_REFERENCE types_conversion[ET_special_unit_element+1];
+    FORMATTING_REFERENCE 
css_string_types_conversion[ET_special_unit_element+1];
     FORMATTING_REFERENCE output_units_conversion[OU_special_unit+1];
 
     /* state only in C converter */
@@ -441,6 +443,11 @@ typedef struct CONVERTER {
     size_t *output_unit_file_indices;   /* array of indices in 
output_unit_files
               each position corresponding to an output unit. */
     size_t *special_unit_file_indices;  /* same for special output units */
+    /* next three allow to switch from normal HTML formatting to css strings
+       formatting */
+    FORMATTING_REFERENCE *current_formatting_references;
+    FORMATTING_REFERENCE *current_commands_conversion;
+    FORMATTING_REFERENCE *current_types_conversion;
 
     /* state common with perl converter */
     int document_global_context;
diff --git a/tp/Texinfo/XS/main/get_perl_info.c 
b/tp/Texinfo/XS/main/get_perl_info.c
index 69113c4009..b742c2fb2f 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -411,31 +411,48 @@ set_translated_commands (CONVERTER *converter, HV *hv_in)
     }
 }
 
-
-static void
-register_formatting_reference_with_default (char *type_string,
+static SV **
+register_formatting_reference_default (char *type_string,
                 FORMATTING_REFERENCE *formatting_reference,
-                const char *ref_name, HV *default_hv, HV *customized_hv)
+                const char *ref_name, HV *default_hv)
 {
   SV **default_formatting_reference_sv;
-  SV **formatting_reference_sv;
 
   dTHX;
 
   default_formatting_reference_sv
    = hv_fetch (default_hv, ref_name, strlen (ref_name), 0);
-  formatting_reference_sv
-    = hv_fetch (customized_hv, ref_name, strlen (ref_name), 0);
+
   if (default_formatting_reference_sv)
     {
       if (SvOK (*default_formatting_reference_sv))
         {
           formatting_reference->sv_default = *default_formatting_reference_sv;
+          /* will be replaced by customization if there are not only defaults 
*/
+          formatting_reference->sv_reference = 
*default_formatting_reference_sv;
           formatting_reference->status = FRS_status_default_set;
         }
       else
         formatting_reference->status = FRS_status_ignored;
     }
+  return default_formatting_reference_sv;
+}
+
+static void
+register_formatting_reference_with_default (char *type_string,
+                FORMATTING_REFERENCE *formatting_reference,
+                const char *ref_name, HV *default_hv, HV *customized_hv)
+{
+  SV **default_formatting_reference_sv;
+  SV **formatting_reference_sv;
+
+  dTHX;
+
+  default_formatting_reference_sv = register_formatting_reference_default(
+                 type_string, formatting_reference, ref_name, default_hv);
+
+  formatting_reference_sv
+    = hv_fetch (customized_hv, ref_name, strlen (ref_name), 0);
   if (formatting_reference_sv)
     {
       if SvOK (*formatting_reference_sv)
@@ -460,8 +477,10 @@ html_converter_initialize_sv (SV *sv_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)
 {
   int i;
@@ -470,8 +489,10 @@ html_converter_initialize_sv (SV *sv_in, SV 
*default_formatting_references,
   HV *default_css_string_formatting_references_hv;
   HV *default_commands_open_hv;
   HV *default_commands_conversion_hv;
+  HV *default_css_string_commands_conversion_hv;
   HV *default_types_open_hv;
   HV *default_types_conversion_hv;
+  HV *default_css_string_types_conversion_hv;
   HV *default_output_units_conversion_hv;
   SV **converter_init_conf_sv;
   SV **converter_sv;
@@ -543,7 +564,7 @@ html_converter_initialize_sv (SV *sv_in, SV 
*default_formatting_references,
                     strlen (ref_name), 0);
       SV **formatting_reference_sv
         = hv_fetch (formatting_function_hv, ref_name, strlen (ref_name), 0);
-      /* no check, all should exist */
+      /* no check for existence, all should exist */
       if (SvOK (*default_formatting_reference_sv))
         {
           formatting_reference->sv_default = *default_formatting_reference_sv;
@@ -563,11 +584,16 @@ html_converter_initialize_sv (SV *sv_in, SV 
*default_formatting_references,
         fprintf (stderr, "BUG: formatting reference %s not found\n",
                          ref_name);
     }
-  for (i = 0; i < CSSFR_format_protect_text+1; i++)
+
+  /* copy the normal formatting references and replace the css strings
+     specific references */
+  memcpy (&converter->css_string_formatting_references,
+          &converter->formatting_references,
+      (FR_format_translate_message_string+1) * sizeof (FORMATTING_REFERENCE));
+
+  for (i = 0; i < FR_format_translate_message_string+1; i++)
     {
-      char *ref_name = html_css_string_formatting_reference_names[i];
-      FORMATTING_REFERENCE *formatting_reference
-        = &converter->css_string_formatting_references[i];
+      char *ref_name = html_formatting_reference_names[i];
       SV **default_formatting_reference_sv
         = hv_fetch (default_css_string_formatting_references_hv, ref_name,
                     strlen (ref_name), 0);
@@ -576,15 +602,14 @@ html_converter_initialize_sv (SV *sv_in, SV 
*default_formatting_references,
       if (default_formatting_reference_sv
           && SvOK (*default_formatting_reference_sv))
         {
+          FORMATTING_REFERENCE *formatting_reference
+            = &converter->css_string_formatting_references[i];
           formatting_reference->sv_default = *default_formatting_reference_sv;
           formatting_reference->sv_reference = 
*default_formatting_reference_sv;
+          formatting_reference->status = FRS_status_default_set;
         }
-      else
-        fprintf (stderr, "BUG: css formatting reference %s not found\n",
-                         ref_name);
     }
 
-
   FETCH(commands_open)
   commands_open_hv = (HV *)SvRV (*commands_open_sv);
   default_commands_open_hv = (HV *)SvRV (default_commands_open);
@@ -614,6 +639,30 @@ html_converter_initialize_sv (SV *sv_in, SV 
*default_formatting_references,
         commands_conversion_hv);
     }
 
+  default_css_string_commands_conversion_hv
+    = (HV *)SvRV (default_css_string_commands_conversion);
+  /* copy the normal formatting references and replace the css strings
+     specific references */
+  memcpy (&converter->css_string_commands_conversion,
+          &converter->commands_conversion,
+      (BUILTIN_CMD_NUMBER) * sizeof (FORMATTING_REFERENCE));
+
+  for (i = 0; i < BUILTIN_CMD_NUMBER; i++)
+    {
+      char *ref_name;
+      if (i == 0)
+        ref_name = "";
+      else
+        ref_name = builtin_command_data[i].cmdname;
+
+     FORMATTING_REFERENCE *conversion_formatting_reference
+       = &converter->css_string_commands_conversion[i];
+
+     register_formatting_reference_default ("css_command_conversion",
+        conversion_formatting_reference, ref_name,
+        default_css_string_commands_conversion_hv);
+    }
+
 
   FETCH(types_open)
   types_open_hv = (HV *)SvRV (*types_open_sv);
@@ -644,6 +693,29 @@ html_converter_initialize_sv (SV *sv_in, SV 
*default_formatting_references,
         types_conversion_hv);
     }
 
+  default_css_string_types_conversion_hv
+     = (HV *)SvRV (default_css_string_types_conversion);
+  /* copy the normal formatting references and replace the css strings
+     specific references */
+  memcpy (&converter->css_string_types_conversion,
+          &converter->types_conversion,
+      (ET_special_unit_element+1) * sizeof (FORMATTING_REFERENCE));
+  for (i = 0; i < ET_special_unit_element+1; i++)
+    {
+      char *ref_name;
+      if (i == 0)
+        ref_name = "";
+      else
+        ref_name = element_type_names[i];
+      FORMATTING_REFERENCE *conversion_formatting_reference
+       = &converter->css_string_types_conversion[i];
+
+      register_formatting_reference_default ("css_type_conversion",
+        conversion_formatting_reference, ref_name,
+        default_css_string_types_conversion_hv);
+    }
+
+
   FETCH(output_units_conversion)
   output_units_conversion_hv = (HV *)SvRV (*output_units_conversion_sv);
   default_output_units_conversion_hv
diff --git a/tp/Texinfo/XS/main/get_perl_info.h 
b/tp/Texinfo/XS/main/get_perl_info.h
index c88d5a6bed..2840d12a43 100644
--- a/tp/Texinfo/XS/main/get_perl_info.h
+++ b/tp/Texinfo/XS/main/get_perl_info.h
@@ -23,9 +23,12 @@ int html_converter_initialize_sv (SV *sv_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);
+
 CONVERTER *set_output_converter_sv (SV *sv_in, char *warn_string);
 CONVERTER *get_sv_converter (SV *sv_in, char *warn_string);
 



reply via email to

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