texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Thu, 26 Sep 2024 17:15:29 -0400 (EDT)

branch: master
commit 6b10e5e8f5126541023c10d9a361803a3a514907
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Sep 26 20:14:26 2024 +0200

    * tp/Texinfo/Convert/HTML.pm (_file_header_information)
    (_default_format_begin_file, _default_format_node_redirection_page),
    tp/Texinfo/XS/convert/convert_html.c (BEGIN_FILE_INFORMATION)
    (destroy_begin_file_information, file_header_information)
    (html_default_format_begin_file)
    (html_default_format_node_redirection_page): add keywords to
    file_header_information returned information.
---
 ChangeLog                            | 10 ++++++++++
 tp/Texinfo/Convert/HTML.pm           | 32 ++++++++++++++++++++++----------
 tp/Texinfo/XS/convert/convert_html.c | 27 +++++++++++++++++++--------
 3 files changed, 51 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 24b785ee0d..d2601cba18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-09-26  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (_file_header_information)
+       (_default_format_begin_file, _default_format_node_redirection_page),
+       tp/Texinfo/XS/convert/convert_html.c (BEGIN_FILE_INFORMATION)
+       (destroy_begin_file_information, file_header_information)
+       (html_default_format_begin_file)
+       (html_default_format_node_redirection_page): add keywords to
+       file_header_information returned information.
+
 2024-09-25  Patrice Dumas  <pertusus@free.fr>
 
        * doc/texi2any_api.texi (Loading Init Files), doc/texinfo.texi (HTML
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index dc3ddd393e..fba025c265 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -11338,6 +11338,8 @@ sub _file_header_information($$;$)
   }
   $title = $self->get_info('title_string') if (!defined($title));
 
+  my $keywords = $title;
+
   my $description = $self->get_info('documentdescription_string');
   $description = $title
     if (not defined($description) or $description eq '');
@@ -11437,10 +11439,10 @@ $mathjax_configuration
 
   }
 
-  return ($title, $description, $encoding, $date, $css_lines, $doctype,
-          $root_html_element_attributes, $body_attributes, $copying_comment,
-          $after_body_open, $extra_head, $program_and_version, 
$program_homepage,
-          $program, $generator);
+  return ($title, $description, $keywords, $encoding, $date, $css_lines,
+          $doctype, $root_html_element_attributes, $body_attributes,
+          $copying_comment, $after_body_open, $extra_head,
+          $program_and_version, $program_homepage, $program, $generator);
 }
 
 sub _get_links($$$$)
@@ -11496,7 +11498,7 @@ sub _default_format_begin_file($$$)
     }
   }
 
-  my ($title, $description, $encoding, $date, $css_lines, $doctype,
+  my ($title, $description, $keywords, $encoding, $date, $css_lines, $doctype,
       $root_html_element_attributes, $body_attributes, $copying_comment,
       $after_body_open, $extra_head, $program_and_version, $program_homepage,
       $program, $generator)
@@ -11504,6 +11506,12 @@ sub _default_format_begin_file($$$)
 
   my $links = $self->_get_links($filename, $output_unit, $node_command);
 
+  my $keywords_output = '';
+  if (defined($keywords)) {
+    $keywords_output = $self->close_html_lone_element(
+        "<meta name=\"keywords\" content=\"$keywords\"")."\n";
+  }
+
   my $result = "$doctype
 <html${root_html_element_attributes}>
 <!-- Created by $program_and_version, $program_homepage -->
@@ -11512,8 +11520,7 @@ $encoding
 $copying_comment<title>$title</title>
 
 $description\n".
-    $self->close_html_lone_element(
-      "<meta name=\"keywords\" content=\"$title\"")."\n".
+    $keywords_output.
     $self->close_html_lone_element(
       "<meta name=\"resource-type\" content=\"document\"")."\n".
      $self->close_html_lone_element(
@@ -11546,12 +11553,18 @@ sub _default_format_node_redirection_page($$;$)
       { 'href' => {'type' => '_converted', 'text' => $direction }}),
       'Tr redirection sentence');
 
