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_def_comman


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/HTML.pm (_convert_def_command): move code to be with other commands conversion.
Date: Sat, 06 Jan 2024 06:15:38 -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 45e8dfa86e * tp/Texinfo/Convert/HTML.pm (_convert_def_command): move 
code to be with other commands conversion.
45e8dfa86e is described below

commit 45e8dfa86e2d1336b1beb4602a15371fea03b46b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Jan 6 12:15:38 2024 +0100

    * tp/Texinfo/Convert/HTML.pm (_convert_def_command): move code to be
    with other commands conversion.
    
    * tp/Texinfo/XS/convert/convert_html.c (convert_def_item_type)
    (convert_table_definition_type, types_internal_conversion_table):
    implement convert_def_item_type and convert_table_definition_type in
    C.
---
 ChangeLog                            | 10 ++++++
 tp/Texinfo/Convert/HTML.pm           | 69 ++++++++++++++++++------------------
 tp/Texinfo/XS/convert/convert_html.c | 51 ++++++++++++++++++++++++++
 3 files changed, 96 insertions(+), 34 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 442619422b..4c2f231fd8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-01-06  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (_convert_def_command): move code to be
+       with other commands conversion.
+
+       * tp/Texinfo/XS/convert/convert_html.c (convert_def_item_type)
+       (convert_table_definition_type, types_internal_conversion_table):
+       implement convert_def_item_type and convert_table_definition_type in
+       C.
+
 2024-01-06  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/options_data.txt (CSS_REFS): set type to char_string_list
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 805077f2b0..ce89ff216c 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -6680,6 +6680,41 @@ foreach my $contents_comand (@contents_commands) {
   $default_commands_conversion{$contents_comand} = \&_convert_contents_command;
 }
 
+sub _convert_def_command($$$$$) {
+  my $self = shift;
+  my $cmdname = shift;
+  my $command = shift;
+  my $args = shift;
+  my $content = shift;
+
+  $content = '' if (!defined($content));
+
+  return $content if (in_string($self));
+
+  my @classes;
+  my $command_name;
+  if ($Texinfo::Common::def_aliases{$cmdname}) {
+    $command_name = $Texinfo::Common::def_aliases{$cmdname};
+    push @classes, "first-$cmdname-alias-first-$command_name";
+  } else {
+    $command_name = $cmdname;
+  }
+  unshift @classes, "first-$command_name";
+
+  if (!$self->get_conf('DEF_TABLE')) {
+    return $self->html_attribute_class('dl', \@classes).">\n"
+                                        . $content ."</dl>\n";
+  } else {
+    return $self->html_attribute_class('table', \@classes)." width=\"100%\">\n"
+                                                     . $content . "</table>\n";
+  }
+}
+
+foreach my $command (keys(%def_commands), 'defblock') {
+  $default_commands_conversion{$command} = \&_convert_def_command;
+}
+
+
 # associate same formatting function for @small* command
 # as for the associated @-command
 foreach my $small_command (keys(%small_block_associated_command)) {
@@ -7668,40 +7703,6 @@ sub _convert_def_item_type($$$$)
 $default_types_conversion{'def_item'} = \&_convert_def_item_type;
 $default_types_conversion{'inter_def_item'} = \&_convert_def_item_type;
 
-sub _convert_def_command($$$$$) {
-  my $self = shift;
-  my $cmdname = shift;
-  my $command = shift;
-  my $args = shift;
-  my $content = shift;
-
-  $content = '' if (!defined($content));
-
-  return $content if (in_string($self));
-
-  my @classes;
-  my $command_name;
-  if ($Texinfo::Common::def_aliases{$cmdname}) {
-    $command_name = $Texinfo::Common::def_aliases{$cmdname};
-    push @classes, "first-$cmdname-alias-first-$command_name";
-  } else {
-    $command_name = $cmdname;
-  }
-  unshift @classes, "first-$command_name";
-
-  if (!$self->get_conf('DEF_TABLE')) {
-    return $self->html_attribute_class('dl', \@classes).">\n"
-                                        . $content ."</dl>\n";
-  } else {
-    return $self->html_attribute_class('table', \@classes)." width=\"100%\">\n"
-                                                     . $content . "</table>\n";
-  }
-}
-
-foreach my $command (keys(%def_commands), 'defblock') {
-  $default_commands_conversion{$command} = \&_convert_def_command;
-}
-
 sub _convert_table_definition_type($$$$)
 {
   my $self = shift;
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 16d94d570e..d41e182256 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -14594,13 +14594,64 @@ convert_def_line_type (CONVERTER *self, const enum 
element_type type,
   free (anchor);
 }
 
+void
+convert_def_item_type (CONVERTER *self, const enum element_type type,
+                       const ELEMENT *element, const char *content,
+                       TEXT *result)
+{
+  if (!content)
+    return;
+
+  if (html_in_string (self))
+    text_append (result, content);
+
+  if (content[strspn (content, whitespace_chars)] == '\0')
+    return;
+
+  if (self->conf->DEF_TABLE.integer <= 0)
+    {
+      text_append_n (result, "<dd>", 4);
+      text_append (result, content);
+      text_append_n (result, "</dd>", 5);
+    }
+  else
+    {
+      text_append_n (result, "<tr><td colspan=\"2\">", 20);
+      text_append (result, content);
+      text_append_n (result, "</td></tr>", 10);
+    }
+}
+
+void
+convert_table_definition_type (CONVERTER *self, const enum element_type type,
+                       const ELEMENT *element, const char *content,
+                       TEXT *result)
+{
+  if (!content)
+    return;
+
+  if (html_in_string (self))
+    text_append (result, content);
+
+  if (content[strspn (content, whitespace_chars)] == '\0')
+    return;
+
+  text_append_n (result, "<dd>", 4);
+  text_append (result, content);
+  text_append_n (result, "</dd>\n", 6);
+}
+
 /* associate type to the C function implementing the conversion */
 static TYPE_INTERNAL_CONVERSION types_internal_conversion_table[] = {
   {ET_balanced_braces, &convert_balanced_braces_type},
   {ET_before_item, convert_before_item_type},
+  {ET_def_item, &convert_def_item_type},
+  {ET_inter_def_item, &convert_def_item_type},
   {ET_def_line, &convert_def_line_type},
   {ET_definfoenclose_command, &convert_definfoenclose_type},
   {ET_index_entry_command, &convert_index_entry_command_type},
+  {ET_table_definition, &convert_table_definition_type},
+  {ET_inter_item, &convert_table_definition_type},
   {ET_menu_comment, &convert_menu_comment_type},
   {ET_menu_entry, convert_menu_entry_type},
   {ET_multitable_body, &convert_multitable_body_type},



reply via email to

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