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/convert_html.c, tp/Texinf


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/convert/convert_html.c, tp/Texinfo/XS/convert/html_prepare_converter.c (html_id_is_registered) (html_register_id): move html_id_is_registered and html_register_id to html_prepare_converter.c.
Date: Fri, 04 Oct 2024 18:51:55 -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 6e33b8468a * tp/Texinfo/XS/convert/convert_html.c, 
tp/Texinfo/XS/convert/html_prepare_converter.c (html_id_is_registered) 
(html_register_id): move html_id_is_registered and html_register_id to 
html_prepare_converter.c.
6e33b8468a is described below

commit 6e33b8468a8f3e2aa97438a063ce2ce2e515f6e8
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Aug 14 23:21:03 2024 +0200

    * tp/Texinfo/XS/convert/convert_html.c,
    tp/Texinfo/XS/convert/html_prepare_converter.c (html_id_is_registered)
    (html_register_id): move html_id_is_registered and html_register_id to
    html_prepare_converter.c.
    
    * tp/Texinfo/XS/convert/convert_html.c: move translations related
    code around to group code, and move the whole above.
---
 ChangeLog                                      |  10 +
 tp/Texinfo/XS/convert/convert_html.c           | 689 ++++++++++++-------------
 tp/Texinfo/XS/convert/convert_html.h           |  23 +-
 tp/Texinfo/XS/convert/html_prepare_converter.c |  18 +
 tp/Texinfo/XS/convert/html_prepare_converter.h |   4 +
 5 files changed, 380 insertions(+), 364 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index db0c5055a1..5c5c20a93e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,16 @@
        * tp/Texinfo/XS/convert/convert_html.c (html_command_description):
        call html_get_target instead of find_element_target.
 
+2024-08-14  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/convert_html.c,
+       tp/Texinfo/XS/convert/html_prepare_converter.c (html_id_is_registered)
+       (html_register_id): move html_id_is_registered and html_register_id to
+       html_prepare_converter.c.
+
+       * tp/Texinfo/XS/convert/convert_html.c: move translations related
+       code around to group code, and move the whole above.
+
 2024-08-14  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/convert_html.c: move code around to group code
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index f4a7ef2719..021eebb2b3 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -110,24 +110,6 @@ const enum htmlxref_split_type 
htmlxref_entries[htmlxref_split_type_chapter + 1]
 static void convert_to_html_internal (CONVERTER *self, const ELEMENT *e,
                                       TEXT *result, const char *explanation);
 
