texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Sun, 31 Dec 2023 18:26:40 -0500 (EST)

branch: master
commit fc85b868c1ed27f228752fc6888ddf9f93c42b82
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Dec 31 19:49:43 2023 +0100

    * tp/Texinfo/Convert/Converter.pm (table_item_content_tree),
    tp/Texinfo/Convert/Plaintext.pm (_convert): remove
    table_item_content_tree contents element, instead always use
    $element->{'args'}->[0] in the function.  Return the @-command
    used to format the item argument directly, undef if there is no
    command_as_argument.  Update callers to set tree to
    $element->{'args'}->[0] if the return value is undef.  Also do not
    modify the element returned in Plaintext.pm.
---
 ChangeLog                       | 11 +++++++++++
 tp/Texinfo/Convert/Converter.pm | 35 ++++++++++++++---------------------
 tp/Texinfo/Convert/DocBook.pm   | 10 ++++++----
 tp/Texinfo/Convert/HTML.pm      |  8 +++++---
 tp/Texinfo/Convert/Plaintext.pm | 14 +++++++-------
 5 files changed, 43 insertions(+), 35 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bf541c042c..9ab4444d2a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,17 @@
 
        No functional changes intended.
 
+2023-12-31  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/Converter.pm (table_item_content_tree),
+       tp/Texinfo/Convert/Plaintext.pm (_convert): remove
+       table_item_content_tree contents element, instead always use
+       $element->{'args'}->[0] in the function.  Return the @-command
+       used to format the item argument directly, undef if there is no
+       command_as_argument.  Update callers to set tree to
+       $element->{'args'}->[0] if the return value is undef.  Also do not
+       modify the element returned in Plaintext.pm.
+
 2023-12-31  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/HTML.pm (_convert_multitable_command)
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index a61ec41b1c..451deae413 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -1465,28 +1465,22 @@ sub format_comment_or_return_end_line($$)
   return $end_line;
 }
 
-sub table_item_content_tree($$$)
+sub table_item_content_tree($$)
 {
   my $self = shift;
   my $element = shift;
-  my $contents = shift;
-
-  my $table_item_tree = {'parent' => $element};
-
-  return $table_item_tree
-    if (!defined($contents));
 
   my $table_command = $element->{'parent'}->{'parent'}->{'parent'};
-  if ($table_command->{'extra'}
-     and $table_command->{'extra'}->{'command_as_argument'}) {
+  if (defined($element->{'args'}) and scalar(@{$element->{'args'}})
+      and $table_command->{'extra'}
+      and $table_command->{'extra'}->{'command_as_argument'}) {
     my $command_as_argument
       = $table_command->{'extra'}->{'command_as_argument'};
     my $command = {'cmdname' => $command_as_argument->{'cmdname'},
-               'source_info' => $element->{'source_info'},
-               'parent' => $table_item_tree };
+                   'source_info' => $element->{'source_info'},
+                   'parent' => $element};
     if ($table_command->{'extra'}->{'command_as_argument_kbd_code'}) {
-      $command->{'extra'} = {} if (!$command->{'extra'});
-      $command->{'extra'}->{'code'} = 1;
+      $command->{'extra'} = {'code' => 1};
     }
     if ($command_as_argument->{'type'} eq 'definfoenclose_command') {
       $command->{'type'} = $command_as_argument->{'type'};
@@ -1495,13 +1489,12 @@ sub table_item_content_tree($$$)
       $command->{'extra'}->{'end'} = $command_as_argument->{'extra'}->{'end'};
     }
     my $arg = {'type' => 'brace_command_arg',
-               'contents' => $contents,
+               'contents' => [$element->{'args'}->[0]],
                'parent' => $command,};
     $command->{'args'} = [$arg];
-    $contents = [$command];
+    return $command;
   }
-  $table_item_tree->{'contents'} = $contents;
-  return $table_item_tree;
+  return undef;
 }
 
 sub convert_accents($$$;$$)
@@ -2382,13 +2375,13 @@ variables are set.
 For more information on the function used to set the value for each of the 
command, see
 L<Texinfo::Common set_global_document_command|Texinfo::Common/$element = 
