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_indented_c


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/HTML.pm (_convert_indented_command): modify code to handle first the cases leading to returning contents or nothing.
Date: Sat, 30 Dec 2023 18:23:56 -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 d77bebe6f1 * tp/Texinfo/Convert/HTML.pm (_convert_indented_command): 
modify code to handle first the cases leading to returning contents or nothing.
d77bebe6f1 is described below

commit d77bebe6f1bd7f5b4db99524c22c7faf43eba247
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Dec 31 00:23:53 2023 +0100

    * tp/Texinfo/Convert/HTML.pm (_convert_indented_command): modify code
    to handle first the cases leading to returning contents or nothing.
    
    * tp/Texinfo/XS/convert/convert_html.c (convert_indented_command)
    (commands_internal_conversion_table): implement
    convert_indented_command.
---
 ChangeLog                            |  9 +++++
 tp/Texinfo/Convert/HTML.pm           | 23 +++++++------
 tp/Texinfo/XS/convert/convert_html.c | 64 ++++++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c316c31d9c..86238cdd02 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-12-30  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (_convert_indented_command): modify code
+       to handle first the cases leading to returning contents or nothing.
+
+       * tp/Texinfo/XS/convert/convert_html.c (convert_indented_command)
+       (commands_internal_conversion_table): implement
+       convert_indented_command.
+
 2023-12-30  Gavin Smith <gavinsmith0123@gmail.com>
 
        * tp/Texinfo/Convert/Plaintext.pm (_convert) <'menu_entry'>:
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 3d48cb10c8..d78ac95516 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -5078,7 +5078,13 @@ sub _convert_indented_command($$$$$)
   my $args = shift;
   my $content = shift;
 
-  $content = '' if (!defined($content));
+  if (!defined($content) or $content eq '') {
+    return '';
+  }
+
+  if (in_string($self)) {
+    return $content;
+  }
 
   my @classes;
 
@@ -5089,16 +5095,13 @@ sub _convert_indented_command($$$$$)
   } else {
     $main_cmdname = $cmdname;
   }
-  if ($content ne '' and !in_string($self)) {
-    if ($self->get_conf('COMPLEX_FORMAT_IN_TABLE')) {
-      return _indent_with_table($self, $main_cmdname, $content, \@classes);
-    } else {
-      unshift @classes, $main_cmdname;
-      return $self->html_attribute_class('blockquote', \@classes).">\n"
-                          . $content . '</blockquote>'."\n";
-    }
+
+  if ($self->get_conf('COMPLEX_FORMAT_IN_TABLE')) {
+    return _indent_with_table($self, $main_cmdname, $content, \@classes);
   } else {
-    return $content;
+    unshift @classes, $main_cmdname;
+    return $self->html_attribute_class('blockquote', \@classes).">\n"
+                        . $content . '</blockquote>'."\n";
   }
 }
 
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index a5234502c5..8094d85a31 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -10022,6 +10022,67 @@ convert_preformatted_command (CONVERTER *self, const 
enum command_id cmd,
   free (additional_classes);
 }
 
+void
+convert_indented_command (CONVERTER *self, const enum command_id cmd,
+                    const ELEMENT *element,
+                    const HTML_ARGS_FORMATTED *args_formatted,
+                    const char *content, TEXT *result)
+{
+  enum command_id main_cmd = 0;
+  STRING_LIST *additional_classes;
+
+  if (!content || !strlen (content))
+    return;
+
+  if (html_in_string (self))
+    {
+      text_append (result, content);
+      return;
+    }
+
+  additional_classes = (STRING_LIST *) malloc (sizeof (STRING_LIST));
+  memset (additional_classes, 0, sizeof (STRING_LIST));
+
+  if (html_commands_data[cmd].flags & HF_small_block_command)
+    {
+      int i;
+      for (i = 0; small_block_associated_command[i][0]; i++)
+        {
+          enum command_id small_cmd = small_block_associated_command[i][0];
+          if (small_cmd == cmd)
+            {
+              main_cmd = small_block_associated_command[i][1];
+              add_string (builtin_command_name (cmd), additional_classes);
+              break;
+            }
+        }
+    }
+  else
+    main_cmd = cmd;
+
+  if (self->conf->COMPLEX_FORMAT_IN_TABLE > 0)
+    {
+      indent_with_table (self, main_cmd, content,
+                         additional_classes, result);
+    }
+  else
+    {
+      char *attribute_class;
+      STRING_LIST *classes = (STRING_LIST *) malloc (sizeof (STRING_LIST));
+      memset (classes, 0, sizeof (STRING_LIST));
+      add_string (builtin_command_name (main_cmd), classes);
+      merge_strings (classes, additional_classes);
+      attribute_class = html_attribute_class (self, "blockquote", classes);
+      text_append (result, attribute_class);
+      text_printf (result, ">\n%s</blockquote>\n", content);
+      free (attribute_class);
+      destroy_strings_list (classes);
+    }
+
+  free (additional_classes->list);
+  free (additional_classes);
+}
+
 void
 convert_xref_commands (CONVERTER *self, const enum command_id cmd,
                     const ELEMENT *element,
@@ -10871,6 +10932,9 @@ static COMMAND_INTERNAL_CONVERSION 
commands_internal_conversion_table[] = {
   {CM_inlineifclear, &convert_inline_command},
   {CM_inlineifset, &convert_inline_command},
 
+  {CM_indentedblock, &convert_indented_command},
+  {CM_smallindentedblock, &convert_indented_command},
+
   {CM_contents, &convert_contents_command},
   {CM_shortcontents, &convert_contents_command},
   {CM_summarycontents, &convert_contents_command},



reply via email to

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