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/ConvertXS.xs (html_prepar


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/convert/ConvertXS.xs (html_prepare_simpletitle): call build_simpletitle with converter_info.
Date: Sun, 29 Sep 2024 17:05: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 2b14d5833c * tp/Texinfo/XS/convert/ConvertXS.xs 
(html_prepare_simpletitle): call build_simpletitle with converter_info.
2b14d5833c is described below

commit 2b14d5833cf85374bc1582cce0c8693a6d5db569
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jul 7 22:00:03 2024 +0200

    * tp/Texinfo/XS/convert/ConvertXS.xs (html_prepare_simpletitle):
    call build_simpletitle with converter_info.
    
    * tp/Texinfo/Convert/HTML.pm (_init_output, output),
    tp/Texinfo/XS/convert/ConvertXS.xs (html_init_output),
    tp/Texinfo/XS/convert/build_html_perl_state.c (pass_jslicenses),
    tp/Texinfo/XS/convert/convert_html.c (contents_elements_options)
    (conf_for_documentlanguage, fill_jslicense_file_info)
    (html_init_output): move BODY_ELEMENT_ATTRIBUTES setting and
    some set_global_document_commands calls to init_output.  Move
    jslicences data setting to init_output, add to XS interface and add
    pass_jslicenses to build jslicense data from C to Perl.
---
 ChangeLog                                     | 15 +++++
 tp/Texinfo/Convert/HTML.pm                    | 38 ++++++-------
 tp/Texinfo/XS/convert/ConvertXS.xs            | 20 +++++--
 tp/Texinfo/XS/convert/build_html_perl_state.c | 39 +++++++++++++
 tp/Texinfo/XS/convert/build_html_perl_state.h |  1 +
 tp/Texinfo/XS/convert/convert_html.c          | 80 ++++++++++++++++++++++++++-
 6 files changed, 167 insertions(+), 26 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 888e7e2faf..0e5db1ecf3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,21 @@
        converter_set_document, converter_initialize and
        reset_output_init_conf to get_converter_perl_info.c.
 
+2024-07-07  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/ConvertXS.xs (html_prepare_simpletitle):
+       call build_simpletitle with converter_info.
+
+       * tp/Texinfo/Convert/HTML.pm (_init_output, output),
+       tp/Texinfo/XS/convert/ConvertXS.xs (html_init_output),
+       tp/Texinfo/XS/convert/build_html_perl_state.c (pass_jslicenses),
+       tp/Texinfo/XS/convert/convert_html.c (contents_elements_options)
+       (conf_for_documentlanguage, fill_jslicense_file_info)
+       (html_init_output): move BODY_ELEMENT_ATTRIBUTES setting and
+       some set_global_document_commands calls to init_output.  Move
+       jslicences data setting to init_output, add to XS interface and add
+       pass_jslicenses to build jslicense data from C to Perl.
+
 2024-07-07  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/utils.c (html_free_direction_icons): reset number
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 36b430135a..0bfd84d093 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -13358,25 +13358,6 @@ sub _init_output($)
   # pass to XS.
   _XS_reset_output_init_conf($self);
 
-  return 1;
-}
-
-# Main function for outputting a manual in HTML.
-# $SELF is the output converter object of class Texinfo::Convert::HTML (this
-# module), and $DOCUMENT is the parsed document from the parser and structuring
-sub output($$)
-{
-  my $self = shift;
-  my $document = shift;
-
-  $self->conversion_initialization($document);
-
-  my $success_status = _init_output($self);
-  unless ($success_status) {
-    $self->conversion_finalization();
-    return undef;
-  }
-
   # set BODY_ELEMENT_ATTRIBUTES
   $self->set_global_document_commands('preamble', ['documentlanguage']);
   my $structure_preamble_document_language = 
$self->get_conf('documentlanguage');
@@ -13422,6 +13403,25 @@ sub output($$)
 
   $self->{'converter_info'}->{'jslicenses'} = $jslicenses;
 
+  return 1;
+}
+
+# Main function for outputting a manual in HTML.
+# $SELF is the output converter object of class Texinfo::Convert::HTML (this
+# module), and $DOCUMENT is the parsed document from the parser and structuring
+sub output($$)
+{
+  my $self = shift;
+  my $document = shift;
+
+  $self->conversion_initialization($document);
+
+  my $success_status = _init_output($self);
+  unless ($success_status) {
+    $self->conversion_finalization();
+    return undef;
+  }
+
   $self->_prepare_css();
 
   # this sets OUTFILE, to be used if not split, but also 'output_filename'
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 668ea96cf9..f140d0e308 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -566,6 +566,12 @@ html_init_output (SV *converter_in)
          self = get_sv_converter (converter_in, "html_init_output");
          if (self)
            {
+             HV *converter_hv = (HV *) SvRV (converter_in);
+             SV **converter_info_sv
+                 = hv_fetch (converter_hv, "converter_info",
+                             strlen ("converter_info"), 0);
+             HV *converter_info_hv = (HV *) SvRV (*converter_info_sv);
+
              status = html_init_output (self);
 
              /* internal links code is in Perl */
@@ -575,16 +581,15 @@ html_init_output (SV *converter_in)
              if (self->conf->CONVERT_TO_LATEX_IN_MATH.o.integer > 0)
                self->external_references_number++;
 
-             if (self->external_references_number
-                 && self->conf->CONVERT_TO_LATEX_IN_MATH.o.integer > 0)
+             if (self->conf->CONVERT_TO_LATEX_IN_MATH.o.integer > 0)
                {
-                 HV *converter_hv = (HV *) SvRV (converter_in);
                  HV *options_latex_math_hv =
-                   latex_build_options_for_convert_to_latex_math (self);
+                 latex_build_options_for_convert_to_latex_math (self);
                  hv_store (converter_hv, "options_latex_math",
                            strlen ("options_latex_math"),
                            newRV_noinc ((SV *)options_latex_math_hv), 0);
                }
+             pass_jslicenses (&self->jslicenses, converter_info_hv);
            }
          RETVAL = status;
     OUTPUT:
@@ -2170,7 +2175,12 @@ html_prepare_simpletitle (SV *converter_in)
              if (self->simpletitle_tree)
                {
                  HV *converter_hv = (HV *) SvRV (converter_in);
-                 build_simpletitle (self, converter_hv);
+                 SV **converter_info_sv
+                    = hv_fetch (converter_hv, "converter_info",
+                                strlen ("converter_info"), 0);
+                 HV *converter_info_hv = (HV *) SvRV (*converter_info_sv);
+
+                 build_simpletitle (self, converter_info_hv);
                }
            }
 