set_global_document_command($customization_information, 
$global_commands_information, $cmdname, $command_location)>.
 
-=item $table_item_tree = $converter->table_item_content_tree($element, 
$contents)
+=item $table_item_tree = $converter->table_item_content_tree($element)
 X<C<table_item_content_tree>>
 
-I<$element> should be an C<@item> or C<@itemx> tree element,
-I<$contents> should be corresponding texinfo tree contents.
+I<$element> should be an C<@item> or C<@itemx> tree element.
 Returns a tree in which the @-command in argument of C<@*table>
-of the I<$element> has been applied to I<$contents>.
+of the I<$element> has been applied to the I<$element> line argument,
+or C<undef>.
 
 =item $result = $converter->top_node_filename($document_name)
 X<C<top_node_filename>>
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index 91917ebab3..56ebfe6687 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -779,16 +779,18 @@ sub _convert($$;$)
           $self->{'pending_prepend'} .= " ";
         }
         push @close_format_elements, 'listitem';
-      } elsif (($element->{'cmdname'} eq 'item' or $element->{'cmdname'} eq 
'itemx')
+      } elsif (($element->{'cmdname'} eq 'item'
+                or $element->{'cmdname'} eq 'itemx')
                and $element->{'parent'}->{'type'}
                and $element->{'parent'}->{'type'} eq 'table_term') {
 
         $result .= "<term>" if ($element->{'cmdname'} eq 'itemx');
         $result .= $self->_index_entry($element);
-        if ($element->{'args'}->[0]
+        if ($element->{'args'} and scalar(@{$element->{'args'}})
             and $element->{'args'}->[0]->{'contents'}) {
-          my $table_item_tree = $self->table_item_content_tree($element,
-                                         
$element->{'args'}->[0]->{'contents'});
+          my $table_item_tree = $self->table_item_content_tree($element);
+          $table_item_tree = $element->{'args'}->[0]
+            if (!defined($table_item_tree));
 
           $result .= $self->_convert($table_item_tree);
         }
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 00e9e0e07c..dd65f96a57 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -5768,9 +5768,11 @@ sub _convert_item_command($$$$$)
     }
   } elsif ($command->{'parent'}->{'type'}
            and $command->{'parent'}->{'type'} eq 'table_term') {
-    if ($args->[0]) {
-      my $table_item_tree = $self->table_item_content_tree($command,
-                                                [$args->[0]->{'tree'}]);
+    if ($command->{'args'} and scalar(@{$command->{'args'}})
+        and $command->{'args'}->[0]->{'contents'}) {
+      my $table_item_tree = $self->table_item_content_tree($command);
+      $table_item_tree = $command->{'args'}->[0]
+        if (!defined($table_item_tree));
       my $result = $self->convert_tree($table_item_tree,
                                        'convert table_item_tree');
       if (in_preformatted_context($self)) {
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index b15163d877..c2568269d9 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -2890,14 +2890,14 @@ sub _convert($$)
             and $element->{'args'} and $element->{'args'}->[0]
             and $element->{'args'}->[0]->{'type'}
             and $element->{'args'}->[0]->{'type'} eq 'line_arg') {
-      if ($element->{'args'} and @{$element->{'args'}}
+      if ($element->{'args'} and scalar(@{$element->{'args'}})
           and $element->{'args'}->[0]->{'contents'}) {
-
-        my $table_item_tree = $self->table_item_content_tree($element,
-                                         
$element->{'args'}->[0]->{'contents'});
-
-        $table_item_tree->{'type'} = 'frenchspacing';
-        $result = $self->convert_line($table_item_tree,
+        my $table_item_tree = $self->table_item_content_tree($element);
+        $table_item_tree = $element->{'args'}->[0]
+          if (!defined($table_item_tree));
+        my $frenchspacing_element = {'type' => 'frenchspacing',
+                                     'contents' => [$table_item_tree]};
+        $result = $self->convert_line($frenchspacing_element,
              {'indent_length' =>
                  ($self->{'format_context'}->[-1]->{'indent_level'} -1)
                    * $indent_length});



reply via email to

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