texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/DocBook.pm (_convert): avoid


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/DocBook.pm (_convert): avoid formatting when contents is not set.
Date: Tue, 08 Nov 2022 14:51:39 -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 131ba09f6f * tp/Texinfo/Convert/DocBook.pm (_convert): avoid 
formatting when contents is not set.
131ba09f6f is described below

commit 131ba09f6f3e9e67367a29a45ca1e1120582c994
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Nov 8 20:51:29 2022 +0100

    * tp/Texinfo/Convert/DocBook.pm (_convert): avoid formatting when
    contents is not set.
    
    * tp/Texinfo/Convert/Converter.pm (table_item_content_tree):
    explicitely handle undef $contents argument.
---
 ChangeLog                       |  8 ++++++++
 tp/Texinfo/Convert/Converter.pm |  4 ++++
 tp/Texinfo/Convert/DocBook.pm   | 36 ++++++++++++++++++++++--------------
 3 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1816031484..6772007a3f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2022-11-08  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/DocBook.pm (_convert): avoid formatting when
+       contents is not set.
+
+       * tp/Texinfo/Convert/Converter.pm (table_item_content_tree):
+       explicitely handle undef $contents argument.
+
 2022-11-08  Gavin Smith  <gavinsmith0123@gmail.com>
 
        * doc/texinfo.texi (Adding Output Formats): Update name of
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 65dd89c138..b39dfca3af 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -1326,6 +1326,10 @@ sub table_item_content_tree($$$)
   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'}) {
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index f71ebde3f6..704f55dc88 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -394,8 +394,8 @@ sub output($$)
     if ($self->{'global_commands'}->{$title_cmdname}) {
       my $command = $self->{'global_commands'}->{$title_cmdname};
       next if (!$command->{'args'}
-               or (!$command->{'args'}->[0]->{'contents'}
-                   or $command->{'extra'}->{'missing_argument'}));
+               or !$command->{'args'}->[0]->{'contents'}
+               or $command->{'extra'}->{'missing_argument'});
       $fulltitle_command = $command;
       last;
     }
@@ -449,8 +449,8 @@ sub output($$)
     my $command = $self->{'global_commands'}->{'settitle'};
     $settitle_command = $command
       unless (!$command->{'args'}
-               or (!$command->{'args'}->[0]->{'contents'}
-                   or $command->{'extra'}->{'missing_argument'}));
+               or !$command->{'args'}->[0]->{'contents'}
+               or $command->{'extra'}->{'missing_argument'});
 
   }
 
@@ -465,12 +465,12 @@ sub output($$)
     my $command = $self->{'global_commands'}->{'top'};
     $fulltitle_command = $command
       unless (!$command->{'args'}
-               or (!$command->{'args'}->[0]->{'contents'}
-                   or $command->{'extra'}->{'missing_argument'}));
+               or !$command->{'args'}->[0]->{'contents'}
+               or $command->{'extra'}->{'missing_argument'});
   }
 
   my $title_info = '';
-  
+
   if ($fulltitle_command) {
     foreach my $element_command ([$fulltitle_command, 'title'],
                                  [$titleabbrev_command, 'titleabbrev']) {
@@ -703,7 +703,7 @@ sub _convert($$;$)
       #warn "  has no_arg_commands_formatting \n";
       my $command;
       if ($element->{'cmdname'} eq 'click'
-          and $element->{'extra'} 
+          and $element->{'extra'}
           and defined($element->{'extra'}->{'clickstyle'})) {
         $command = $element->{'extra'}->{'clickstyle'};
       } elsif ($self->{'document_context'}->[-1]->{'upper_case'}->[-1]
@@ -747,12 +747,15 @@ sub _convert($$;$)
                and $element->{'parent'}->{'type'}
                and $element->{'parent'}->{'type'} eq 'table_term') {
 
-        my $table_item_tree = $self->table_item_content_tree($element,
-                                         
$element->{'args'}->[0]->{'contents'});
-
         $result .= "<term>";
         $result .= $self->_index_entry($element);
-        $result .= $self->_convert($table_item_tree);
+        if ($element->{'args'}->[0]
+            and $element->{'args'}->[0]->{'contents'}) {
+          my $table_item_tree = $self->table_item_content_tree($element,
+                                         
$element->{'args'}->[0]->{'contents'});
+
+          $result .= $self->_convert($table_item_tree);
+        }
         chomp ($result);
         $result .= "\n";
         $result .= "</term>";
@@ -1030,6 +1033,7 @@ sub _convert($$;$)
           } else {
             if (scalar(@{$element->{'args'}}) == 5
                 and defined($element->{'args'}->[-1])
+                and $element->{'args'}->[-1]->{'contents'}
                 and @{$element->{'args'}->[-1]->{'contents'}}) {
               $book_contents = $element->{'args'}->[-1]->{'contents'};
             }
@@ -1329,7 +1333,9 @@ sub _convert($$;$)
       } elsif ($element->{'cmdname'} eq 'abbr' or $element->{'cmdname'} eq 
'acronym') {
         my $argument;
         if (scalar(@{$element->{'args'}}) >= 1
-            and defined($element->{'args'}->[0]) and 
@{$element->{'args'}->[0]->{'contents'}}) {
+            and defined($element->{'args'}->[0])
+            and $element->{'args'}->[0]->{'contents'}
+            and @{$element->{'args'}->[0]->{'contents'}}) {
           my $arg = $self->_convert({'contents' 
                       => $element->{'args'}->[0]->{'contents'}});
           if ($arg ne '') {
@@ -1344,7 +1350,9 @@ sub _convert($$;$)
         }
         #
         if (scalar(@{$element->{'args'}}) == 2
-           and defined($element->{'args'}->[-1]) and 
@{$element->{'args'}->[-1]->{'contents'}}) {
+           and defined($element->{'args'}->[-1])
+           and $element->{'args'}->[-1]->{'contents'}
+           and @{$element->{'args'}->[-1]->{'contents'}}) {
           if (defined($argument)) {
             my $tree = $self->gdt('{abbr_or_acronym} ({explanation})',
                            {'abbr_or_acronym' => {'type' => '_converted',



reply via email to

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