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 (convert_f


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/convert/convert_html.c (convert_footnote_command): remove spurious end of line in identifiers.
Date: Sun, 31 Dec 2023 07:47:18 -0500

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 22c802e414 * tp/Texinfo/XS/convert/convert_html.c 
(convert_footnote_command): remove spurious end of line in identifiers.
22c802e414 is described below

commit 22c802e4143e96f2899214b19a59006233fe8ab9
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Dec 31 13:47:18 2023 +0100

    * tp/Texinfo/XS/convert/convert_html.c (convert_footnote_command):
    remove spurious end of line in identifiers.
    
    * tp/Texinfo/XS/convert/convert_html.c (convert_titlefont_command):
    destroy classes.
    
    * tp/Texinfo/XS/convert/convert_html.c (convert_listoffloats_command)
    (commands_internal_conversion_table): implement
    convert_listoffloats_command.
    
    * tp/Texinfo/Convert/HTML.pm (_convert_listoffloats_command): rename
    $caption as $caption_element.
---
 ChangeLog                            |  15 +++++
 tp/Texinfo/Convert/HTML.pm           |  10 +--
 tp/Texinfo/XS/convert/convert_html.c | 122 ++++++++++++++++++++++++++++++++++-
 3 files changed, 140 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7f7615ddb1..1a9a3bcced 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2023-12-31  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/convert_html.c (convert_footnote_command):
+       remove spurious end of line in identifiers.
+
+       * tp/Texinfo/XS/convert/convert_html.c (convert_titlefont_command):
+       destroy classes.
+
+       * tp/Texinfo/XS/convert/convert_html.c (convert_listoffloats_command)
+       (commands_internal_conversion_table): implement
+       convert_listoffloats_command.
+
+       * tp/Texinfo/Convert/HTML.pm (_convert_listoffloats_command): rename
+       $caption as $caption_element.
+
 2023-12-31  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/convert_html.c (convert_insertcopying_command)
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index d78ac95516..d472a21081 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -5361,21 +5361,21 @@ sub _convert_listoffloats_command($$$$)
         }
       }
       $result .= '</dt>';
-      my $caption;
+      my $caption_element;
       my $caption_cmdname;
       if ($float->{'extra'} and $float->{'extra'}->{'shortcaption'}) {
-        $caption = $float->{'extra'}->{'shortcaption'};
+        $caption_element = $float->{'extra'}->{'shortcaption'};
         $caption_cmdname = 'shortcaption';
       } elsif ($float->{'extra'} and $float->{'extra'}->{'caption'}) {
-        $caption = $float->{'extra'}->{'caption'};
+        $caption_element = $float->{'extra'}->{'caption'};
         $caption_cmdname = 'caption';
       }
 
       my $caption_text;
       my @caption_classes;