diff --git a/tp/Texinfo/XS/convert/build_html_perl_state.c 
b/tp/Texinfo/XS/convert/build_html_perl_state.c
index 1c8531ffbd..f845c0e04a 100644
--- a/tp/Texinfo/XS/convert/build_html_perl_state.c
+++ b/tp/Texinfo/XS/convert/build_html_perl_state.c
@@ -552,3 +552,42 @@ build_simpletitle (CONVERTER *converter, HV 
*converter_info_hv)
             newSVpv (builtin_command_name (converter->simpletitle_cmd), 0), 0);
 }
 
+void
+pass_jslicenses (JSLICENSE_CATEGORY_LIST *jslicenses, HV *converter_info_hv)
+{
+  HV *jslicenses_hv;
+  size_t i;
+
+  dTHX;
+
+  jslicenses_hv = newHV ();
+
+  for (i = 0; i < jslicenses->number; i++)
+    {
+      size_t j;
+      JSLICENSE_FILE_INFO_LIST *jslicences_files_info = &jslicenses->list[i];
+      SV *category_sv = newSVpv_utf8 (jslicences_files_info->category, 0);
+      HV *jslicences_files_info_hv = newHV ();
+      hv_store_ent (jslicenses_hv, category_sv,
+                    newRV_noinc ((SV *)jslicences_files_info_hv), 0);
+      for (j = 0; j < jslicences_files_info->number; j++)
+        {
+          JSLICENSE_FILE_INFO *jslicense_file_info
+            = &jslicences_files_info->list[j];
+          SV *filename_sv = newSVpv_utf8 (jslicense_file_info->filename, 0);
+          AV *jslicence_file_info_av = newAV ();
+          hv_store_ent (jslicences_files_info_hv, filename_sv,
+                        newRV_noinc ((SV *)jslicence_file_info_av), 0);
+          av_push (jslicence_file_info_av,
+                   newSVpv_utf8 (jslicense_file_info->license, 0));
+          av_push (jslicence_file_info_av,
+                   newSVpv_utf8 (jslicense_file_info->url, 0));
+          av_push (jslicence_file_info_av,
+                   newSVpv_utf8 (jslicense_file_info->source, 0));
+        }
+    }
+
+  hv_store (converter_info_hv, "jslicenses", strlen ("jslicenses"),
+            newRV_noinc ((SV *) jslicenses_hv), 0);
+}
+
diff --git a/tp/Texinfo/XS/convert/build_html_perl_state.h 
b/tp/Texinfo/XS/convert/build_html_perl_state.h
index c024afeca5..d65b8d4dca 100644
--- a/tp/Texinfo/XS/convert/build_html_perl_state.h
+++ b/tp/Texinfo/XS/convert/build_html_perl_state.h
@@ -30,5 +30,6 @@ SV *build_replaced_substrings (NAMED_STRING_ELEMENT_LIST 
*replaced_substrings);
 void build_pending_footnotes (AV *av, HTML_PENDING_FOOTNOTE_STACK *stack);
 
 void build_simpletitle (CONVERTER *converter, HV *converter_info_hv);
