texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/Makefile.am (libtexinfo_convert_l


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/Makefile.am (libtexinfo_convert_la_SOURCES), tp/Texinfo/XS/convert/html_converter_api.c (html_output) (html_convert), tp/Texinfo/XS/convert/html_converter_api.h, tp/Texinfo/XS/convert/texinfo.c (txi_html_output): add html_converter_api.h with a selection of HTML conversion functions that allow to set up and destroy a converter and implement output() and convert(). Add html_output using code form texinfo.c. Add html_convert implementation.
Date: Fri, 04 Oct 2024 19:24:10 -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 ae275bf564 * tp/Texinfo/XS/Makefile.am 
(libtexinfo_convert_la_SOURCES), tp/Texinfo/XS/convert/html_converter_api.c 
(html_output) (html_convert), tp/Texinfo/XS/convert/html_converter_api.h, 
tp/Texinfo/XS/convert/texinfo.c (txi_html_output): add html_converter_api.h 
with a selection of HTML conversion functions that allow to set up and destroy 
a converter and implement output() and convert().  Add html_output using code 
form texinfo.c.  Add html_convert implementation.
ae275bf564 is described below

commit ae275bf5643fd1b2ea57e225bbec577d69c2fe4d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Aug 15 15:32:53 2024 +0200

    * tp/Texinfo/XS/Makefile.am (libtexinfo_convert_la_SOURCES),
    tp/Texinfo/XS/convert/html_converter_api.c (html_output)
    (html_convert), tp/Texinfo/XS/convert/html_converter_api.h,
    tp/Texinfo/XS/convert/texinfo.c (txi_html_output): add
    html_converter_api.h with a selection of HTML conversion functions
    that allow to set up and destroy a converter and implement output()
    and convert().  Add html_output using code form texinfo.c.  Add
    html_convert implementation.
---
 ChangeLog                                      |  11 ++
 tp/Texinfo/XS/Makefile.am                      |   2 +
 tp/Texinfo/XS/convert/convert_html.h           |   4 +-
 tp/Texinfo/XS/convert/html_converter_api.c     | 153 +++++++++++++++++++++++++
 tp/Texinfo/XS/convert/html_converter_api.h     | 103 +++++++++++++++++
 tp/Texinfo/XS/convert/html_prepare_converter.c |   4 +-
 tp/Texinfo/XS/convert/html_prepare_converter.h |   7 +-
 tp/Texinfo/XS/convert/texinfo.c                |  87 ++------------
 8 files changed, 287 insertions(+), 84 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ed1da42b1b..6a70da291e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,17 @@
        (html_default_format_node_redirection_page)
        (html_default_format_special_body_about): fix function names.
 
+2024-08-15  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/Makefile.am (libtexinfo_convert_la_SOURCES),
+       tp/Texinfo/XS/convert/html_converter_api.c (html_output)
+       (html_convert), tp/Texinfo/XS/convert/html_converter_api.h,
+       tp/Texinfo/XS/convert/texinfo.c (txi_html_output): add
+       html_converter_api.h with a selection of HTML conversion functions
+       that allow to set up and destroy a converter and implement output()
+       and convert().  Add html_output using code form texinfo.c.  Add
+       html_convert implementation.
+
 2024-08-15  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/html_conversion_state.c
diff --git a/tp/Texinfo/XS/Makefile.am b/tp/Texinfo/XS/Makefile.am
index d7c0757487..1180b8960d 100644
--- a/tp/Texinfo/XS/Makefile.am
+++ b/tp/Texinfo/XS/Makefile.am
@@ -399,6 +399,8 @@ C_libtexinfo_convert_sources = \
                        convert/html_conversion_state.h \
                        convert/html_prepare_converter.c \
                        convert/html_prepare_converter.h \
+                       convert/html_converter_api.c \
+                       convert/html_converter_api.h \
                        convert/texinfo.c \
                        convert/texinfo.h
 
diff --git a/tp/Texinfo/XS/convert/convert_html.h 
b/tp/Texinfo/XS/convert/convert_html.h
index 9457769dad..536cc54cc0 100644
--- a/tp/Texinfo/XS/convert/convert_html.h
+++ b/tp/Texinfo/XS/convert/convert_html.h
@@ -76,9 +76,11 @@ int html_run_stage_handlers (CONVERTER *self,
 void html_setup_output_simple_page (CONVERTER *self,
                                     const char *output_filename);
 
+/* next two called separately for convert() */
 void html_prepare_simpletitle (CONVERTER *self);
 void html_prepare_title_titlepage (CONVERTER *self, const char *output_file,
                                    const char *output_filename);
+/* only for output() */
 int html_prepare_converted_output_info (CONVERTER *self,
                                         const char *output_file,
                                         const char *output_filename);
@@ -87,8 +89,6 @@ int html_prepare_converted_output_info (CONVERTER *self,
 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);
 
 char *html_convert_output (CONVERTER *self, const ELEMENT *root,
                            const char *output_file,
diff --git a/tp/Texinfo/XS/convert/html_converter_api.c 
b/tp/Texinfo/XS/convert/html_converter_api.c
new file mode 100644
index 0000000000..1515a696b3
--- /dev/null
+++ b/tp/Texinfo/XS/convert/html_converter_api.c
@@ -0,0 +1,153 @@
+/* Copyright 2010-2024 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
+
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "document_types.h"
+#include "converter.h"
+#include "html_converter_api.h"
+
+/* similar to Texinfo::Convert::HTML->output */
+char *
+html_output (CONVERTER *converter, DOCUMENT *document)
+{
+  int i;
+  char *paths[5];
+  const char *output_file;
+  const char *destination_directory;
+  const char *output_filename;
+  const char *document_name;
+  char *result = 0;
+  int status;
+
+  /* prepare conversion to HTML */
+  converter_set_document (converter, document);
+
+  html_initialize_output_state (converter, "_output");
+
+  status = html_setup_output (converter, paths);
+
+  if (!status)
+   {
+     memset (paths, 0, 5 * sizeof (char *));
+     goto finalization;
+   }
+
+  output_file = paths[0];
+  destination_directory = paths[1];
+  output_filename = paths[2];
+  document_name = paths[3];
+
+  html_prepare_conversion_units (converter);
+
+  html_prepare_conversion_units_targets (converter, converter->document_name);
+
+  html_translate_names (converter);
+
+  html_prepare_units_directions_files (converter,
+                   output_file, destination_directory, output_filename,
+                                document_name);
+  status = html_prepare_converted_output_info (converter, output_file,
+                                                     output_filename);
+
+  if (!status)
+    goto finalization;
+
+  /* conversion */
+  if (converter->document)
+    {
+      result = html_convert_output (converter, converter->document->tree,
+                  output_file, destination_directory, output_filename,
+                        document_name);
+    }
+
+  if (!result)
+    goto finalization;
+
+  if (strlen (result) && !strlen (output_file))
+    {
+      if (converter->conf->TEST.o.integer <= 0 )
+        {
+    /* This case is unlikely to happen, as there is no output file
+       only if formatting is called as convert, which only happens in tests.
+     */
+          html_do_js_files (converter);
+        }
+      goto finalization;
+    }
+
+  status = html_finish_output (converter, output_file, destination_directory);
+
+ finalization:
+
+  for (i = 0; i < 5; i++)
+    {
+      free (paths[i]);
+    }
+
+  html_conversion_finalization (converter);
+
+  return result;
+}
+
+/* similar to Texinfo::Convert::HTML->convert */
+char *
+html_convert (CONVERTER *converter, DOCUMENT *document)
+{
+  char *result;
+
+  converter_set_document (converter, document);
+
+  html_initialize_output_state (converter, "_convert");
+
+  html_setup_convert (converter);
+
+  html_prepare_conversion_units (converter);
+
+  /* converter->document_name should be 0 */
+  html_prepare_conversion_units_targets (converter, converter->document_name);
+
+        /* setup global targets.  It is not clearly relevant to have those
+           global targets when called as convert, but the Top global
+           unit directions is often referred to in code, so at least this
+           global target needs to be setup.
+           Since the relative directions are not set, this leads to lone
+           global direction buttons such as [Contents] or [Index] appearing
+           in otherwise empty navigation headings if those global directions
+           are set and present in the buttons, as is the case in the default
+           buttons.  For example in converters_tests/ref_in_sectioning
+           or converters_tests/sections_and_printindex.
+         */
+  html_prepare_output_units_global_targets (converter);
+
+  html_translate_names (converter);
+
+  html_prepare_simpletitle (converter);
+
+  html_prepare_title_titlepage (converter, "", "");
+
+  /* main conversion here */
+  result = html_convert_convert (converter, converter->document->tree);
+
+  html_conversion_finalization (converter);
+
+  return result;
+}
diff --git a/tp/Texinfo/XS/convert/html_converter_api.h 
b/tp/Texinfo/XS/convert/html_converter_api.h
new file mode 100644
index 0000000000..7508d8f6a4
--- /dev/null
+++ b/tp/Texinfo/XS/convert/html_converter_api.h
@@ -0,0 +1,103 @@
+/* html_converter_api.h - selected functions for the html converter API */
+#ifndef HTML_CONVERTER_API_H
+#define HTML_CONVERTER_API_H
+
+/* Copyright 2010-2024 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
+
+/* HTML functions that are needed to setup and destroy a converter and
+   implement conversion with output() or convert() */
+
+#include "option_types.h"
+#include "document_types.h"
+#include "converter_types.h"
+
+/* in html_prepare_converter.c */
+void html_format_setup (void);
+
+/* in html_converter_init_options.c */
+void html_converter_defaults (CONVERTER *self,
+                              CONVERTER_INITIALIZATION_INFO *format_defaults);
+
+void html_converter_initialize (CONVERTER *self);
+
+/* in html_prepare_converter.c */
+void html_converter_init_special_unit (CONVERTER *self);
+void html_converter_customize (CONVERTER *self);
+
+/* in options_init_free.c */
+void html_fill_options_directions (OPTIONS *options, const CONVERTER 
*converter);
+
+void html_initialize_output_state (CONVERTER *self, const char *context);
+
+int html_setup_output (CONVERTER *self, char **paths);
+void html_setup_convert (CONVERTER *self);
+
+void html_prepare_conversion_units (CONVERTER *self);
+
+void html_prepare_conversion_units_targets (CONVERTER *self,
+                                     const char *document_name);
+
+/* called separately for convert() */
+void html_prepare_output_units_global_targets (CONVERTER *self);
+/* only called for output() */
+FILE_SOURCE_INFO_LIST *html_prepare_units_directions_files (CONVERTER *self,
+          const char *output_file, const char *destination_directory,
+          const char *output_filename, const char *document_name);
+
+/* in convert_html.c */
+char *html_convert_tree (CONVERTER *self, const ELEMENT *tree,
+                         const char *explanation);
+
+void html_translate_names (CONVERTER *self);
+
+/* next two called separately for convert() */
+void html_prepare_simpletitle (CONVERTER *self);
+void html_prepare_title_titlepage (CONVERTER *self, const char *output_file,
+                                   const char *output_filename);
+/* only for output() */
+int html_prepare_converted_output_info (CONVERTER *self,
+                                        const char *output_file,
+                                        const char *output_filename);
+
+char *html_convert_convert (CONVERTER *self, const ELEMENT *root);
+
+char *html_convert_output (CONVERTER *self, const ELEMENT *root,
+                           const char *output_file,
+                           const char *destination_directory,
+                           const char *output_filename,
+                           const char *document_name);
+
+void html_conversion_finalization (CONVERTER *self);
+
+void html_do_js_files (CONVERTER *self);
+
+int html_finish_output (CONVERTER *self, const char *output_file,
+                        const char *destination_directory);
+
+/* in html_converter_finish.c */
+void html_reset_converter (CONVERTER *self);
+
+void html_free_converter (CONVERTER *self);
+
+
+
+/* implemented in html_converter_api.c using above functions */
+
+char *html_output (CONVERTER *converter, DOCUMENT *document);
+
+char *html_convert (CONVERTER *converter, DOCUMENT *document);
+
+#endif
diff --git a/tp/Texinfo/XS/convert/html_prepare_converter.c 
b/tp/Texinfo/XS/convert/html_prepare_converter.c
index 5575725d53..476d81a2b1 100644
--- a/tp/Texinfo/XS/convert/html_prepare_converter.c
+++ b/tp/Texinfo/XS/convert/html_prepare_converter.c
@@ -694,7 +694,7 @@ html_converter_init_special_unit (CONVERTER *self)
     }
 }
 
-/* Used to get Perl formatting references.  Initalize in C */
+/* Used to get Perl formatting references.  Initialize in C */
 FORMATTING_REFERENCE *
 new_special_unit_formatting_references (int special_units_varieties_nr)
 {
@@ -705,7 +705,7 @@ new_special_unit_formatting_references (int 
special_units_varieties_nr)
   return formatting_references;
 }
 
-/* sed to get htmlxref info from Perl.  Initalize in C */
+/* Used to get htmlxref info from Perl.  Initialize in C */
 HTMLXREF_MANUAL *
 new_htmlxref_manual_list (size_t size)
 {
diff --git a/tp/Texinfo/XS/convert/html_prepare_converter.h 
b/tp/Texinfo/XS/convert/html_prepare_converter.h
index 2338a8f3fe..83ee79c68a 100644
--- a/tp/Texinfo/XS/convert/html_prepare_converter.h
+++ b/tp/Texinfo/XS/convert/html_prepare_converter.h
@@ -14,15 +14,19 @@ extern const char *html_formatting_reference_names[];
 
 extern const char *htmlxref_split_type_names[htmlxref_split_type_chapter + 1];
 
+
+
 void html_format_setup (void);
 
 
 
+/* called from XS only */
 FORMATTING_REFERENCE *new_special_unit_formatting_references
                                       (int special_units_varieties_nr);
-
+/* Called from XS only */
 HTMLXREF_MANUAL *new_htmlxref_manual_list (size_t size);
 
+/* Called from XS only */
 SPECIAL_UNIT_INFO *html_add_special_unit_info (
                             SPECIAL_UNIT_INFO_LIST *special_unit_info_list,
                             int type, size_t variety_nr, const char *value);
@@ -64,6 +68,7 @@ void html_prepare_output_units_global_targets (CONVERTER 
*self);
 /* called from XS only */
 void html_setup_global_units_direction_names (CONVERTER *self);
 
+/* only called for output() */
 FILE_SOURCE_INFO_LIST * html_prepare_units_directions_files (CONVERTER *self,
           const char *output_file, const char *destination_directory,
           const char *output_filename, const char *document_name);
diff --git a/tp/Texinfo/XS/convert/texinfo.c b/tp/Texinfo/XS/convert/texinfo.c
index 9fc31b1288..d11ef33f56 100644
--- a/tp/Texinfo/XS/convert/texinfo.c
+++ b/tp/Texinfo/XS/convert/texinfo.c
@@ -38,8 +38,7 @@
 #include "structuring.h"
 #include "transformations.h"
 #include "converter.h"
-#include "convert_html.h"
-#include "html_prepare_converter.h"
+#include "html_converter_api.h"
 #include "texinfo.h"
 
 /* initialization of the library. */
@@ -372,83 +371,14 @@ txi_converter_initialize (CONVERTER *converter,
 char *
 txi_html_output (CONVERTER *converter, DOCUMENT *document)
 {
-  int i;
-  char *paths[5];
-  const char *output_file;
-  const char *destination_directory;
-  const char *output_filename;
-  const char *document_name;
-  char *result = 0;
-  int status;
-
-  /* prepare conversion to HTML */
-  converter_set_document (converter, document);
-
-  html_initialize_output_state (converter, "_output");
-
-  status = html_setup_output (converter, paths);
-
-  if (!status)
-   {
-     memset (paths, 0, 5 * sizeof (char *));
-     goto finalization;
-   }
-
-  output_file = paths[0];
-  destination_directory = paths[1];
-  output_filename = paths[2];
-  document_name = paths[3];
-
-  html_prepare_conversion_units (converter);
-
-  html_prepare_conversion_units_targets (converter, converter->document_name);
-
-  html_translate_names (converter);
-
-  html_prepare_units_directions_files (converter,
-                   output_file, destination_directory, output_filename,
-                                document_name);
-  status = html_prepare_converted_output_info (converter, output_file,
-                                                     output_filename);
-
-  if (!status)
-    goto finalization;
-
-  /* conversion */
-  if (converter->document)
-    {
-      result = html_convert_output (converter, converter->document->tree,
-                  output_file, destination_directory, output_filename,
-                        document_name);
-    }
-
-  if (!result)
-    goto finalization;
-
-  if (strlen (result) && !strlen (output_file))
-    {
-      if (converter->conf->TEST.o.integer <= 0 )
-        {
-    /* This case is unlikely to happen, as there is no output file
-       only if formatting is called as convert, which only happens in tests.
-     */
-          html_do_js_files (converter);
-        }
-      goto finalization;
-    }
-
-  status = html_finish_output (converter, output_file, destination_directory);
-
- finalization:
-
-  for (i = 0; i < 5; i++)
-    {
-      free (paths[i]);
-    }
-
-  html_conversion_finalization (converter);
+  return html_output (converter, document);
+}
 
-  return result;
+/* similar to Texinfo::Convert::HTML->convert */
+char *
+txi_html_convert (CONVERTER *converter, DOCUMENT *document)
+{
+  return html_convert (converter, document);
 }
 
 
@@ -506,5 +436,4 @@ txi_handle_converter_error_messages (CONVERTER *converter, 
int no_warn,
 {
   return handle_error_messages (&converter->error_messages, no_warn,
                          use_filename, message_encoding);
-
 }



reply via email to

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