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, tp/ext/highlight_sy


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/HTML.pm, tp/ext/highlight_syntax.pm, tp/init/documentation_examples.pm, tp/init/html32.pm, tp/t/init/ignore_and_comments_output.init, tp/t/init/mini_ker_t2h.init, tp/t/init/t2h_singular.init: handle undef contents for all commands and types conversion functions (and undef args).
Date: Sun, 05 Nov 2023 10:32:44 -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 de9c991605 * tp/Texinfo/Convert/HTML.pm, tp/ext/highlight_syntax.pm, 
tp/init/documentation_examples.pm, tp/init/html32.pm, 
tp/t/init/ignore_and_comments_output.init, tp/t/init/mini_ker_t2h.init, 
tp/t/init/t2h_singular.init: handle undef contents for all commands and types 
conversion functions (and undef args).
de9c991605 is described below

commit de9c99160574dcb4e71b5c26852aa58e310abf50
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Nov 5 16:29:59 2023 +0100

    * tp/Texinfo/Convert/HTML.pm, tp/ext/highlight_syntax.pm,
    tp/init/documentation_examples.pm, tp/init/html32.pm,
    tp/t/init/ignore_and_comments_output.init,
    tp/t/init/mini_ker_t2h.init, tp/t/init/t2h_singular.init: handle undef
    contents for all commands and types conversion functions (and undef
    args).
---
 ChangeLog                                 |  9 ++++
 doc/texi2any_api.texi                     |  5 +-
 tp/Texinfo/Convert/HTML.pm                | 86 +++++++++++++++++++++++++------
 tp/ext/highlight_syntax.pm                |  1 +
 tp/init/documentation_examples.pm         |  2 +
 tp/init/html32.pm                         | 12 +++++
 tp/t/init/ignore_and_comments_output.init |  4 +-
 tp/t/init/mini_ker_t2h.init               |  1 +
 tp/t/init/t2h_singular.init               |  2 +
 9 files changed, 102 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7212aab50a..96f99608c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,15 @@
        This gets back to the execution times from texi2any 7.1 (with XS
        enabled only).
 
+2023-11-05  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm, tp/ext/highlight_syntax.pm,
+       tp/init/documentation_examples.pm, tp/init/html32.pm,
+       tp/t/init/ignore_and_comments_output.init,
+       tp/t/init/mini_ker_t2h.init, tp/t/init/t2h_singular.init: handle undef
+       contents for all commands and types conversion functions (and undef
+       args).
+
 2023-11-05  Patrice Dumas  <pertusus@free.fr>
 
        Change customization of translations to target only translated string
diff --git a/doc/texi2any_api.texi b/doc/texi2any_api.texi
index 382769bebc..f7bc58f115 100644
--- a/doc/texi2any_api.texi
+++ b/doc/texi2any_api.texi
@@ -4037,8 +4037,9 @@ formats the footer and navigation panel of a output unit.
     @var{$content}, @var{$command})
 @var{\%output_unit} is the output unit in which the
 navigation footer is formatted.  @var{$tree_unit_type} is the associated type.
-@var{$content} is the formatted element content.  @var{$command} is an optional
-argument, the @@-command associated with the @var{\%output_unit}.
+@var{$content} is the formatted element content.  @var{$content} can be
+@code{undef}. @var{$command} is an optional argument, the @@-command
+associated with the @var{\%output_unit}.
 
 Returns the formatted navigation footer and panel.
 
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index a9c664dde9..66f9b52029 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -4518,6 +4518,8 @@ sub _convert_raw_command($$$$$)
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   if ($cmdname eq 'html') {
     return $content;
   }
@@ -4597,6 +4599,8 @@ sub _convert_preformatted_command($$$$$)
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   my @classes;
 
   # this is mainly for classes as there are purprosely no classes
@@ -4654,6 +4658,8 @@ sub _convert_indented_command($$$$$)
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   my @classes;
 
   my $main_cmdname;
