texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: XS override for HTML::convert


From: Patrice Dumas
Subject: branch master updated: XS override for HTML::convert
Date: Tue, 01 Oct 2024 12:10:22 -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 35f5d7296c XS override for HTML::convert
35f5d7296c is described below

commit 35f5d7296cd12e5be9e4d09766aa8589b662868c
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Jul 24 18:25:32 2024 +0200

    XS override for HTML::convert
    
    * tp/Texinfo/Convert/HTML.pm (%XS_overrides),
    tp/Texinfo/XS/convert/ConvertXS.xs (html_convert): add an XS override
    for convert.
---
 ChangeLog                          |  8 ++++
 tp/Texinfo/Convert/HTML.pm         |  2 +
 tp/Texinfo/XS/convert/ConvertXS.xs | 83 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 93 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 6a65674de7..6459e5392e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,14 @@
        (call_formatting_function_format_single_footnote): check and reset
        flags in build_html_formatting_state.
 
+2024-07-24  Patrice Dumas  <pertusus@free.fr>
+
+       XS override for HTML::convert
+
+       * tp/Texinfo/Convert/HTML.pm (%XS_overrides),
+       tp/Texinfo/XS/convert/ConvertXS.xs (html_convert): add an XS override
+       for convert.
+
 2024-07-24  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/ConvertXS.xs
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 2df83c2d88..97810034e9 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -103,6 +103,8 @@ my %XS_overrides = (
 my %XS_conversion_overrides = (
   "Texinfo::Convert::HTML::output"
    => "Texinfo::Convert::ConvertXS::html_output",
+  "Texinfo::Convert::HTML::convert"
+   => "Texinfo::Convert::ConvertXS::html_convert",
 
   # following are not called when output and convert are overriden
   "Texinfo::Convert::HTML::_XS_format_setup"
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index d3c9251ba5..e98542115d 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -787,6 +787,89 @@ html_output (SV *converter_in, SV *document_in)
         RETVAL
 
 
+SV *
+html_convert (SV *converter_in, SV *document_in)
+      PREINIT:
+        CONVERTER *self;
+        char *result;
+        SV *output_units_sv;
+        SV *special_units_sv;
+        SV *associated_special_units_sv;
+      CODE:
+        /* html_conversion_initialization */
+        self = converter_set_document_from_sv (converter_in, document_in);
+
+        html_initialize_output_state (self, "_convert");
+        /* could be useful if something from Perl is needed
+        html_conversion_initialization_sv (converter_in, self);
+         */
+
+        html_pass_conversion_initialization (self, converter_in, document_in);
+
+        /* html_setup_convert */
+        html_setup_convert (self);
+        html_pass_converter_setup_state (self, converter_in);
+
+        /* html_prepare_conversion_units */
+        html_prepare_conversion_units (self);
+
+        html_pass_conversion_output_units (self, converter_in,
+                                     &output_units_sv, &special_units_sv,
+                                     &associated_special_units_sv);
+
+        /* calls Perl customization functions, so need to be done after
+           build_output_units_list calls to be able to retrieve Perl
+           output units references */
+        html_prepare_conversion_units_targets (self, self->document_name);
+
+        /* html_prepare_output_units_global_targets */
+        /* 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.
+           Output units lists are rebuilt in the XS code.
+         */
+        html_prepare_output_units_global_targets (self);
+
+        html_pass_output_units_global_targets (self, output_units_sv,
+                               special_units_sv, associated_special_units_sv);
+
+        /* html_translate_names */
+        /* setup untranslated strings */
+        html_translate_names (self);
+        build_html_formatting_state (self);
+
+        /* html_prepare_simpletitle */
+        html_prepare_simpletitle (self);
+
+        /* html_prepare_title_titlepage */
+        /* title.  Not often set in the default case, as convert() is only
+           used in the *.t tests, and a title requires both simpletitle_tree
+           and SHOW_TITLE set, with the default formatting function.
+         */
+        html_prepare_title_titlepage (self, "", "");
+
+        /* html_convert_convert */
+        /* main conversion here */
+        result = html_convert_convert (self, self->document->tree);
+        build_html_formatting_state (self);
+
+        /* html_conversion_finalization */
+        html_conversion_finalization (self);
+
+        html_check_transfer_state_finalization (self);
+
+        RETVAL = newSVpv_utf8 (result, 0);
+        free (result);
+    OUTPUT:
+        RETVAL
+
 void
 html_register_id (SV *converter_in, id)
          const char *id = (char *)SvPVutf8_nolen($arg);



reply via email to

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