-int
-html_id_is_registered (CONVERTER *self, const char *string)
-{
-  if (self->ids_data_type == IDT_perl_hashmap)
-    return is_hv_registered_id (self, string);
-  else
-    return find_string (self->registered_ids, string);
-}
-
-void
-html_register_id (CONVERTER *self, const char *string)
-{
-  if (self->ids_data_type == IDT_perl_hashmap)
-    hv_register_id (self, string);
-  else
-    add_string (string, self->registered_ids);
-}
-
 /*
  if OUTPUT_UNITS is defined, the first output unit is used if a proper
  top output unit is not found.
@@ -1351,31 +1333,6 @@ convert_tree_new_formatting_context (CONVERTER *self, 
const ELEMENT *tree,
   return result;
 }
 
-void
-html_clear_direction_string_type (const CONVERTER *self,
-                                  char ***type_directions_strings)
-{
-  int i;
-  int nr_string_directions = NON_SPECIAL_DIRECTIONS_NR - FIRSTINFILE_NR
-                      + self->special_unit_varieties.number;
-  int nr_dir_str_contexts = TDS_context_string + 1;
-
-  for (i = 0; i < nr_string_directions; i++)
-    {
-      char **direction_strings = type_directions_strings[i];
-      int j;
-      /* NULL only happens for customized_directions_strings */
-      if (direction_strings != NULL)
-        {
-          for (j = 0; j < nr_dir_str_contexts; j++)
-            {
-              free (direction_strings[j]);
-              direction_strings[j] = 0;
-            }
-        }
-    }
-}
-
 const char *
 direction_string (CONVERTER *self, int direction,
                   enum direction_string_type string_type,
@@ -13180,339 +13137,121 @@ html_default_format_special_body_about (CONVERTER 
*self,
 
 
 
-static const enum command_id simpletitle_cmds[] =
- {CM_settitle, CM_shorttitlepage, 0};
+/* reset translated data and translate no args commands */
 
 void
-html_prepare_simpletitle (CONVERTER *self)
+html_clear_direction_string_type (const CONVERTER *self,
+                                  char ***type_directions_strings)
 {
   int i;
-  for (i = 0; simpletitle_cmds[i]; i++)
+  int nr_string_directions = NON_SPECIAL_DIRECTIONS_NR - FIRSTINFILE_NR
+                      + self->special_unit_varieties.number;
+  int nr_dir_str_contexts = TDS_context_string + 1;
+
+  for (i = 0; i < nr_string_directions; i++)
     {
-      enum command_id cmd = simpletitle_cmds[i];
-      const ELEMENT *command
-        = get_cmd_global_uniq_command (&self->document->global_commands, cmd);
-      if (command && command->e.c->args.number > 0
-          && command->e.c->args.list[0]->e.c->contents.number > 0)
+      char **direction_strings = type_directions_strings[i];
+      int j;
+      /* NULL only happens for customized_directions_strings */
+      if (direction_strings != NULL)
         {
-          self->simpletitle_tree = command->e.c->args.list[0];
-          self->simpletitle_cmd = cmd;
-          break;
+          for (j = 0; j < nr_dir_str_contexts; j++)
+            {
+              free (direction_strings[j]);
+              direction_strings[j] = 0;
+            }
         }
     }
 }
 
 void
-html_prepare_title_titlepage (CONVERTER *self, const char *output_file,
-                              const char *output_filename)
+html_reset_translated_special_unit_info_tree (CONVERTER *self)
 {
-  const OUTPUT_UNIT_LIST *output_units = retrieve_output_units
-    (self->document, self->output_units_descriptors[OUDT_units]);
-
-  if (strlen (output_file))
-    {
-      self->current_filename.filename = output_units->list[0]->unit_filename;
-      self->current_filename.file_number
-        = self->output_unit_file_indices[0]+1;
-    }
-  else
+  STRING_LIST *special_unit_varieties = &self->special_unit_varieties;
+  int j;
+  for (j = 0; translated_special_unit_info[j].tree_type != SUIT_type_none; j++)
     {
-      /* case of convert() call.  Need to setup the page here */
-      if (self->page_name_number.number <= 0)
-         html_setup_output_simple_page (self, output_filename);
-      self->current_filename.filename = output_filename;
-      self->current_filename.file_number = 1;
-    }
+      size_t i;
+      enum special_unit_info_tree tree_type
+        = translated_special_unit_info[j].tree_type;
+      for (i = 0; i < special_unit_varieties->number; i++)
+        {
+          if (self->special_unit_info_tree[tree_type][i])
+            {
+              remove_tree_to_build (self,
+                             self->special_unit_info_tree[tree_type][i]);
+              destroy_element_and_children (
+                self->special_unit_info_tree[tree_type][i]);
 
-  self->title_titlepage = format_title_titlepage (self);
-  memset (&self->current_filename, 0, sizeof (FILE_NUMBER_NAME));
+            }
+          self->special_unit_info_tree[tree_type][i] = 0;
+        }
+    }
 }
 
-static const enum command_id fulltitle_cmds[] =
- {CM_settitle, CM_title, CM_shorttitlepage, CM_top, 0};
-
-
-int
-html_prepare_converted_output_info (CONVERTER *self, const char *output_file,
-                                    const char *output_filename)
+static void
+reset_unset_no_arg_commands_formatting_context (CONVERTER *self,
+               enum command_id cmd, enum conversion_context reset_context,
+               enum conversion_context ref_context, int translate)
 {
-  int i;
-  ELEMENT *fulltitle_tree = 0;
-  char *html_title_string = 0;
-  char *default_document_language = 0;
-  char *preamble_document_language = 0;
-  int init_handler_status;
-  int handler_fatal_error_level
-     = self->conf->HANDLER_FATAL_ERROR_LEVEL.o.integer;
-
-  int structure_handler_status
-    = html_run_stage_handlers (self, HSHT_type_structure);
-
-  if (structure_handler_status < handler_fatal_error_level
-      && structure_handler_status > -handler_fatal_error_level)
-    {}
-  else
-    return 0;
-
-  if (self->conf->documentlanguage.o.string)
-    default_document_language = strdup (self->conf->documentlanguage.o.string);
-
-  set_global_document_commands (self, CL_preamble, conf_for_documentlanguage);
-
-  if (self->conf->documentlanguage.o.string)
-    preamble_document_language = strdup 
(self->conf->documentlanguage.o.string);
-
-  if (! (!default_document_language && !preamble_document_language)
-      && (!default_document_language || !preamble_document_language
-          || strcmp (default_document_language, preamble_document_language)))
-    html_translate_names (self);
-
-  /*
-   prepare title.  fulltitle uses more possibility than simpletitle for
-   title, including @-commands found in @titlepage only.  Therefore
-   simpletitle is more in line with what makeinfo in C did.
-   */
-
-  html_prepare_simpletitle (self);
-
-  for (i = 0; fulltitle_cmds[i]; i++)
+  HTML_NO_ARG_COMMAND_CONVERSION *no_arg_command_context;
+  HTML_NO_ARG_COMMAND_CONVERSION *conversion_contexts
+    = self->html_no_arg_command_conversion[cmd];
+  no_arg_command_context = &conversion_contexts[reset_context];
+  if (ref_context >= 0)
     {
-      enum command_id cmd = fulltitle_cmds[i];
-      const ELEMENT *command
-        = get_cmd_global_uniq_command (&self->document->global_commands, cmd);
-      if (command && command->e.c->args.number > 0
-          && command->e.c->args.list[0]->e.c->contents.number > 0)
+      if (no_arg_command_context->unset)
         {
-          fulltitle_tree = command->e.c->args.list[0];
-          break;
-        }
-    }
-
-  if (!fulltitle_tree
-      && self->document->global_commands.titlefont.number > 0
-      && self->document->global_commands.titlefont.list[0]->e.c->args.number > 0
-      && self->document->global_commands.titlefont.list[0]->e.c->args.list[0]
-                                    ->e.c->contents.number > 0)
-    {
-      fulltitle_tree = self->document->global_commands.titlefont.list[0];
-    }
-
-  if (fulltitle_tree)
-    {
-      self->title_tree = fulltitle_tree;
+          HTML_NO_ARG_COMMAND_CONVERSION *no_arg_ref
+            = &conversion_contexts[ref_context];
 
-      html_title_string = convert_string_tree_new_formatting_context (self,
-                                       fulltitle_tree, "title_string", 0);
-      if (html_title_string[strspn (html_title_string, whitespace_chars)]
-           == '\0')
-        {
-          free (html_title_string);
-          html_title_string = 0;
+          if (no_arg_ref->text)
+            {
+              free (no_arg_command_context->text);
+              no_arg_command_context->text = strdup (no_arg_ref->text);
+            }
+          if (no_arg_ref->translated_tree)
+            no_arg_command_context->translated_tree
+              = no_arg_ref->translated_tree;
+          if (no_arg_ref->translated_converted)
+            {
+              free (no_arg_command_context->translated_converted);
+              no_arg_command_context->translated_converted
+                = strdup (no_arg_ref->translated_converted);
+            }
+          if (no_arg_ref->translated_to_convert)
+            {
+              free (no_arg_command_context->translated_to_convert);
+              no_arg_command_context->translated_to_convert
+                = strdup (no_arg_ref->translated_to_convert);
+            }
         }
     }
 
-  if (!html_title_string)
+  if (translate
+      && no_arg_command_context->translated_tree
+      && !no_arg_command_context->translated_converted)
     {
-      ELEMENT *default_title = html_cdt_tree ("Untitled Document",
-                                              self, 0, 0);
-      SOURCE_INFO cmd_source_info;
-
-      self->title_tree = default_title;
-
-      html_title_string = convert_string_tree_new_formatting_context (self,
-                                       default_title, "title_string", 0);
-
-      self->added_title_tree = 1;
-
-      if (self->document->global_info.input_file_name)
+      char *translation_result = 0;
+      char *explanation;
+      char *context;
+      ELEMENT *tree_built = 0;
+      ELEMENT *translated_tree = no_arg_command_context->translated_tree;
+      if (self->external_references_number > 0 && !translated_tree->hv)
         {
-          /* setup a source info with file only */
-          memset (&cmd_source_info, 0, sizeof (SOURCE_INFO));
-          cmd_source_info.file_name
-           = self->document->global_info.input_file_name;
-          /* this is more in line with the Perl function used, as DEBUG is
-             checked in the called function */
-          message_list_line_error_ext (&self->error_messages, self->conf,
-                                  MSG_warning, 0, &cmd_source_info,
-                      "must specify a title with a title command or @top");
+          add_to_element_list (&self->tree_to_build, translated_tree);
+          tree_built = translated_tree;
         }
-      else
+      xasprintf (&explanation, "Translated NO ARG @%s ctx %s",
+                 builtin_command_data[cmd].cmdname,
+                 html_conversion_context_type_names[reset_context]);
+      xasprintf (&context, "Tr %s ctx %s",
+                 builtin_command_data[cmd].cmdname,
+                 html_conversion_context_type_names[reset_context]);
+      if (reset_context == HCC_type_normal)
         {
-          message_list_document_warn (&self->error_messages, self->conf, 0,
-                      "must specify a title with a title command or @top");
-        }
-    }
-
-  self->title_string = html_title_string;
-
-  /* copying comment */
-
-  if (self->document->global_commands.copying)
-    {
-      char *copying_comment;
-      ELEMENT *tmp = new_element (ET_NONE);
-
-      tmp->e.c->contents = 
self->document->global_commands.copying->e.c->contents;
-
-      copying_comment = convert_to_text (tmp, self->convert_text_options);
-
-      tmp->e.c->contents.list = 0;
-      destroy_element (tmp);
-
-      if (copying_comment && strlen (copying_comment) > 0)
-        {
-          self->copying_comment = format_comment (self, copying_comment);
-        }
-      free (copying_comment);
-    }
-
-  /* documentdescription */
-  if (self->conf->documentdescription.o.string)
-    self->documentdescription_string
-     = strdup (self->conf->documentdescription.o.string);
-  else if (self->document->global_commands.documentdescription)
-    {
-      ELEMENT *tmp = new_element (ET_NONE);
-      char *documentdescription_string;
-      size_t documentdescription_string_len;
-
-      tmp->e.c->contents
-        = self->document->global_commands.documentdescription->e.c->contents;
-
-      documentdescription_string
-                 = convert_string_tree_new_formatting_context (self,
-                                       tmp, "documentdescription", 0);
-
-      tmp->e.c->contents.list = 0;
-      destroy_element (tmp);
-
-      documentdescription_string_len = strlen (documentdescription_string);
-      if (documentdescription_string_len > 0
-          && documentdescription_string[documentdescription_string_len -1]
-             == '\n')
-        documentdescription_string[documentdescription_string_len -1] = '\0';
-
-      self->documentdescription_string = documentdescription_string;
-    }
-
-  init_handler_status = html_run_stage_handlers (self, HSHT_type_init);
-
-  if (init_handler_status < handler_fatal_error_level
-      && init_handler_status > -handler_fatal_error_level)
-    {}
-  else
-    {
-      free (default_document_language);
-      free (preamble_document_language);
-
-      return 0;
-    }
-
-  html_prepare_title_titlepage (self, output_file, output_filename);
-
-  set_global_document_commands (self, CL_before, conf_for_documentlanguage);
-
-  if (! (!default_document_language && !preamble_document_language)
-      && (!default_document_language || !preamble_document_language
-          || strcmp (default_document_language, preamble_document_language)))
-    html_translate_names (self);
-
-  free (default_document_language);
-  free (preamble_document_language);
-
-  return 1;
-}
-
-
-
-void
-html_reset_translated_special_unit_info_tree (CONVERTER *self)
-{
-  STRING_LIST *special_unit_varieties = &self->special_unit_varieties;
-  int j;
-  for (j = 0; translated_special_unit_info[j].tree_type != SUIT_type_none; j++)
-    {
-      size_t i;
-      enum special_unit_info_tree tree_type
-        = translated_special_unit_info[j].tree_type;
-      for (i = 0; i < special_unit_varieties->number; i++)
-        {
-          if (self->special_unit_info_tree[tree_type][i])
-            {
-              remove_tree_to_build (self,
-                             self->special_unit_info_tree[tree_type][i]);
-              destroy_element_and_children (
-                self->special_unit_info_tree[tree_type][i]);
-
-            }
-          self->special_unit_info_tree[tree_type][i] = 0;
-        }
-    }
-}
-
-static void
-reset_unset_no_arg_commands_formatting_context (CONVERTER *self,
-               enum command_id cmd, enum conversion_context reset_context,
-               enum conversion_context ref_context, int translate)
-{
-  HTML_NO_ARG_COMMAND_CONVERSION *no_arg_command_context;
-  HTML_NO_ARG_COMMAND_CONVERSION *conversion_contexts
-    = self->html_no_arg_command_conversion[cmd];
-  no_arg_command_context = &conversion_contexts[reset_context];
-  if (ref_context >= 0)
-    {
-      if (no_arg_command_context->unset)
-        {
-          HTML_NO_ARG_COMMAND_CONVERSION *no_arg_ref
-            = &conversion_contexts[ref_context];
-
-          if (no_arg_ref->text)
-            {
-              free (no_arg_command_context->text);
-              no_arg_command_context->text = strdup (no_arg_ref->text);
-            }
-          if (no_arg_ref->translated_tree)
-            no_arg_command_context->translated_tree
-              = no_arg_ref->translated_tree;
-          if (no_arg_ref->translated_converted)
-            {
-              free (no_arg_command_context->translated_converted);
-              no_arg_command_context->translated_converted
-                = strdup (no_arg_ref->translated_converted);
-            }
-          if (no_arg_ref->translated_to_convert)
-            {
-              free (no_arg_command_context->translated_to_convert);
-              no_arg_command_context->translated_to_convert
-                = strdup (no_arg_ref->translated_to_convert);
-            }
-        }
-    }
-
-  if (translate
-      && no_arg_command_context->translated_tree
-      && !no_arg_command_context->translated_converted)
-    {
-      char *translation_result = 0;
-      char *explanation;
-      char *context;
-      ELEMENT *tree_built = 0;
-      ELEMENT *translated_tree = no_arg_command_context->translated_tree;
-      if (self->external_references_number > 0 && !translated_tree->hv)
-        {
-          add_to_element_list (&self->tree_to_build, translated_tree);
-          tree_built = translated_tree;
-        }
-      xasprintf (&explanation, "Translated NO ARG @%s ctx %s",
-                 builtin_command_data[cmd].cmdname,
-                 html_conversion_context_type_names[reset_context]);
-      xasprintf (&context, "Tr %s ctx %s",
-                 builtin_command_data[cmd].cmdname,
-                 html_conversion_context_type_names[reset_context]);
-      if (reset_context == HCC_type_normal)
-        {
-          translation_result = html_convert_tree (self, translated_tree,
-                                                  explanation);
+          translation_result = html_convert_tree (self, translated_tree,
+                                                  explanation);
         }
       else if (reset_context == HCC_type_preformatted)
         {
@@ -13715,6 +13454,254 @@ html_translate_names (CONVERTER *self)
 
 
 
+/* last preparations of conversion.  At this point conversion of
+   Texinfo tree is possible */
+
+static const enum command_id simpletitle_cmds[] =
+ {CM_settitle, CM_shorttitlepage, 0};
+
+void
+html_prepare_simpletitle (CONVERTER *self)
+{
+  int i;
+  for (i = 0; simpletitle_cmds[i]; i++)
+    {
+      enum command_id cmd = simpletitle_cmds[i];
+      const ELEMENT *command
+        = get_cmd_global_uniq_command (&self->document->global_commands, cmd);
+      if (command && command->e.c->args.number > 0
+          && command->e.c->args.list[0]->e.c->contents.number > 0)
+        {
+          self->simpletitle_tree = command->e.c->args.list[0];
+          self->simpletitle_cmd = cmd;
+          break;
+        }
+    }
+}
+
+void
+html_prepare_title_titlepage (CONVERTER *self, const char *output_file,
+                              const char *output_filename)
+{
+  const OUTPUT_UNIT_LIST *output_units = retrieve_output_units
+    (self->document, self->output_units_descriptors[OUDT_units]);
+
+  if (strlen (output_file))
+    {
+      self->current_filename.filename = output_units->list[0]->unit_filename;
+      self->current_filename.file_number
+        = self->output_unit_file_indices[0]+1;
+    }
+  else
+    {
+      /* case of convert() call.  Need to setup the page here */
+      if (self->page_name_number.number <= 0)
+         html_setup_output_simple_page (self, output_filename);
+      self->current_filename.filename = output_filename;
+      self->current_filename.file_number = 1;
+    }
+
+  self->title_titlepage = format_title_titlepage (self);
+  memset (&self->current_filename, 0, sizeof (FILE_NUMBER_NAME));
+}
+
+static const enum command_id fulltitle_cmds[] =
+ {CM_settitle, CM_title, CM_shorttitlepage, CM_top, 0};
+
+
+int
+html_prepare_converted_output_info (CONVERTER *self, const char *output_file,
+                                    const char *output_filename)
+{
+  int i;
+  ELEMENT *fulltitle_tree = 0;
+  char *html_title_string = 0;
+  char *default_document_language = 0;
+  char *preamble_document_language = 0;
+  int init_handler_status;
+  int handler_fatal_error_level
+     = self->conf->HANDLER_FATAL_ERROR_LEVEL.o.integer;
+
+  int structure_handler_status
+    = html_run_stage_handlers (self, HSHT_type_structure);
+
+  if (structure_handler_status < handler_fatal_error_level
+      && structure_handler_status > -handler_fatal_error_level)
+    {}
+  else
+    return 0;
+
+  if (self->conf->documentlanguage.o.string)
+    default_document_language = strdup (self->conf->documentlanguage.o.string);
+
+  set_global_document_commands (self, CL_preamble, conf_for_documentlanguage);
+
+  if (self->conf->documentlanguage.o.string)
+    preamble_document_language = strdup 
(self->conf->documentlanguage.o.string);
+
+  if (! (!default_document_language && !preamble_document_language)
+      && (!default_document_language || !preamble_document_language
+          || strcmp (default_document_language, preamble_document_language)))
+    html_translate_names (self);
+
+  /*
+   prepare title.  fulltitle uses more possibility than simpletitle for
+   title, including @-commands found in @titlepage only.  Therefore
+   simpletitle is more in line with what makeinfo in C did.
+   */
+
+  html_prepare_simpletitle (self);
+
+  for (i = 0; fulltitle_cmds[i]; i++)
+    {
+      enum command_id cmd = fulltitle_cmds[i];
+      const ELEMENT *command
+        = get_cmd_global_uniq_command (&self->document->global_commands, cmd);
+      if (command && command->e.c->args.number > 0
+          && command->e.c->args.list[0]->e.c->contents.number > 0)
+        {
+          fulltitle_tree = command->e.c->args.list[0];
+          break;
+        }
+    }
+
+  if (!fulltitle_tree
+      && self->document->global_commands.titlefont.number > 0
+      && self->document->global_commands.titlefont.list[0]->e.c->args.number > 0
+      && self->document->global_commands.titlefont.list[0]->e.c->args.list[0]
+                                    ->e.c->contents.number > 0)
+    {
+      fulltitle_tree = self->document->global_commands.titlefont.list[0];
+    }
+
+  if (fulltitle_tree)
+    {
+      self->title_tree = fulltitle_tree;
+
+      html_title_string = convert_string_tree_new_formatting_context (self,
+                                       fulltitle_tree, "title_string", 0);
+      if (html_title_string[strspn (html_title_string, whitespace_chars)]
+           == '\0')
+        {
+          free (html_title_string);
+          html_title_string = 0;
+        }
+    }
+
+  if (!html_title_string)
+    {
+      ELEMENT *default_title = html_cdt_tree ("Untitled Document",
+                                              self, 0, 0);
+      SOURCE_INFO cmd_source_info;
+
+      self->title_tree = default_title;
+
+      html_title_string = convert_string_tree_new_formatting_context (self,
+                                       default_title, "title_string", 0);
+
+      self->added_title_tree = 1;
+
+      if (self->document->global_info.input_file_name)
+        {
+          /* setup a source info with file only */
+          memset (&cmd_source_info, 0, sizeof (SOURCE_INFO));
+          cmd_source_info.file_name
+           = self->document->global_info.input_file_name;
+          /* this is more in line with the Perl function used, as DEBUG is
+             checked in the called function */
+          message_list_line_error_ext (&self->error_messages, self->conf,
+                                  MSG_warning, 0, &cmd_source_info,
+                      "must specify a title with a title command or @top");
+        }
+      else
+        {
+          message_list_document_warn (&self->error_messages, self->conf, 0,
+                      "must specify a title with a title command or @top");
+        }
+    }
+
+  self->title_string = html_title_string;
+
+  /* copying comment */
+
+  if (self->document->global_commands.copying)
+    {
+      char *copying_comment;
+      ELEMENT *tmp = new_element (ET_NONE);
+
+      tmp->e.c->contents = 
self->document->global_commands.copying->e.c->contents;
+
+      copying_comment = convert_to_text (tmp, self->convert_text_options);
+
+      tmp->e.c->contents.list = 0;
+      destroy_element (tmp);
+
+      if (copying_comment && strlen (copying_comment) > 0)
+        {
+          self->copying_comment = format_comment (self, copying_comment);
+        }
+      free (copying_comment);
+    }
+
+  /* documentdescription */
+  if (self->conf->documentdescription.o.string)
+    self->documentdescription_string
+     = strdup (self->conf->documentdescription.o.string);
+  else if (self->document->global_commands.documentdescription)
+    {
+      ELEMENT *tmp = new_element (ET_NONE);
+      char *documentdescription_string;
+      size_t documentdescription_string_len;
+
+      tmp->e.c->contents
+        = self->document->global_commands.documentdescription->e.c->contents;
+
+      documentdescription_string
+                 = convert_string_tree_new_formatting_context (self,
+                                       tmp, "documentdescription", 0);
+
+      tmp->e.c->contents.list = 0;
+      destroy_element (tmp);
+
+      documentdescription_string_len = strlen (documentdescription_string);
+      if (documentdescription_string_len > 0
+          && documentdescription_string[documentdescription_string_len -1]
+             == '\n')
+        documentdescription_string[documentdescription_string_len -1] = '\0';
+
+      self->documentdescription_string = documentdescription_string;
+    }
+
+  init_handler_status = html_run_stage_handlers (self, HSHT_type_init);
+
+  if (init_handler_status < handler_fatal_error_level
+      && init_handler_status > -handler_fatal_error_level)
+    {}
+  else
+    {
+      free (default_document_language);
+      free (preamble_document_language);
+
+      return 0;
+    }
+
+  html_prepare_title_titlepage (self, output_file, output_filename);
+
+  set_global_document_commands (self, CL_before, conf_for_documentlanguage);
+
+  if (! (!default_document_language && !preamble_document_language)
+      && (!default_document_language || !preamble_document_language
+          || strcmp (default_document_language, preamble_document_language)))
+    html_translate_names (self);
+
+  free (default_document_language);
+  free (preamble_document_language);
+
+  return 1;
+}
+
+
+
 /* conversion */
 
 void
@@ -14811,8 +14798,8 @@ html_convert_output (CONVERTER *self, const ELEMENT 
*root,
 
 
 
-/* This function cleans up the conversion state that would only be relevant
-   during conversion.  Other information is removed when calling reset_parser
+/* This function cleans up the conversion state that is relevant during
+   conversion.  Other information is removed when calling reset_parser
    later on and should not be freed here */
 void
 html_conversion_finalization (CONVERTER *self)
diff --git a/tp/Texinfo/XS/convert/convert_html.h 
b/tp/Texinfo/XS/convert/convert_html.h
index 1a08728324..56b428e7e5 100644
--- a/tp/Texinfo/XS/convert/convert_html.h
+++ b/tp/Texinfo/XS/convert/convert_html.h
@@ -40,9 +40,6 @@ extern const char *direction_string_context_names[];
 
 extern const char *html_stage_handler_stage_type_names[];
 
-int html_id_is_registered (CONVERTER *self, const char *string);
-void html_register_id (CONVERTER *self, const char *string);
-
 OUTPUT_UNIT *html_get_top_unit (DOCUMENT *document,
                                 const OUTPUT_UNIT_LIST *output_units);
 
@@ -88,9 +85,6 @@ int html_run_stage_handlers (CONVERTER *self,
 
 void html_default_format_protect_text (const char *text, TEXT *result);
 
-void html_clear_direction_string_type (const CONVERTER *self,
-                                       char ***type_directions_strings);
-
 
 int html_special_unit_variety_direction_index (const CONVERTER *self,
                                         const char *special_unit_variety);
@@ -299,13 +293,8 @@ SPECIAL_BODY_FORMATTING_FUNCTION(about)
 #undef SPECIAL_BODY_FORMATTING_FUNCTION
 
 
-void html_prepare_simpletitle (CONVERTER *self);
-void html_prepare_title_titlepage (CONVERTER *self, const char *output_file,
-                                   const char *output_filename);
-int html_prepare_converted_output_info (CONVERTER *self,
-                                        const char *output_file,
-                                        const char *output_filename);
-
+void html_clear_direction_string_type (const CONVERTER *self,
+                                       char ***type_directions_strings);
 
 void html_complete_no_arg_commands_formatting (CONVERTER *self,
                                                enum command_id cmd,
@@ -315,6 +304,14 @@ void html_reset_translated_special_unit_info_tree 
(CONVERTER *self);
 void html_translate_names (CONVERTER *self);
 
 
+void html_prepare_simpletitle (CONVERTER *self);
+void html_prepare_title_titlepage (CONVERTER *self, const char *output_file,
+                                   const char *output_filename);
+int html_prepare_converted_output_info (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);
diff --git a/tp/Texinfo/XS/convert/html_prepare_converter.c 
b/tp/Texinfo/XS/convert/html_prepare_converter.c
index ab640d49e3..31d6ad2be7 100644
--- a/tp/Texinfo/XS/convert/html_prepare_converter.c
+++ b/tp/Texinfo/XS/convert/html_prepare_converter.c
@@ -3137,6 +3137,24 @@ html_prepare_conversion_units (CONVERTER *self)
 
 
 
+int
+html_id_is_registered (CONVERTER *self, const char *string)
+{
+  if (self->ids_data_type == IDT_perl_hashmap)
+    return is_hv_registered_id (self, string);
+  else
+    return find_string (self->registered_ids, string);
+}
+
+void
+html_register_id (CONVERTER *self, const char *string)
+{
+  if (self->ids_data_type == IDT_perl_hashmap)
+    hv_register_id (self, string);
+  else
+    add_string (string, self->registered_ids);
+}
+
 /* used for diverse elements: tree units, indices, footnotes, special
   elements, contents elements... */
 static HTML_TARGET *
diff --git a/tp/Texinfo/XS/convert/html_prepare_converter.h 
b/tp/Texinfo/XS/convert/html_prepare_converter.h
index b82023dd94..517eb5ec39 100644
--- a/tp/Texinfo/XS/convert/html_prepare_converter.h
+++ b/tp/Texinfo/XS/convert/html_prepare_converter.h
@@ -44,9 +44,13 @@ void html_setup_convert (CONVERTER *self);
 
 void html_prepare_conversion_units (CONVERTER *self);
 
+int html_id_is_registered (CONVERTER *self, const char *string);
+void html_register_id (CONVERTER *self, const char *string);
+
 void html_prepare_conversion_units_targets (CONVERTER *self,
                                      const char *document_name);
 
+
 void html_prepare_output_units_global_targets (CONVERTER *self);
 void html_setup_global_units_direction_names (CONVERTER *self);
 const OUTPUT_UNIT *html_find_direction_name_global_unit (const CONVERTER *self,



reply via email to

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