texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/convert/get_html_perl_info.c, tp


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/convert/get_html_perl_info.c, tp/Texinfo/XS/convert/html_conversion_state.c (html_get_css_info_spec): move from get_html_perl_info.c to html_conversion_state.c.
Date: Fri, 04 Oct 2024 07:06:02 -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 80df9a562a * tp/Texinfo/XS/convert/get_html_perl_info.c, 
tp/Texinfo/XS/convert/html_conversion_state.c (html_get_css_info_spec): move 
from get_html_perl_info.c to html_conversion_state.c.
80df9a562a is described below

commit 80df9a562a7b69fae10cdaeb4b553afbba1d59ae
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Aug 14 08:55:22 2024 +0200

    * tp/Texinfo/XS/convert/get_html_perl_info.c,
    tp/Texinfo/XS/convert/html_conversion_state.c
    (html_get_css_info_spec): move from get_html_perl_info.c to
    html_conversion_state.c.
    
    * tp/Texinfo/XS/convert/convert_html.c,
    tp/Texinfo/XS/convert/html_conversion_state.c (css_info_type_names)
    (count_elements_in_filename_type_names, push_html_formatting_context)
    (pop_html_formatting_context, html_new_document_context)
    (html_pop_document_context, html_open_command_update_context)
    (html_convert_command_update_context, html_open_type_update_context)
    (html_convert_type_update_context, html_set_multiple_conversions)
    (html_unset_multiple_conversions, find_explained_command_string)
    (register_explained_command_string, source_info_id)
    (html_check_htmlxref_already_warned)
    (initialize_css_selector_style_list): move from convert_html.c
    to html_conversion_state.c.
---
 ChangeLog                                     |  20 ++
 tp/Texinfo/XS/convert/convert_html.c          | 455 ------------------------
 tp/Texinfo/XS/convert/convert_html.h          |  47 +--
 tp/Texinfo/XS/convert/get_html_perl_info.c    |  17 +-
 tp/Texinfo/XS/convert/get_html_perl_info.h    |   2 -
 tp/Texinfo/XS/convert/html_conversion_state.c | 476 ++++++++++++++++++++++++++
 tp/Texinfo/XS/convert/html_conversion_state.h |  51 ++-
 7 files changed, 547 insertions(+), 521 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f471610306..66c4731179 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,26 @@
        html_register_opened_section_level and
        html_close_registered_sections_level.
 
+2024-08-14  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/get_html_perl_info.c,
+       tp/Texinfo/XS/convert/html_conversion_state.c
+       (html_get_css_info_spec): move from get_html_perl_info.c to
+       html_conversion_state.c.
+
+       * tp/Texinfo/XS/convert/convert_html.c,
+       tp/Texinfo/XS/convert/html_conversion_state.c (css_info_type_names)
+       (count_elements_in_filename_type_names, push_html_formatting_context)
+       (pop_html_formatting_context, html_new_document_context)
+       (html_pop_document_context, html_open_command_update_context)
+       (html_convert_command_update_context, html_open_type_update_context)
+       (html_convert_type_update_context, html_set_multiple_conversions)
+       (html_unset_multiple_conversions, find_explained_command_string)
+       (register_explained_command_string, source_info_id)
+       (html_check_htmlxref_already_warned)
+       (initialize_css_selector_style_list): move from convert_html.c
+       to html_conversion_state.c.
+
 2024-08-14  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/Makefile.am (libtexinfo_convert_la_SOURCES),
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 749d6bd492..f4225e805d 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -153,9 +153,6 @@ static enum element_type ignored_types[] = {
 };
 
 
-const char *count_elements_in_filename_type_names[] = {
- "total", "remaining", "current"};
-
 const char *html_global_unit_direction_names[] = {
   #define hgdt_name(name) #name,
    HTML_GLOBAL_DIRECTIONS_LIST
@@ -205,11 +202,6 @@ const char 
*htmlxref_split_type_names[htmlxref_split_type_chapter + 1] =
   "mono", "node", "section", "chapter"
 };
 
-const char *css_info_type_names[] =
-{
-  "element_classes", "imports", "rules"
-};
-
 const enum htmlxref_split_type htmlxref_entries[htmlxref_split_type_chapter + 
1][htmlxref_split_type_chapter + 1] = {
  { htmlxref_split_type_mono, htmlxref_split_type_chapter, 
htmlxref_split_type_section, htmlxref_split_type_node },
  { htmlxref_split_type_node, htmlxref_split_type_section, 
htmlxref_split_type_chapter, htmlxref_split_type_mono },
@@ -2186,103 +2178,6 @@ url_protect_file_text (CONVERTER *self, const char 
*input_string)
   return (result.text);
 }
 