-  my ($title, $description, $encoding, $date, $css_lines, $doctype,
+  my ($title, $description, $keywords, $encoding, $date, $css_lines, $doctype,
       $root_html_element_attributes, $body_attributes, $copying_comment,
       $after_body_open, $extra_head, $program_and_version, $program_homepage,
       $program, $generator) = $self->_file_header_information($command,
                                                               $filename);
 
+  my $keywords_output = '';
+  if (defined($keywords)) {
+    $keywords_output = $self->close_html_lone_element(
+        "<meta name=\"keywords\" content=\"$keywords\"")."\n";
+  }
+
   my $result = "$doctype
 <html${root_html_element_attributes}>
 <!-- Created by $program_and_version, $program_homepage -->
@@ -11561,8 +11574,7 @@ $encoding
 $copying_comment<title>$title</title>
 
 $description\n".
-   $self->close_html_lone_element(
-     "<meta name=\"keywords\" content=\"$title\"")."\n".
+   $keywords_output.
    $self->close_html_lone_element(
      "<meta name=\"resource-type\" content=\"document\"")."\n".
    $self->close_html_lone_element(
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 32a2dfe277..8c9bab9e47 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -6867,6 +6867,7 @@ format_end_file (CONVERTER *self, const char *filename,
 typedef struct BEGIN_FILE_INFORMATION {
     char *title;
     char *description;
+    char *keywords;
     char *encoding;
     char *css_lines;
     char *root_html_element_attributes;
@@ -6880,6 +6881,7 @@ destroy_begin_file_information (BEGIN_FILE_INFORMATION 
*begin_info)
 {
   free (begin_info->title);
   free (begin_info->description);
+  free (begin_info->keywords);
   free (begin_info->encoding);
   free (begin_info->css_lines);
   free (begin_info->root_html_element_attributes);
@@ -7119,6 +7121,9 @@ file_header_information (CONVERTER *self, const ELEMENT 
*command,
   if (!begin_info->title)
     begin_info->title = strdup (self->title_string);
 
+  if (begin_info->title)
+    begin_info->keywords = strdup (begin_info->title);
+
   if (!description || !strlen (description))
     description = begin_info->title;
 
@@ -7351,10 +7356,13 @@ html_default_format_begin_file (CONVERTER *self, const 
char *filename,
   if (begin_info->description)
     text_append (&result, begin_info->description);
   text_append_n (&result, "\n", 1);
-  text_printf (&result, "<meta name=\"keywords\" content=\"%s\"",
-               begin_info->title);
-  close_html_lone_element (self, &result);
-  text_append_n (&result, "\n", 1);
+  if (begin_info->keywords)
+    {
+      text_printf (&result, "<meta name=\"keywords\" content=\"%s\"",
+                   begin_info->keywords);
+      close_html_lone_element (self, &result);
+      text_append_n (&result, "\n", 1);
+    }
   text_append (&result, "<meta name=\"resource-type\" content=\"document\"");
   close_html_lone_element (self, &result);
   text_append_n (&result, "\n", 1);
@@ -8482,10 +8490,13 @@ html_default_format_node_redirection_page (CONVERTER 
*self,
   if (begin_info->description)
     text_append (&result, begin_info->description);
   text_append_n (&result, "\n", 1);
-  text_printf (&result, "<meta name=\"keywords\" content=\"%s\"",
-               begin_info->title);
-  close_html_lone_element (self, &result);
-  text_append_n (&result, "\n", 1);
+  if (begin_info->keywords)
+    {
+      text_printf (&result, "<meta name=\"keywords\" content=\"%s\"",
+                   begin_info->keywords);
+      close_html_lone_element (self, &result);
+      text_append_n (&result, "\n", 1);
+    }
   text_append (&result, "<meta name=\"resource-type\" content=\"document\"");
   close_html_lone_element (self, &result);
   text_append_n (&result, "\n", 1);



reply via email to

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