@@ -4686,6 +4692,8 @@ sub _convert_verbatim_command($$$$$)
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   if (!$self->in_string()) {
     return $self->html_attribute_class('pre', [$cmdname]).'>'
           .$content . '</pre>';
@@ -4704,6 +4712,8 @@ sub _convert_displaymath_command($$$$$)
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   if ($self->in_string()) {
     return $content;
   }
@@ -4752,6 +4762,8 @@ sub _convert_command_simple_block($$$$$)
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   return $self->html_attribute_class('div', [$cmdname]).'>'
         .$content.'</div>';
 }
@@ -4835,7 +4847,7 @@ sub _convert_author_command($$$$)
   my $command = shift;
   my $args = shift;
 
-  return '' if (!$args->[0] or !$command->{'extra'}
+  return '' if (!$args or !$args->[0] or !$command->{'extra'}
                 or !$command->{'extra'}->{'titlepage'});
   if (!$self->in_string()) {
     return $self->html_attribute_class('strong', [$cmdname])
@@ -4854,7 +4866,7 @@ sub _convert_title_command($$$$)
   my $cmdname = shift;
   my $command = shift;
   my $args = shift;
-  return '' if (!$args->[0]);
+  return '' if (!$args or !$args->[0]);
   if (!$self->in_string()) {
     return $self->html_attribute_class('h1', [$cmdname])
                             .">$args->[0]->{'normal'}</h1>\n";
@@ -4871,7 +4883,7 @@ sub _convert_subtitle_command($$$$)
   my $command = shift;
   my $args = shift;
 
-  return '' if (!$args->[0]);
+  return '' if (!$args or !$args->[0]);
   if (!$self->in_string()) {
     return $self->html_attribute_class('h3', [$cmdname])
                             .">$args->[0]->{'normal'}</h3>\n";
@@ -4973,6 +4985,8 @@ sub _convert_menu_command($$$$$)
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   return $content if ($cmdname eq 'detailmenu');
 
   my $html_menu_entry_index
@@ -5010,6 +5024,8 @@ sub _convert_float_command($$$$$)
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   my ($caption, $prepended)
      = Texinfo::Convert::Converter::float_name_caption($self, $command);
   my $caption_command_name;
@@ -5093,6 +5109,8 @@ sub _convert_quotation_command($$$$$)
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   $self->cancel_pending_formatted_inline_content($cmdname);
 
   my @classes;
@@ -5140,10 +5158,12 @@ sub _convert_cartouche_command($$$$$)
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   return $content if ($self->in_string());
 
   my $title_content = '';
-  if ($args->[0] and $args->[0]->{'normal'} ne '') {
+  if ($args and $args->[0] and $args->[0]->{'normal'} ne '') {
     $title_content = "<tr><th>\n". $args->[0]->{'normal'} ."</th></tr>";
   }
   my $cartouche_content = '';
@@ -5168,6 +5188,8 @@ sub _convert_itemize_command($$$$$)
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   if ($self->in_string()) {
     return $content;
   }
@@ -5225,12 +5247,12 @@ sub _convert_enumerate_command($$$$$)
   my $args = shift;
   my $content = shift;
 
-  if ($self->in_string()) {
-    return $content;
-  }
-  if ($content eq '') {
+  if (!defined($content) or $content eq '') {
     return '';
+  } elsif ($self->in_string()) {
+    return $content;
   }
+
   my $type_attribute = '';
   my $start_attribute = '';
   my $specification = $command->{'extra'}->{'enumerate_specification'};
@@ -5262,6 +5284,8 @@ sub _convert_multitable_command($$$$$)
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   if ($self->in_string()) {
     return $content;
   }
@@ -5283,6 +5307,8 @@ sub _convert_xtable_command($$$$$)
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   if ($self->in_string()) {
     return $content;
   }
@@ -5305,6 +5331,8 @@ sub _convert_item_command($$$$$)
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   if ($self->in_string()) {
     return $content;
   }
@@ -5394,6 +5422,8 @@ sub _convert_tab_command($$$$$)
     }
   }
 
+  $content = '' if (!defined($content));
+
   $content =~ s/^\s*//;
   $content =~ s/\s*$//;
 
@@ -6339,6 +6369,8 @@ sub _convert_paragraph_type($$$$)
   my $element = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   $content = $self->get_associated_formatted_inline_content($element).$content;
 
   if ($self->paragraph_number() == 1) {
@@ -6414,10 +6446,7 @@ sub _convert_preformatted_type($$$$)
   my $element = shift;
   my $content = shift;
 
-  if (!defined($content)) {
-    cluck "content undef in _convert_preformatted_type "
-       .Texinfo::Common::debug_print_element($element, 1);
-  }
+  $content = '' if (!defined($content));
 
   $content = $self->get_associated_formatted_inline_content($element).$content;
 
@@ -6471,6 +6500,8 @@ sub _convert_balanced_braces_type($$$$) {
   my $element = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   return $content;
 }
 
@@ -6505,6 +6536,8 @@ sub _convert_definfoenclose_type($$$$) {
   my $element = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   # FIXME add a span to mark the original command as a class?
   return &{$self->formatting_function('format_protect_text')}($self,
                                       $element->{'extra'}->{'begin'})
@@ -6664,7 +6697,10 @@ sub _convert_row_type($$$$) {
   my $element = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   return $content if ($self->in_string());
+
   if ($content =~ /\S/) {
     my $result = '<tr>' . $content . '</tr>';
     if ($element->{'contents'}
@@ -6686,7 +6722,10 @@ sub _convert_multitable_head_type($$$$) {
   my $element = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   return $content if ($self->in_string());
+
   if ($content =~ /\S/) {
     return '<thead>' . $content . '</thead>' . "\n";
   } else {
@@ -6950,6 +6989,8 @@ sub _convert_menu_comment_type($$$$)
   my $element = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   if ($self->_in_preformatted_in_menu() or $self->in_string()) {
     return $content;
   } else {
@@ -6992,6 +7033,8 @@ sub _convert_table_term_type($$$$)
   my $element = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   return '<dt>'.$content;
 }
 
@@ -7187,7 +7230,10 @@ sub _convert_def_item_type($$$$)
   my $element = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   return $content if ($self->in_string());
+
   if ($content =~ /\S/) {
     if (! $self->get_conf('DEF_TABLE')) {
       return '<dd>' . $content . '</dd>';
@@ -7207,6 +7253,8 @@ sub _convert_def_command($$$$$) {
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   return $content if ($self->in_string());
 
   my @classes;
@@ -7239,7 +7287,10 @@ sub _convert_table_definition_type($$$$)
   my $element = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   return $content if ($self->in_string());
+
   if ($content =~ /\S/) {
     return '<dd>' . $content . '</dd>'."\n";
   }
@@ -7333,6 +7384,8 @@ sub _convert_special_unit_type($$$$)
   my $element = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   if ($self->in_string()) {
     return '';
   }
@@ -7398,12 +7451,10 @@ sub _convert_unit_type($$$$)
   my $element = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   if ($self->in_string()) {
-    if (defined($content)) {
-      return $content;
-    } else {
-      return '';
-    }
+    return $content;
   }
   my $result = '';
   my $output_unit = $element;
@@ -7503,6 +7554,7 @@ sub _default_format_element_footer($$$$;$)
       if ($self->get_conf('HEADERS')) {
         my $no_footer_word_count;
         if ($self->get_conf('WORDS_IN_PAGE')) {
+          $content = '' if (!defined($content));
           # FIXME it seems that NO-BREAK SPACE and NEXT LINE (NEL) may
           # not be in \h and \v in some case, but not sure which case it is
           my @cnt = split(/\P{Word}*[\h\v]+\P{Word}*/, $content);
diff --git a/tp/ext/highlight_syntax.pm b/tp/ext/highlight_syntax.pm
index d16fe9d39d..c0a56df8e4 100644
--- a/tp/ext/highlight_syntax.pm
+++ b/tp/ext/highlight_syntax.pm
@@ -604,6 +604,7 @@ sub highlight_preformatted_command($$$$$)
         $commands{$cmdname}->{'output_languages_counters'}->{$language}++;
 
         if ($self->in_string()) {
+          $content = '' if (!defined($content));
           return $content;
         }
 
diff --git a/tp/init/documentation_examples.pm 
b/tp/init/documentation_examples.pm
index 77a9d5b34a..5d5454e0ed 100644
--- a/tp/init/documentation_examples.pm
+++ b/tp/init/documentation_examples.pm
@@ -120,6 +120,8 @@ sub my_convert_paragraph_type($$$$)
   my $element = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   return $content if ($converter->in_string());
 
   my @contents = @{$element->{'contents'}};
diff --git a/tp/init/html32.pm b/tp/init/html32.pm
index c345f4bc80..dc482f11fd 100644
--- a/tp/init/html32.pm
+++ b/tp/init/html32.pm
@@ -211,6 +211,8 @@ sub html32_convert_multitable_head_type($$$$) {
   my $element = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   return $content if ($self->in_string());
   if ($content =~ /\S/) {
     return $content . "\n";
@@ -226,6 +228,8 @@ sub html32_convert_multitable_body_type($$$$) {
   my $element = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   return $content if ($self->in_string());
   if ($content =~ /\S/) {
     return $content;
@@ -243,6 +247,8 @@ sub html32_convert_itemize_command($$$$$)
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   if ($self->in_string()) {
     return $content;
   }
@@ -263,6 +269,8 @@ sub html32_convert_tab_command($$$$$)
   my $row = $command->{'parent'};
   my $row_cmdname = $row->{'contents'}->[0]->{'cmdname'};
 
+  $content = '' if (!defined($content));
+
   # FIXME is it right?
   $content =~ s/^\s*//;
   $content =~ s/\s*$//;
@@ -287,6 +295,8 @@ sub html32_convert_item_command($$$$$)
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   if ($self->in_string()) {
     return $content;
   }
@@ -361,6 +371,8 @@ sub html32_convert_paragraph_type($$$$)
   my $element = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   $content = $self->get_associated_formatted_inline_content($element).$content;
 
   if ($self->paragraph_number() == 1) {
diff --git a/tp/t/init/ignore_and_comments_output.init 
b/tp/t/init/ignore_and_comments_output.init
index 59495821de..b4f7a023c5 100644
--- a/tp/t/init/ignore_and_comments_output.init
+++ b/tp/t/init/ignore_and_comments_output.init
@@ -24,8 +24,10 @@ sub convert_ignore_command($$$$$)
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   # FIXME should the spacing be set differently for raw commands?
-  return $self->xml_comment(" ".$content."\n");
+  return $self->xml_comment(" $content\n");
 }
 
 texinfo_register_command_formatting('ignore', \&convert_ignore_command);
diff --git a/tp/t/init/mini_ker_t2h.init b/tp/t/init/mini_ker_t2h.init
index d08f1b97f4..38f68c4ca6 100644
--- a/tp/t/init/mini_ker_t2h.init
+++ b/tp/t/init/mini_ker_t2h.init
@@ -8,6 +8,7 @@ sub mini_ker_element_type($$$$)
   my $content = shift;
 
   if ($self->unit_is_top_output_unit($element)) {
+    $content = '' if (!defined($content));
     my $result = '';
     $result .= &{$self->formatting_function('format_navigation_header')}($self,
           $self->get_conf('MISC_BUTTONS'), $type, $element)
diff --git a/tp/t/init/t2h_singular.init b/tp/t/init/t2h_singular.init
index 6cac5fee7c..4af597d6b6 100644
--- a/tp/t/init/t2h_singular.init
+++ b/tp/t/init/t2h_singular.init
@@ -298,6 +298,8 @@ sub t2h_sing_menu($$$$$)
   my $args = shift;
   my $content = shift;
 
+  $content = '' if (!defined($content));
+
   if ($content =~ /\S/) {
     return "<blockquote><table class=\"menu\" border=\"0\" 
cellspacing=\"0\">\n" . $content. "</table></blockquote>\n";
   }



reply via email to

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