-static void
-push_html_formatting_context (HTML_FORMATTING_CONTEXT_STACK *stack,
-                              char *context_name)
-{
-  if (stack->top >= stack->space)
-    {
-      stack->stack
-        = realloc (stack->stack,
-                   (stack->space += 5) * sizeof (HTML_FORMATTING_CONTEXT));
-    }
-
-  memset (&stack->stack[stack->top], 0, sizeof (HTML_FORMATTING_CONTEXT));
-
-  stack->stack[stack->top].context_name = strdup (context_name);
-
-  stack->top++;
-}
-
-static void
-pop_html_formatting_context (HTML_FORMATTING_CONTEXT_STACK *stack)
-{
-  if (stack->top == 0)
-    fatal ("HTML formatting context stack empty");
-
-  free (stack->stack[stack->top - 1].context_name);
-  stack->top--;
-}
-
-void
-html_new_document_context (CONVERTER *self,
-        const char *context_name, const char *document_global_context,
-        enum command_id block_command)
-{
-  HTML_DOCUMENT_CONTEXT_STACK *stack = &self->html_document_context;
-  HTML_DOCUMENT_CONTEXT *doc_context;
-
-  if (stack->top >= stack->space)
-    {
-      stack->stack
-        = realloc (stack->stack,
-                   (stack->space += 5) * sizeof (HTML_DOCUMENT_CONTEXT));
-    }
-
-  doc_context = &stack->stack[stack->top];
-  memset (doc_context, 0, sizeof (HTML_DOCUMENT_CONTEXT));
-  doc_context->context = strdup (context_name);
-  if (document_global_context)
-    doc_context->document_global_context = strdup (document_global_context);
-
-  push_integer_stack_integer (&doc_context->monospace, 0);
-  push_integer_stack_integer (&doc_context->preformatted_context, 0);
-  push_command_or_type (&doc_context->composition_context, 0, 0);
-  if (block_command)
-    push_command (&doc_context->block_commands, block_command);
-
-  if (document_global_context)
-    {
-      self->document_global_context++;
-    }
-
-  push_html_formatting_context (&doc_context->formatting_context,
-                                "_format");
-
-  stack->top++;
-}
-
-void
-html_pop_document_context (CONVERTER *self)
-{
-  HTML_DOCUMENT_CONTEXT_STACK *stack = &self->html_document_context;
-  HTML_DOCUMENT_CONTEXT *document_ctx;
-
-  if (stack->top == 0)
-    fatal ("HTML document context stack empty for pop");
-
-  document_ctx = &stack->stack[stack->top -1];
-
-  free (document_ctx->context);
-  free (document_ctx->document_global_context);
-  free (document_ctx->monospace.stack);
-  free (document_ctx->preformatted_context.stack);
-  free (document_ctx->composition_context.stack);
-  free (document_ctx->preformatted_classes.stack);
-  if (document_ctx->block_commands.top > 0)
-    pop_command (&document_ctx->block_commands);
-  free (document_ctx->block_commands.stack);
-  pop_html_formatting_context (&document_ctx->formatting_context);
-  free (document_ctx->formatting_context.stack);
-
-  if (document_ctx->document_global_context)
-    {
-      self->document_global_context--;
-    }
-
-  stack->top--;
-}
-
 /* returned string to be freed by the caller */
 char *
 html_convert_tree (CONVERTER *self, const ELEMENT *tree,
@@ -2296,20 +2191,6 @@ html_convert_tree (CONVERTER *self, const ELEMENT *tree,
   return result.text;
 }
 
-void
-html_set_multiple_conversions (CONVERTER *self, const char *multiple_pass)
-{
-  self->multiple_conversions++;
-  push_string_stack_string (&self->multiple_pass, multiple_pass);
-}
-
-void
-html_unset_multiple_conversions (CONVERTER *self)
-{
-  self->multiple_conversions--;
-  pop_string_stack (&self->multiple_pass);
-}
-
 /* Call convert_tree out of the main conversion flow.
  */
 char *
@@ -2549,55 +2430,6 @@ find_htmlxref_manual
   return result;
 }
 
-/* to be freed by caller */
-static char *
-source_info_id (const SOURCE_INFO *source_info)
-{
-  TEXT result;
-
-  text_init (&result);
-  if (source_info->file_name)
-    text_append (&result, source_info->file_name);
-  text_append_n (&result, "-", 1);
-  if (source_info->macro)
-    text_append (&result, source_info->macro);
-  text_append_n (&result, "-", 1);
-  text_printf (&result, "%d", source_info->line_nr);
-  return result.text;
-}
-
-size_t
-html_check_htmlxref_already_warned (CONVERTER *self, const char *manual_name,
-                                    const SOURCE_INFO *source_info)
-{
-  STRING_LIST *htmlxref_warned_list
-    = &self->check_htmlxref_already_warned;
-  char *node_manual_key;
-  char *info_id;
-  size_t entry_nr;
-
-  if (source_info)
-    info_id = source_info_id (source_info);
-  else
-    info_id = strdup ("UNDEF");
-
-  xasprintf (&node_manual_key, "%s-%s", info_id, manual_name);
-  free (info_id);
-
-  entry_nr = find_string (htmlxref_warned_list, node_manual_key);
-
-  if (entry_nr)
-    {
-      free (node_manual_key);
-      return entry_nr;
-    }
-
-  add_string (node_manual_key, htmlxref_warned_list);
-  free (node_manual_key);
-
-  return 0;
-}
-
 char *
 external_node_href (CONVERTER *self, const ELEMENT *external_node,
                     const ELEMENT *source_command) /* for messages only */
@@ -8435,51 +8267,6 @@ convert_email_command (CONVERTER *self, const enum 
command_id cmd,
     }
 }
 
