texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/HTML.pm (_convert_multitable


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/HTML.pm (_convert_multitable_command) (_convert_xtable_command): rearrange code.
Date: Sun, 31 Dec 2023 12:41: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 cb60fc73c0 * tp/Texinfo/Convert/HTML.pm (_convert_multitable_command) 
(_convert_xtable_command): rearrange code.
cb60fc73c0 is described below

commit cb60fc73c0170c2e9f94f73c8378a876a2caf552
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Dec 31 18:41:16 2023 +0100

    * tp/Texinfo/Convert/HTML.pm (_convert_multitable_command)
    (_convert_xtable_command): rearrange code.
    
    * tp/Texinfo/XS/convert/convert_html.c (convert_multitable_command)
    (convert_xtable_command), commands_internal_conversion_table):
    implement convert_multitable_command and convert_xtable_command.
---
 ChangeLog                            | 10 ++++++
 tp/Texinfo/Convert/HTML.pm           | 12 +++++--
 tp/Texinfo/XS/convert/convert_html.c | 64 ++++++++++++++++++++++++++++++++++++
 3 files changed, 83 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fbbadd0e81..0d9680476e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-12-31  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (_convert_multitable_command)
+       (_convert_xtable_command): rearrange code.
+
+       * tp/Texinfo/XS/convert/convert_html.c (convert_multitable_command)
+       (convert_xtable_command), commands_internal_conversion_table):
+       implement convert_multitable_command and convert_xtable_command.
+
+
 2023-12-31  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/convert_html.c (convert_enumerate_command)
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 93d4eb210e..00e9e0e07c 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -5694,12 +5694,15 @@ sub _convert_multitable_command($$$$$)
   my $args = shift;
   my $content = shift;
 
-  $content = '' if (!defined($content));
+  if (!defined($content)) {
+    return '';
+  }
 
   if (in_string($self)) {
     return $content;
   }
-  if ($content =~ /\S/) {
+
+  if ($content ne '') {
     return $self->html_attribute_class('table', [$cmdname]).">\n"
                                      . $content . "</table>\n";
   } else {
@@ -5717,11 +5720,14 @@ sub _convert_xtable_command($$$$$)
   my $args = shift;
   my $content = shift;
 
-  $content = '' if (!defined($content));
+  if (!defined($content)) {
+    return '';
+  }
 
   if (in_string($self)) {
     return $content;
   }
+
   if ($content ne '') {
     return $self->html_attribute_class('dl', [$cmdname]).">\n"
       . $content . "</dl>\n";
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index cb383585ec..a640f3496b 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -11171,6 +11171,66 @@ convert_enumerate_command (CONVERTER *self, const enum 
command_id cmd,
   text_append_n (result, "</ol>\n", 6);
 }
 
+void
+convert_multitable_command (CONVERTER *self, const enum command_id cmd,
+                    const ELEMENT *element,
+                    const HTML_ARGS_FORMATTED *args_formatted,
+                    const char *content, TEXT *result)
+{
+  STRING_LIST *classes;
+  char *attribute_class;
+
+  if (!content || !strlen (content))
+    return;
+
+  if (html_in_string (self))
+    {
+      text_append (result, content);
+    }
+
+  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, "table", classes);
+  destroy_strings_list (classes);
+  text_append (result, attribute_class);
+  free (attribute_class);
+  text_append_n (result, ">\n", 2);
+  text_append (result, content);
+  text_append_n (result, "</table>\n", 9);
+}
+
+void
+convert_xtable_command (CONVERTER *self, const enum command_id cmd,
+                    const ELEMENT *element,
+                    const HTML_ARGS_FORMATTED *args_formatted,
+                    const char *content, TEXT *result)
+{
+  STRING_LIST *classes;
+  char *attribute_class;
+
+  if (!content || !strlen (content))
+    return;
+
+  if (html_in_string (self))
+    {
+      text_append (result, content);
+    }
+
+  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);
+  destroy_strings_list (classes);
+  text_append (result, attribute_class);
+  free (attribute_class);
+  text_append_n (result, ">\n", 2);
+  text_append (result, content);
+  text_append_n (result, "</dl>\n", 6);
+}
+
 void
 convert_xref_commands (CONVERTER *self, const enum command_id cmd,
                     const ELEMENT *element,
@@ -11870,6 +11930,10 @@ static COMMAND_INTERNAL_CONVERSION 
commands_internal_conversion_table[] = {
   {CM_cartouche, &convert_cartouche_command},
   {CM_itemize, convert_itemize_command},
   {CM_enumerate, convert_enumerate_command},
+  {CM_multitable, &convert_multitable_command},
+  {CM_table, &convert_xtable_command},
+  {CM_ftable, &convert_xtable_command},
+  {CM_vtable, &convert_xtable_command},
 
   {CM_verbatiminclude, &convert_verbatiminclude_command},
   {CM_sp, &convert_sp_command},



reply via email to

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