-      if ($caption) {
+      if ($caption_element) {
         $caption_text = $self->convert_tree_new_formatting_context(
-          $caption->{'args'}->[0], $cmdname, 'listoffloats');
+          $caption_element->{'args'}->[0], $cmdname, 'listoffloats');
         push @caption_classes, "${caption_cmdname}-in-${cmdname}";
       } else {
         $caption_text = '';
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 3afd5a4eee..16c787ada8 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -8659,9 +8659,9 @@ convert_footnote_command (CONVERTER *self, const enum 
command_id cmd,
   if (multi_expanded_region)
     {
     /* to avoid duplicate names, use a prefix that cannot happen in anchors */
-      xasprintf (&footid, "%s%s_%s_%d\n", target_prefix, multi_expanded_region,
+      xasprintf (&footid, "%s%s_%s_%d", target_prefix, multi_expanded_region,
                  footnote_id, foot_num);
-      xasprintf (&docid, "%s%s_%s_%d\n", target_prefix, multi_expanded_region,
+      xasprintf (&docid, "%s%s_%s_%d", target_prefix, multi_expanded_region,
                  footnote_docid, foot_num);
     }
   else
@@ -9217,6 +9217,7 @@ convert_titlefont_command (CONVERTER *self, const enum 
command_id cmd,
       format_heading_text (self, cmd, classes,
                    args_formatted->args[0].formatted[AFT_type_normal],
                      0, 0, 0, 0, result);
+      destroy_strings_list (classes);
     }
 }
 
@@ -10464,6 +10465,122 @@ convert_insertcopying_command (CONVERTER *self, const 
enum command_id cmd,
     }
 }
 
+static char *caption_in_listoffloats_array[] = {"caption-in-listoffloats"};
+static const STRING_LIST caption_in_listoffloats_classes
+  = {caption_in_listoffloats_array, 1, 1};
+static char *shortcaption_in_listoffloats_array[]
+  = {"shortcaption-in-listoffloats"};
+static const STRING_LIST shortcaption_in_listoffloats_classes
+  = {shortcaption_in_listoffloats_array, 1, 1};
+
+void
+convert_listoffloats_command (CONVERTER *self, const enum command_id cmd,
+                    const ELEMENT *element,
+                    const HTML_ARGS_FORMATTED *args_formatted,
+                    const char *content, TEXT *result)
+{
+  LISTOFFLOATS_TYPE_LIST *listoffloats;
+  char *listoffloats_name;
+  int i;
+
+  if (html_in_string (self))
+    return;
+
+  listoffloats = self->document->listoffloats;
+
+  if (!listoffloats->number)
+    return;
+
+  listoffloats_name = lookup_extra_string (element, "float_type");
+
+  for (i = 0; i < listoffloats->number; i++)
+    {
+      LISTOFFLOATS_TYPE *float_types = &listoffloats->float_types[i];
+      if (!strcmp (float_types->type, listoffloats_name))
+        {
+          char *attribute_class;
+          STRING_LIST *classes;
+          size_t j;
+
+          if (float_types->float_list.number <= 0)
+            return;
+
+          classes = (STRING_LIST *) malloc (sizeof (STRING_LIST));
+          memset (classes, 0, sizeof (STRING_LIST));
+          add_string (builtin_command_name (cmd), classes);
+
+          attribute_class = html_attribute_class (self, "dl", classes);
+          text_append (result, attribute_class);
+          text_append_n (result, ">\n", 2);
+
+          for (j = 0; j < float_types->float_list.number; j++)
+            {
+              char *caption_attribute_class;
+              ELEMENT *caption_element;
+              const STRING_LIST *caption_classes = 0;
+              ELEMENT *float_elt = float_types->float_list.list[j];
+              char *float_href = html_command_href (self, float_elt, 0, 0, 0);
+              char *float_text;
+
+              if (!float_href)
+                continue;
+
+              text_append_n (result, "<dt>", 4);
+              float_text = html_command_text (self, float_elt, 0);
+              if (float_text && strlen (float_text))
+                {
+                  if (strlen (float_href))
+                    {
+                      text_printf (result, "<a href=\"%s\">%s</a>",
+                                   float_href, float_text);
+                    }
+                  else /* not sure that it can happen */
+                    {
+                      text_append (result, float_text);
+                    }
+                }
+
+              text_append_n (result, "</dt>", 5);
+
+              free (float_text);
+              free (float_href);
+
+              caption_element = lookup_extra_element (float_elt,
+                                                      "shortcaption");
+              if (caption_element)
+                caption_classes = &shortcaption_in_listoffloats_classes;
+              else
+                {
+                  caption_element = lookup_extra_element (float_elt, 
"caption");
+                  if (caption_element)
+                    caption_classes = &caption_in_listoffloats_classes;
+                }
+
+              caption_attribute_class = html_attribute_class (self, "dd",
+                                                              caption_classes);
+              text_append (result, caption_attribute_class);
+              free (caption_attribute_class);
+              text_append_n (result, ">", 1);
+              if (caption_element)
+                {
+                  char *caption_text
+                    = convert_tree_new_formatting_context (self,
+                        caption_element->args.list[0],
+                        builtin_command_name (cmd),
+                        "listoffloats", 0, 0);
+                  text_append (result, caption_text);
+                  free (caption_text);
+                }
+              text_append_n (result, "</dd>\n", 6);
+            }
+          text_append_n (result, "</dl>\n", 6);
+
+          free (attribute_class);
+          destroy_strings_list (classes);
+        }
+    }
+}
+
 void
 convert_xref_commands (CONVERTER *self, const enum command_id cmd,
                     const ELEMENT *element,
@@ -11331,6 +11448,7 @@ static COMMAND_INTERNAL_CONVERSION 
commands_internal_conversion_table[] = {
   {CM_subtitle, &convert_subtitle_command},
 
   {CM_insertcopying, &convert_insertcopying_command},
+  {CM_listoffloats, &convert_listoffloats_command},
 
   {CM_contents, &convert_contents_command},
   {CM_shortcontents, &convert_contents_command},



reply via email to

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