-EXPLAINED_COMMAND_TYPE *
-find_explained_command_string (
-                      const EXPLAINED_COMMAND_TYPE_LIST *type_explanations,
-                               const enum command_id cmd, const char *type)
-{
-  size_t i;
-  for (i = 0; i < type_explanations->number; i++)
-    {
-      EXPLAINED_COMMAND_TYPE *type_explanation = &type_explanations->list[i];
-      if (type_explanation->cmd == cmd
-          && !strcmp (type_explanation->type, type))
-        return type_explanation;
-    }
-  return 0;
-}
-
-void
-register_explained_command_string (
-               EXPLAINED_COMMAND_TYPE_LIST *type_explanations,
-                    const enum command_id cmd,
-                    const char *type, const char *explanation)
-{
-  EXPLAINED_COMMAND_TYPE *type_explanation
-    = find_explained_command_string (type_explanations, cmd, type);
-  if (!type_explanation)
-    {
-      if (type_explanations->number == type_explanations->space)
-        {
-          type_explanations->list
-           = realloc (type_explanations->list,
-            sizeof (EXPLAINED_COMMAND_TYPE) * (type_explanations->space += 5));
-        }
-      type_explanation = &type_explanations->list[type_explanations->number];
-      type_explanation->cmd = cmd;
-      type_explanation->type = strdup (type);
-
-      type_explanation = &type_explanations->list[type_explanations->number];
-      type_explanations->number++;
-    }
-  else
-    free (type_explanation->explanation);
-
-  type_explanation->explanation = strdup (explanation);
-}
-
 void
 convert_explained_command (CONVERTER *self, const enum command_id cmd,
                     const ELEMENT *element,
@@ -16450,16 +16237,6 @@ initialize_jslicense_files (JSLICENSE_FILE_INFO_LIST 
*jslicences_files_info,
   jslicences_files_info->number = size;
 }
 
-void
-initialize_css_selector_style_list (CSS_SELECTOR_STYLE_LIST *selector_styles,
-                                    size_t size)
-{
-  selector_styles->list = (CSS_SELECTOR_STYLE *)
-        malloc (size * sizeof (CSS_SELECTOR_STYLE));
-  selector_styles->space = size;
-  selector_styles->number = size;
-}
-
 HTML_DIRECTION_STRING_TRANSLATED *
 new_directions_strings_translated_type (int nr_string_directions)
 {
@@ -19316,238 +19093,6 @@ destroy_args_formatted (HTML_ARGS_FORMATTED 
*args_formatted)
 }
 
 
-int
-html_open_command_update_context (CONVERTER *self, enum command_id data_cmd)
-{
-  int convert_to_latex = 0;
-  int preformatted = 0;
-
-  HTML_DOCUMENT_CONTEXT *top_document_ctx;
-  HTML_FORMATTING_CONTEXT *top_formating_ctx;
-
-  if (builtin_command_data[data_cmd].flags & CF_brace
-      && builtin_command_data[data_cmd].data == BRACE_context)
-    {
-      html_new_document_context (self,
-                       builtin_command_data[data_cmd].cmdname, 0, 0);
-
-    }
-  top_document_ctx = html_top_document_context (self);
-
-  if (html_commands_data[data_cmd].flags & HF_format_context)
-    {
-      char *context_str;
-      xasprintf (&context_str, "@%s",
-                 builtin_command_data[data_cmd].cmdname);
-      push_html_formatting_context (
-                 &top_document_ctx->formatting_context,
-                 context_str);
-      free (context_str);
-    }
-
-  top_formating_ctx
-    = html_top_formatting_context (&top_document_ctx->formatting_context);
-
-  if (builtin_command_data[data_cmd].flags & CF_block)
-    {
-      push_command (&top_document_ctx->block_commands, data_cmd);
-    }
-
-  if (html_commands_data[data_cmd].flags & HF_pre_class)
-    {
-      push_command_or_type (&top_document_ctx->preformatted_classes,
-                            html_commands_data[data_cmd].pre_class_cmd, 0);
-      if (builtin_command_data[data_cmd].flags & CF_preformatted)
-        {
-          preformatted = 1;
-          top_document_ctx->inside_preformatted++;
-        }
-      else if (builtin_command_data[data_cmd].data == BLOCK_menu
-               && top_document_ctx->inside_preformatted)
-        preformatted = 1;
-    }
-
-  if (html_commands_data[data_cmd].flags & HF_composition_context)
-    {
-      push_command_or_type (&top_document_ctx->composition_context,
-                            data_cmd, 0);
-      push_integer_stack_integer (&top_document_ctx->preformatted_context,
-                                preformatted);
-    }
-
-  if (html_commands_data[data_cmd].flags & HF_format_raw)
-    {
-      top_document_ctx->raw_ctx++;
-    }
-  else if (data_cmd == CM_verbatim)
-    {
-      top_document_ctx->verbatim_ctx++;
-    }
-
-  if (builtin_command_data[data_cmd].other_flags & CF_brace_code
-      || builtin_command_data[data_cmd].flags & CF_preformatted_code)
-    {
-      push_integer_stack_integer (&top_document_ctx->monospace, 1);
-    }
-  else if (builtin_command_data[data_cmd].flags & CF_brace
-           && builtin_command_data[data_cmd].data == BRACE_style_no_code)
-    {
-      push_integer_stack_integer (&top_document_ctx->monospace, 0);
-    }
-  else if (self->upper_case[data_cmd])
-    {
-      top_formating_ctx->upper_case_ctx++;
-    }
-  else if (builtin_command_data[data_cmd].flags & CF_math)
-    {
-      top_document_ctx->math_ctx++;
-      if (self->conf->CONVERT_TO_LATEX_IN_MATH.o.integer > 0)
-        convert_to_latex = 1;
-    }
-  if (data_cmd == CM_verb)
-    {
-      top_formating_ctx->space_protected++;
-    }
-  else if (data_cmd == CM_w)
-    {
-      top_formating_ctx->no_break++;
-    }
-  return convert_to_latex;
-}
-
-void
-html_convert_command_update_context (CONVERTER *self, enum command_id data_cmd)
-{
-  HTML_DOCUMENT_CONTEXT *top_document_ctx;
-  HTML_FORMATTING_CONTEXT *top_formating_ctx;
-
-  top_document_ctx = html_top_document_context (self);
-
-  top_formating_ctx
-    = html_top_formatting_context (&top_document_ctx->formatting_context);
-
-  if (html_commands_data[data_cmd].flags & HF_composition_context)
-    {
-      pop_command_or_type (&top_document_ctx->composition_context);
-      pop_integer_stack (&top_document_ctx->preformatted_context);
-    }
-
-  if (html_commands_data[data_cmd].flags & HF_pre_class)
-    {
-      pop_command_or_type (&top_document_ctx->preformatted_classes);
-      if (builtin_command_data[data_cmd].flags & CF_preformatted)
-        top_document_ctx->inside_preformatted--;
-    }
-
-  if (data_cmd == CM_verb)
-    {
-      top_formating_ctx->space_protected--;
-    }
-  else if (data_cmd == CM_w)
-    {
-      top_formating_ctx->no_break--;
-    }
-
-  if (builtin_command_data[data_cmd].flags & CF_preformatted_code
-      || (builtin_command_data[data_cmd].flags & CF_brace
-          && builtin_command_data[data_cmd].data == BRACE_style_no_code)
-      || builtin_command_data[data_cmd].other_flags & CF_brace_code)
-    {
-      pop_integer_stack (&top_document_ctx->monospace);
-    }
-  else if (self->upper_case[data_cmd])
-    {
-      top_formating_ctx->upper_case_ctx--;
-    }
-  else if (builtin_command_data[data_cmd].flags & CF_math)
-    {
-      top_document_ctx->math_ctx--;
-    }
-
-  if (html_commands_data[data_cmd].flags & HF_format_raw)
-    {
-      top_document_ctx->raw_ctx--;
-    }
-  else if (data_cmd == CM_verbatim)
-    {
-      top_document_ctx->verbatim_ctx--;
-    }
-
-  if (builtin_command_data[data_cmd].flags & CF_block)
-    {
-      pop_command (&top_document_ctx->block_commands);
-    }
-
-  if (html_commands_data[data_cmd].flags & HF_format_context)
-    {
-      pop_html_formatting_context (
-                 &top_document_ctx->formatting_context);
-    }
-
-  if (builtin_command_data[data_cmd].flags & CF_brace
-      && builtin_command_data[data_cmd].data == BRACE_context)
-    {
-      html_pop_document_context (self);
-    }
-}
-
-void
-html_open_type_update_context (CONVERTER *self, enum element_type type)
-{
-  HTML_DOCUMENT_CONTEXT *top_document_ctx = html_top_document_context (self);
-  HTML_FORMATTING_CONTEXT *top_formating_ctx
-    = html_top_formatting_context (&top_document_ctx->formatting_context);
-
-  if (type == ET_paragraph)
-    {
-      top_formating_ctx->paragraph_number++;
-    }
-  else if (type == ET_preformatted || type == ET_rawpreformatted)
-    {
-      top_formating_ctx->preformatted_number++;
-    }
-  else if (self->pre_class_types[type])
-    {
-      push_command_or_type (&top_document_ctx->preformatted_classes, 0, type);
-      push_command_or_type (&top_document_ctx->composition_context,
-                            0, type);
-      push_integer_stack_integer (&top_document_ctx->preformatted_context, 1);
-    }
-
-  if (self->code_types[type])
-    {
-      push_integer_stack_integer (&top_document_ctx->monospace, 1);
-    }
-
-  if (type == ET__string)
-    {
-      top_document_ctx->string_ctx++;
-    }
-}
-
-void
-html_convert_type_update_context (CONVERTER *self, enum element_type type)
-{
-  HTML_DOCUMENT_CONTEXT *top_document_ctx = html_top_document_context (self);
-
-  if (self->code_types[type])
-    {
-      pop_integer_stack (&top_document_ctx->monospace);
-    }
-
-  if (type == ET__string)
-    {
-      top_document_ctx->string_ctx--;
-    }
-
-  if (self->pre_class_types[type])
-    {
-      pop_command_or_type (&top_document_ctx->preformatted_classes);
-      pop_command_or_type (&top_document_ctx->composition_context);
-      pop_integer_stack (&top_document_ctx->preformatted_context);
-    }
-}
-
 #define ADD(x) text_append (result, x)
 
 char *
diff --git a/tp/Texinfo/XS/convert/convert_html.h 
b/tp/Texinfo/XS/convert/convert_html.h
index 8b3d7ac12d..aca9adff5e 100644
--- a/tp/Texinfo/XS/convert/convert_html.h
+++ b/tp/Texinfo/XS/convert/convert_html.h
@@ -20,13 +20,9 @@ extern const TRANSLATED_SUI_ASSOCIATION 
translated_special_unit_info[];
 extern const char *special_unit_info_type_names[SUI_type_heading + 1];
 extern const char *htmlxref_split_type_names[htmlxref_split_type_chapter + 1];
 
-extern const char *css_info_type_names[];
-
 extern const char *direction_string_type_names[];
 extern const char *direction_string_context_names[];
 
-extern const char *count_elements_in_filename_type_names[];
-
 extern const char *html_stage_handler_stage_type_names[];
 extern COMMAND_ID_LIST no_arg_formatted_cmd;
 
@@ -53,9 +49,6 @@ void initialize_js_categories_list (JSLICENSE_CATEGORY_LIST 
*js_files_info,
 void initialize_jslicense_files
                        (JSLICENSE_FILE_INFO_LIST *jslicences_files_info,
                                  const char *category, size_t size);
-void initialize_css_selector_style_list
-                   (CSS_SELECTOR_STYLE_LIST *selector_styles,
-                                         size_t size);
 HTML_DIRECTION_STRING_TRANSLATED *new_directions_strings_translated_type
   (int nr_string_directions);
 char ***new_directions_strings_type (int nr_string_directions,
@@ -71,32 +64,6 @@ SPECIAL_UNIT_INFO *html_add_special_unit_info (
 int html_id_is_registered (CONVERTER *self, const char *string);
 void html_register_id (CONVERTER *self, const char *string);
 
-int html_open_command_update_context (CONVERTER *self,
-                                      enum command_id data_cmd);
-void html_convert_command_update_context (CONVERTER *self,
-                                          enum command_id data_cmd);
-void html_open_type_update_context (CONVERTER *self,
-                                    enum element_type type);
-void html_convert_type_update_context (CONVERTER *self, enum element_type 
type);
-void html_new_document_context (CONVERTER *self,
-        const char *context_name, const char *document_global_context,
-        enum command_id block_command);
-void html_pop_document_context (CONVERTER *self);
-void html_set_code_context (CONVERTER *self, int code);
-void html_pop_code_context (CONVERTER *self);
-void html_set_string_context (CONVERTER *self);
-void html_unset_string_context (CONVERTER *self);
-void html_set_raw_context (CONVERTER *self);
-void html_unset_raw_context (CONVERTER *self);
-void html_set_multiple_conversions (CONVERTER *self, const char 
*multiple_pass);
-void html_unset_multiple_conversions (CONVERTER *self);
-
-char *debug_print_html_contexts (const CONVERTER *self);
-
-size_t html_count_elements_in_filename (const CONVERTER *self,
-                 enum count_elements_in_filename_type type,
-                 const char *filename);
-
 int html_special_unit_variety_direction_index (const CONVERTER *self,
                                         const char *special_unit_variety);
 
@@ -129,24 +96,12 @@ char *html_internal_command_text (CONVERTER *self, const 
ELEMENT *command,
 char *html_command_description (CONVERTER *self, const ELEMENT *command,
                                 const enum html_text_type type);
 
-EXPLAINED_COMMAND_TYPE *find_explained_command_string
-                      (const EXPLAINED_COMMAND_TYPE_LIST *type_explanations,
-                               const enum command_id cmd, const char *type);
-void register_explained_command_string (
-               EXPLAINED_COMMAND_TYPE_LIST *type_explanations,
-                    const enum command_id cmd,
-                    const char *type, const char *explanation);
-
 FOOTNOTE_ID_NUMBER *find_footnote_id_number (const CONVERTER *self,
                                            const char *footnote_id);
 
 char *html_attribute_class (CONVERTER *self, const char *element,
                             const STRING_LIST *classes);
 
-size_t html_check_htmlxref_already_warned (CONVERTER *self,
-                                           const char *manual_name,
-                                           const SOURCE_INFO *source_info);
-
 void html_prepare_conversion_units (CONVERTER *self);
 
 void html_prepare_conversion_units_targets (CONVERTER *self,
@@ -170,6 +125,8 @@ int html_prepare_converted_output_info (CONVERTER *self,
 void html_prepare_title_titlepage (CONVERTER *self, const char *output_file,
                                    const char *output_filename);
 
+char *debug_print_html_contexts (const CONVERTER *self);
+
 char *html_convert_convert (CONVERTER *self, const ELEMENT *root);
 char *html_convert_tree (CONVERTER *self, const ELEMENT *tree,
                          const char *explanation);
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c 
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index 9654b60315..e29a84ced8 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -43,6 +43,7 @@
 #include "convert_to_texinfo.h"
 #include "output_unit.h"
 #include "converter.h"
+#include "html_conversion_state.h"
 #include "convert_html.h"
 #include "get_perl_info.h"
 #include "get_converter_perl_info.h"
@@ -1903,19 +1904,3 @@ html_get_shared_conversion_state (CONVERTER *converter, 
SV *converter_in,
     return newSViv (converter->shared_conversion_state.in_skipped_node_top);
   return newSV (0);
 }
-
-enum css_info_type
-html_get_css_info_spec (const char *spec)
-{
-  int i;
-  enum css_info_type type = CI_css_info_element_classes;
-  for (i = 0; i < CI_css_info_rules +1; i++)
-    {
-      if (!strcmp (css_info_type_names[i], spec))
-        {
-          type = i;
-          break;
-        }
-    }
-  return type;
-}
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.h 
b/tp/Texinfo/XS/convert/get_html_perl_info.h
index 15dbf559c5..cc4943dc27 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.h
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.h
@@ -50,6 +50,4 @@ SV *html_get_shared_conversion_state (CONVERTER *converter, 
SV *converter_in,
                                const char *cmdname, const char *state_name,
                                const int args_nr, SV **args_sv);
 
-enum css_info_type html_get_css_info_spec (const char *spec);
-
 #endif
diff --git a/tp/Texinfo/XS/convert/html_conversion_state.c 
b/tp/Texinfo/XS/convert/html_conversion_state.c
index 29d1d9ad7f..a1b1f581e7 100644
--- a/tp/Texinfo/XS/convert/html_conversion_state.c
+++ b/tp/Texinfo/XS/convert/html_conversion_state.c
@@ -18,14 +18,356 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "text.h"
 #include "command_ids.h"
+#include "element_types.h"
 #include "converter_types.h"
 #include "html_converter_types.h"
 #include "command_stack.h"
+#include "builtin_commands.h"
 /* new_string_list add_string fatal */
 #include "utils.h"
 #include "html_conversion_state.h"
 
+/* enum css_info_type */
+static const char *css_info_type_names[] =
+{
+  "element_classes", "imports", "rules"
+};
+
+/* enum count_elements_in_filename_type */
+const char *count_elements_in_filename_type_names[] = {
+ "total", "remaining", "current"};
+
+
+static void
+push_html_formatting_context (HTML_FORMATTING_CONTEXT_STACK *stack,
+                              char *context_name)
+{
+  if (stack->top >= stack->space)
+    {
+      stack->stack
+        = realloc (stack->stack,
+                   (stack->space += 5) * sizeof (HTML_FORMATTING_CONTEXT));
+    }
+
+  memset (&stack->stack[stack->top], 0, sizeof (HTML_FORMATTING_CONTEXT));
+
+  stack->stack[stack->top].context_name = strdup (context_name);
+
+  stack->top++;
+}
+
+static void
+pop_html_formatting_context (HTML_FORMATTING_CONTEXT_STACK *stack)
+{
+  if (stack->top == 0)
+    fatal ("HTML formatting context stack empty");
+
+  free (stack->stack[stack->top - 1].context_name);
+  stack->top--;
+}
+
+void
+html_new_document_context (CONVERTER *self,
+        const char *context_name, const char *document_global_context,
+        enum command_id block_command)
+{
+  HTML_DOCUMENT_CONTEXT_STACK *stack = &self->html_document_context;
+  HTML_DOCUMENT_CONTEXT *doc_context;
+
+  if (stack->top >= stack->space)
+    {
+      stack->stack
+        = realloc (stack->stack,
+                   (stack->space += 5) * sizeof (HTML_DOCUMENT_CONTEXT));
+    }
+
+  doc_context = &stack->stack[stack->top];
+  memset (doc_context, 0, sizeof (HTML_DOCUMENT_CONTEXT));
+  doc_context->context = strdup (context_name);
+  if (document_global_context)
+    doc_context->document_global_context = strdup (document_global_context);
+
+  push_integer_stack_integer (&doc_context->monospace, 0);
+  push_integer_stack_integer (&doc_context->preformatted_context, 0);
+  push_command_or_type (&doc_context->composition_context, 0, 0);
+  if (block_command)
+    push_command (&doc_context->block_commands, block_command);
+
+  if (document_global_context)
+    {
+      self->document_global_context++;
+    }
+
+  push_html_formatting_context (&doc_context->formatting_context,
+                                "_format");
+
+  stack->top++;
+}
+
+void
+html_pop_document_context (CONVERTER *self)
+{
+  HTML_DOCUMENT_CONTEXT_STACK *stack = &self->html_document_context;
+  HTML_DOCUMENT_CONTEXT *document_ctx;
+
+  if (stack->top == 0)
+    fatal ("HTML document context stack empty for pop");
+
+  document_ctx = &stack->stack[stack->top -1];
+
+  free (document_ctx->context);
+  free (document_ctx->document_global_context);
+  free (document_ctx->monospace.stack);
+  free (document_ctx->preformatted_context.stack);
+  free (document_ctx->composition_context.stack);
+  free (document_ctx->preformatted_classes.stack);
+  if (document_ctx->block_commands.top > 0)
+    pop_command (&document_ctx->block_commands);
+  free (document_ctx->block_commands.stack);
+  pop_html_formatting_context (&document_ctx->formatting_context);
+  free (document_ctx->formatting_context.stack);
+
+  if (document_ctx->document_global_context)
+    {
+      self->document_global_context--;
+    }
+
+  stack->top--;
+}
+
+int
+html_open_command_update_context (CONVERTER *self, enum command_id data_cmd)
+{
+  int convert_to_latex = 0;
+  int preformatted = 0;
+
+  HTML_DOCUMENT_CONTEXT *top_document_ctx;
+  HTML_FORMATTING_CONTEXT *top_formating_ctx;
+
+  if (builtin_command_data[data_cmd].flags & CF_brace
+      && builtin_command_data[data_cmd].data == BRACE_context)
+    {
+      html_new_document_context (self,
+                       builtin_command_data[data_cmd].cmdname, 0, 0);
+
+    }
+  top_document_ctx = html_top_document_context (self);
+
+  if (html_commands_data[data_cmd].flags & HF_format_context)
+    {
+      char *context_str;
+      xasprintf (&context_str, "@%s",
+                 builtin_command_data[data_cmd].cmdname);
+      push_html_formatting_context (
+                 &top_document_ctx->formatting_context,
+                 context_str);
+      free (context_str);
+    }
+
+  top_formating_ctx
+    = html_top_formatting_context (&top_document_ctx->formatting_context);
+
+  if (builtin_command_data[data_cmd].flags & CF_block)
+    {
+      push_command (&top_document_ctx->block_commands, data_cmd);
+    }
+
+  if (html_commands_data[data_cmd].flags & HF_pre_class)
+    {
+      push_command_or_type (&top_document_ctx->preformatted_classes,
+                            html_commands_data[data_cmd].pre_class_cmd, 0);
+      if (builtin_command_data[data_cmd].flags & CF_preformatted)
+        {
+          preformatted = 1;
+          top_document_ctx->inside_preformatted++;
+        }
+      else if (builtin_command_data[data_cmd].data == BLOCK_menu
+               && top_document_ctx->inside_preformatted)
+        preformatted = 1;
+    }
+
+  if (html_commands_data[data_cmd].flags & HF_composition_context)
+    {
+      push_command_or_type (&top_document_ctx->composition_context,
+                            data_cmd, 0);
+      push_integer_stack_integer (&top_document_ctx->preformatted_context,
+                                preformatted);
+    }
+
+  if (html_commands_data[data_cmd].flags & HF_format_raw)
+    {
+      top_document_ctx->raw_ctx++;
+    }
+  else if (data_cmd == CM_verbatim)
+    {
+      top_document_ctx->verbatim_ctx++;
+    }
+
+  if (builtin_command_data[data_cmd].other_flags & CF_brace_code
+      || builtin_command_data[data_cmd].flags & CF_preformatted_code)
+    {
+      push_integer_stack_integer (&top_document_ctx->monospace, 1);
+    }
+  else if (builtin_command_data[data_cmd].flags & CF_brace
+           && builtin_command_data[data_cmd].data == BRACE_style_no_code)
+    {
+      push_integer_stack_integer (&top_document_ctx->monospace, 0);
+    }
+  else if (self->upper_case[data_cmd])
+    {
+      top_formating_ctx->upper_case_ctx++;
+    }
+  else if (builtin_command_data[data_cmd].flags & CF_math)
+    {
+      top_document_ctx->math_ctx++;
+      if (self->conf->CONVERT_TO_LATEX_IN_MATH.o.integer > 0)
+        convert_to_latex = 1;
+    }
+  if (data_cmd == CM_verb)
+    {
+      top_formating_ctx->space_protected++;
+    }
+  else if (data_cmd == CM_w)
+    {
+      top_formating_ctx->no_break++;
+    }
+  return convert_to_latex;
+}
+
+void
+html_convert_command_update_context (CONVERTER *self, enum command_id data_cmd)
+{
+  HTML_DOCUMENT_CONTEXT *top_document_ctx;
+  HTML_FORMATTING_CONTEXT *top_formating_ctx;
+
+  top_document_ctx = html_top_document_context (self);
+
+  top_formating_ctx
+    = html_top_formatting_context (&top_document_ctx->formatting_context);
+
+  if (html_commands_data[data_cmd].flags & HF_composition_context)
+    {
+      pop_command_or_type (&top_document_ctx->composition_context);
+      pop_integer_stack (&top_document_ctx->preformatted_context);
+    }
+
+  if (html_commands_data[data_cmd].flags & HF_pre_class)
+    {
+      pop_command_or_type (&top_document_ctx->preformatted_classes);
+      if (builtin_command_data[data_cmd].flags & CF_preformatted)
+        top_document_ctx->inside_preformatted--;
+    }
+
+  if (data_cmd == CM_verb)
+    {
+      top_formating_ctx->space_protected--;
+    }
+  else if (data_cmd == CM_w)
+    {
+      top_formating_ctx->no_break--;
+    }
+
+  if (builtin_command_data[data_cmd].flags & CF_preformatted_code
+      || (builtin_command_data[data_cmd].flags & CF_brace
+          && builtin_command_data[data_cmd].data == BRACE_style_no_code)
+      || builtin_command_data[data_cmd].other_flags & CF_brace_code)
+    {
+      pop_integer_stack (&top_document_ctx->monospace);
+    }
+  else if (self->upper_case[data_cmd])
+    {
+      top_formating_ctx->upper_case_ctx--;
+    }
+  else if (builtin_command_data[data_cmd].flags & CF_math)
+    {
+      top_document_ctx->math_ctx--;
+    }
+
+  if (html_commands_data[data_cmd].flags & HF_format_raw)
+    {
+      top_document_ctx->raw_ctx--;
+    }
+  else if (data_cmd == CM_verbatim)
+    {
+      top_document_ctx->verbatim_ctx--;
+    }
+
+  if (builtin_command_data[data_cmd].flags & CF_block)
+    {
+      pop_command (&top_document_ctx->block_commands);
+    }
+
+  if (html_commands_data[data_cmd].flags & HF_format_context)
+    {
+      pop_html_formatting_context (
+                 &top_document_ctx->formatting_context);
+    }
+
+  if (builtin_command_data[data_cmd].flags & CF_brace
+      && builtin_command_data[data_cmd].data == BRACE_context)
+    {
+      html_pop_document_context (self);
+    }
+}
+
+void
+html_open_type_update_context (CONVERTER *self, enum element_type type)
+{
+  HTML_DOCUMENT_CONTEXT *top_document_ctx = html_top_document_context (self);
+  HTML_FORMATTING_CONTEXT *top_formating_ctx
+    = html_top_formatting_context (&top_document_ctx->formatting_context);
+
+  if (type == ET_paragraph)
+    {
+      top_formating_ctx->paragraph_number++;
+    }
+  else if (type == ET_preformatted || type == ET_rawpreformatted)
+    {
+      top_formating_ctx->preformatted_number++;
+    }
+  else if (self->pre_class_types[type])
+    {
+      push_command_or_type (&top_document_ctx->preformatted_classes, 0, type);
+      push_command_or_type (&top_document_ctx->composition_context,
+                            0, type);
+      push_integer_stack_integer (&top_document_ctx->preformatted_context, 1);
+    }
+
+  if (self->code_types[type])
+    {
+      push_integer_stack_integer (&top_document_ctx->monospace, 1);
+    }
+
+  if (type == ET__string)
+    {
+      top_document_ctx->string_ctx++;
+    }
+}
+
+void
+html_convert_type_update_context (CONVERTER *self, enum element_type type)
+{
+  HTML_DOCUMENT_CONTEXT *top_document_ctx = html_top_document_context (self);
+
+  if (self->code_types[type])
+    {
+      pop_integer_stack (&top_document_ctx->monospace);
+    }
+
+  if (type == ET__string)
+    {
+      top_document_ctx->string_ctx--;
+    }
+
+  if (self->pre_class_types[type])
+    {
+      pop_command_or_type (&top_document_ctx->preformatted_classes);
+      pop_command_or_type (&top_document_ctx->composition_context);
+      pop_integer_stack (&top_document_ctx->preformatted_context);
+    }
+}
 
 static int
 compare_page_name_number (const void *a, const void *b)
@@ -297,6 +639,20 @@ html_in_multi_expanded (CONVERTER *self)
   return 0;
 }
 
+void
+html_set_multiple_conversions (CONVERTER *self, const char *multiple_pass)
+{
+  self->multiple_conversions++;
+  push_string_stack_string (&self->multiple_pass, multiple_pass);
+}
+
+void
+html_unset_multiple_conversions (CONVERTER *self)
+{
+  self->multiple_conversions--;
+  pop_string_stack (&self->multiple_pass);
+}
+
 void
 html_register_footnote (CONVERTER *self, const ELEMENT *command,
      const char *footid, const char *docid, int number_in_doc,
@@ -713,8 +1069,128 @@ html_close_registered_filename_sections_level (CONVERTER 
*self,
   return html_close_registered_sections_level (self, page_number, level);
 }
 
+EXPLAINED_COMMAND_TYPE *
+find_explained_command_string (
+                      const EXPLAINED_COMMAND_TYPE_LIST *type_explanations,
+                               const enum command_id cmd, const char *type)
+{
+  size_t i;
+  for (i = 0; i < type_explanations->number; i++)
+    {
+      EXPLAINED_COMMAND_TYPE *type_explanation = &type_explanations->list[i];
+      if (type_explanation->cmd == cmd
+          && !strcmp (type_explanation->type, type))
+        return type_explanation;
+    }
+  return 0;
+}
+
+void
+register_explained_command_string (
+               EXPLAINED_COMMAND_TYPE_LIST *type_explanations,
+                    const enum command_id cmd,
+                    const char *type, const char *explanation)
+{
+  EXPLAINED_COMMAND_TYPE *type_explanation
+    = find_explained_command_string (type_explanations, cmd, type);
+  if (!type_explanation)
+    {
+      if (type_explanations->number == type_explanations->space)
+        {
+          type_explanations->list
+           = realloc (type_explanations->list,
+            sizeof (EXPLAINED_COMMAND_TYPE) * (type_explanations->space += 5));
+        }
+      type_explanation = &type_explanations->list[type_explanations->number];
+      type_explanation->cmd = cmd;
+      type_explanation->type = strdup (type);
+
+      type_explanation = &type_explanations->list[type_explanations->number];
+      type_explanations->number++;
+    }
+  else
+    free (type_explanation->explanation);
+
+  type_explanation->explanation = strdup (explanation);
+}
+
+/* to be freed by caller */
+static char *
+source_info_id (const SOURCE_INFO *source_info)
+{
+  TEXT result;
+
+  text_init (&result);
+  if (source_info->file_name)
+    text_append (&result, source_info->file_name);
+  text_append_n (&result, "-", 1);
+  if (source_info->macro)
+    text_append (&result, source_info->macro);
+  text_append_n (&result, "-", 1);
+  text_printf (&result, "%d", source_info->line_nr);
+  return result.text;
+}
+
+size_t
+html_check_htmlxref_already_warned (CONVERTER *self, const char *manual_name,
+                                    const SOURCE_INFO *source_info)
+{
+  STRING_LIST *htmlxref_warned_list
+    = &self->check_htmlxref_already_warned;
+  char *node_manual_key;
+  char *info_id;
+  size_t entry_nr;
+
+  if (source_info)
+    info_id = source_info_id (source_info);
+  else
+    info_id = strdup ("UNDEF");
+
+  xasprintf (&node_manual_key, "%s-%s", info_id, manual_name);
+  free (info_id);
+
+  entry_nr = find_string (htmlxref_warned_list, node_manual_key);
+
+  if (entry_nr)
+    {
+      free (node_manual_key);
+      return entry_nr;
+    }
+
+  add_string (node_manual_key, htmlxref_warned_list);
+  free (node_manual_key);
+
+  return 0;
+}
+
 
 
+void
+initialize_css_selector_style_list (CSS_SELECTOR_STYLE_LIST *selector_styles,
+                                    size_t size)
+{
+  selector_styles->list = (CSS_SELECTOR_STYLE *)
+        malloc (size * sizeof (CSS_SELECTOR_STYLE));
+  selector_styles->space = size;
+  selector_styles->number = size;
+}
+
+enum css_info_type
+html_get_css_info_spec (const char *spec)
+{
+  int i;
+  enum css_info_type type = CI_css_info_element_classes;
+  for (i = 0; i < CI_css_info_rules +1; i++)
+    {
+      if (!strcmp (css_info_type_names[i], spec))
+        {
+          type = i;
+          break;
+        }
+    }
+  return type;
+}
+
 void
 html_css_add_info (CONVERTER *self, enum css_info_type type,
                    const char *css_info)
diff --git a/tp/Texinfo/XS/convert/html_conversion_state.h 
b/tp/Texinfo/XS/convert/html_conversion_state.h
index 3051591a79..474ec2dce1 100644
--- a/tp/Texinfo/XS/convert/html_conversion_state.h
+++ b/tp/Texinfo/XS/convert/html_conversion_state.h
@@ -4,9 +4,26 @@
 
 #include "html_converter_types.h"
 
+extern const char *count_elements_in_filename_type_names[];
+
+void html_new_document_context (CONVERTER *self,
+        const char *context_name, const char *document_global_context,
+        enum command_id block_command);
+void html_pop_document_context (CONVERTER *self);
+int html_open_command_update_context (CONVERTER *self,
+                                      enum command_id data_cmd);
+void html_convert_command_update_context (CONVERTER *self,
+                                          enum command_id data_cmd);
+void html_open_type_update_context (CONVERTER *self,
+                                    enum element_type type);
+void html_convert_type_update_context (CONVERTER *self, enum element_type 
type);
+
 size_t count_elements_in_file_number (const CONVERTER *self,
                  enum count_elements_in_filename_type type,
                  size_t file_number);
+size_t html_count_elements_in_filename (const CONVERTER *self,
+                 enum count_elements_in_filename_type type,
+                 const char *filename);
 
 int html_in_code (const CONVERTER *self);
 int html_in_math (const CONVERTER *self);
@@ -24,7 +41,17 @@ enum command_id html_top_block_command (const CONVERTER 
*self);
 const COMMAND_OR_TYPE_STACK *html_preformatted_classes_stack
                                     (const CONVERTER *self);
 enum command_id html_in_align (const CONVERTER *self);
+
+void html_set_code_context (CONVERTER *self, int code);
+void html_pop_code_context (CONVERTER *self);
+void html_set_string_context (CONVERTER *self);
+void html_unset_string_context (CONVERTER *self);
+void html_set_raw_context (CONVERTER *self);
+void html_unset_raw_context (CONVERTER *self);
+
 const char *html_in_multi_expanded (CONVERTER *self);
+void html_set_multiple_conversions (CONVERTER *self, const char 
*multiple_pass);
+void html_unset_multiple_conversions (CONVERTER *self);
 
 void html_register_footnote (CONVERTER *self, const ELEMENT *command,
      const char *footid, const char *docid, const int number_in_doc,
@@ -52,15 +79,32 @@ int html_get_file_information (const CONVERTER *self, const 
char *key,
                                const char *filename, int *status);
 
 void html_register_opened_section_level (CONVERTER *self, size_t file_number,
-                                    int level, const char *close_string);
+                                         int level, const char *close_string);
+STRING_LIST *html_close_registered_sections_level (CONVERTER *self,
+                                                   size_t file_number,
+                                                   int level);
 void html_register_opened_filename_section_level (CONVERTER *self,
                                              const char *filename,
                                          int level, const char *close_string);
-STRING_LIST *html_close_registered_sections_level (CONVERTER *self,
-                                      size_t file_number, int level);
 STRING_LIST *html_close_registered_filename_sections_level (CONVERTER *self,
                                       const char *filename, int level);
 
+EXPLAINED_COMMAND_TYPE *find_explained_command_string
+                      (const EXPLAINED_COMMAND_TYPE_LIST *type_explanations,
+                               const enum command_id cmd, const char *type);
+void register_explained_command_string (
+               EXPLAINED_COMMAND_TYPE_LIST *type_explanations,
+                    const enum command_id cmd,
+                    const char *type, const char *explanation);
+
+size_t html_check_htmlxref_already_warned (CONVERTER *self,
+                                           const char *manual_name,
+                                           const SOURCE_INFO *source_info);
+
+void initialize_css_selector_style_list
+                   (CSS_SELECTOR_STYLE_LIST *selector_styles,
+                                         size_t size);
+enum css_info_type html_get_css_info_spec (const char *spec);
 void html_css_add_info (CONVERTER *self, enum css_info_type type,
                         const char *css_info);
 const STRING_LIST *html_css_get_info (CONVERTER *self, enum css_info_type 
type);
@@ -77,4 +121,5 @@ const char *html_css_get_selector_style (CONVERTER* self, 
const char *css_info);
 
 STRING_LIST *html_get_css_elements_classes (CONVERTER *self,
                                             const char *filename);
+
 #endif



reply via email to

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