+void pass_jslicenses (JSLICENSE_CATEGORY_LIST *jslicenses, HV 
*converter_info_hv);
 
 #endif
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 1ef349c175..79ee2f6b16 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -1794,14 +1794,15 @@ add_special_target (CONVERTER *self, enum 
special_target_type type,
 }
 
 
-/*
 static const enum command_id contents_elements_options[]
              = {CM_contents, CM_shortcontents, CM_summarycontents, 0};
- */
 
 static const enum command_id conf_for_special_units[]
                           = {CM_footnotestyle, 0};
 
+static const enum command_id conf_for_documentlanguage[]
+                          = {CM_documentlanguage, 0};
+
 void
 html_prepare_conversion_units (CONVERTER *self)
 {
@@ -17632,11 +17633,24 @@ html_conversion_finalization (CONVERTER *self)
 
 }
 
+static void
+fill_jslicense_file_info (JSLICENSE_FILE_INFO *jslicense_file_info,
+                          const char *filename, const char *license,
+                          const char *url, const char *source)
+{
+  jslicense_file_info->filename = strdup (filename);
+  jslicense_file_info->license = strdup (license);
+  jslicense_file_info->url = strdup (url);
+  jslicense_file_info->source = strdup (source);
+}
+
 int
 html_init_output (CONVERTER *self)
 {
   int handler_fatal_error_level;
   int setup_status;
+  int js_categories_list_nr = 0;
+  const char *structure_preamble_document_language;
 
   if (self->conf->OUTFILE.o.string)
     {
@@ -17737,6 +17751,68 @@ html_init_output (CONVERTER *self)
 
   copy_options (self->init_conf, self->conf);
 
+  set_global_document_commands (self, CL_preamble, conf_for_documentlanguage);
+
+  structure_preamble_document_language
+    = self->conf->documentlanguage.o.string;
+
+  if (structure_preamble_document_language
+      && strlen (structure_preamble_document_language))
+    {
+      char *body_element_attributes;
+      xasprintf (&body_element_attributes, "lang=\"%s\"",
+                 structure_preamble_document_language);
+      set_conf (&self->conf->BODY_ELEMENT_ATTRIBUTES,
+                0, body_element_attributes);
+      free (body_element_attributes);
+    }
+  set_global_document_commands (self, CL_before, conf_for_documentlanguage);
+
+  /* the presence of contents elements in the document is used in diverse
+     places, set it once for all here */
+  set_global_document_commands (self, CL_last, contents_elements_options);
+
+  if (self->conf->HTML_MATH.o.string
+      && !strcmp (self->conf->HTML_MATH.o.string, "mathjax"))
+    js_categories_list_nr++;
+
+  if (self->conf->INFO_JS_DIR.o.string)
+    js_categories_list_nr++;
+
+  if (js_categories_list_nr > 0)
+    {
+      int i = 0;
+      initialize_js_categories_list (&self->jslicenses, js_categories_list_nr);
+      if (self->conf->HTML_MATH.o.string
+          && !strcmp (self->conf->HTML_MATH.o.string, "mathjax"))
+        {
+          JSLICENSE_FILE_INFO_LIST *jslicences_files_info
+            = &self->jslicenses.list[i];
+          initialize_jslicense_files (jslicences_files_info, "mathjax", 1);
+          fill_jslicense_file_info (&jslicences_files_info->list[0],
+                                    self->conf->MATHJAX_SCRIPT.o.string,
+                                    "Apache License, Version 2.0.",
+                                "https://www.apache.org/licenses/LICENSE-2.0";,
+                                    self->conf->MATHJAX_SOURCE.o.string);
+          i++;
+        }
+      if (self->conf->INFO_JS_DIR.o.string)
+        {
+          JSLICENSE_FILE_INFO_LIST *jslicences_files_info
+            = &self->jslicenses.list[i];
+          initialize_jslicense_files (jslicences_files_info, "infojs", 2);
+          fill_jslicense_file_info (&jslicences_files_info->list[0],
+                                    "js/info.js",
+                                    "GNU General Public License 3.0 or later",
+                                    "http://www.gnu.org/licenses/gpl-3.0.html";,
+                                    "js/info.js");
+          fill_jslicense_file_info (&jslicences_files_info->list[1],
+                                    "js/modernizr.js", "Expat",
+                                    "http://www.jclark.com/xml/copying.txt";,
+                                    "js/modernizr.js");
+        }
+    }
+
   return 1;
 }
 



reply via email to

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