texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Sat, 17 Feb 2024 15:43:31 -0500 (EST)

branch: master
commit d35b7335c3f9f5e30cdd403ade13051cf310cafb
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Feb 17 21:43:27 2024 +0100

    * doc/texi2any_api.texi (Texinfo Tree Conversion Functions),
    tp/Texinfo/Convert/HTML.pm (convert_tree_new_formatting_context),
    tp/Texinfo/XS/convert/convert_html.c
    (convert_tree_new_formatting_context): make context string a mandatory
    argument.
    
    Reindent.
---
 ChangeLog                            | 10 ++++++++++
 doc/texi2any_api.texi                | 21 ++++++++++-----------
 tp/Texinfo/Convert/HTML.pm           | 35 ++++++++++++++++++-----------------
 tp/Texinfo/XS/convert/convert_html.c | 24 +++++++++---------------
 4 files changed, 47 insertions(+), 43 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ef7def0f9f..ee628d9b6c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-02-17  Patrice Dumas  <pertusus@free.fr>
+
+       * doc/texi2any_api.texi (Texinfo Tree Conversion Functions),
+       tp/Texinfo/Convert/HTML.pm (convert_tree_new_formatting_context),
+       tp/Texinfo/XS/convert/convert_html.c
+       (convert_tree_new_formatting_context): make context string a mandatory
+       argument.
+
+       Reindent.
+
 2024-02-17  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/HTML.pm (_default_format_special_body_about):
diff --git a/doc/texi2any_api.texi b/doc/texi2any_api.texi
index 439ec4400f..506a72f21a 100644
--- a/doc/texi2any_api.texi
+++ b/doc/texi2any_api.texi
@@ -1429,16 +1429,15 @@ For such cases, the function is
 @deftypefun {@var{$converted_text} =} 
@var{$converter}->convert_tree_new_formatting_context @
       (@var{\%element}, @var{$context}, @var{$multiple_pass}, 
@var{$global_context}, @
        @var{$block_command_name})
-@var{\%element} is a Texinfo tree element.  @var{$context} is an optional
-string describing the new context to be setup to format out of the main
-conversion flow.  If not defined, the conversion is done in the main document
-flow.  @var{$multiple_pass} is an optional string that marks that the
-conversion is done more than once.  It should be unique and suitable for
-inclusion in targets and identifiers.  @var{$global_context} is an optional
-string that marks that the formatting may be done in advance, and can be
-redone.  @var{$block_command_name} is an optional block command name that is
-used to initialized the new context.  It can be useful, in particular, to 
propagate
-the topmost block command in the new context.
+@var{\%element} is a Texinfo tree element.  @var{$context} describes the new
+context setup to format out of the main conversion flow.  @var{$multiple_pass}
+is an optional string that marks that the conversion is done more than once.
+It should be unique and suitable for inclusion in targets and identifiers.
+@var{$global_context} is an optional string that marks that the formatting may
+be done in advance, and can be redone.  @var{$block_command_name} is an
+optional block command name that is used to initialized the new context.  It
+can be useful, in particular, to propagate the topmost block command in the new
+context.
 
 The function returns @var{\%element} converted, setting the conversion context
 according to the arguments.
@@ -3560,7 +3559,7 @@ Retrieve the @var{$direction} (@pxref{Directions}) string 
of type
 @var{$string_type} (@pxref{Direction Strings}).  @var{$context} is
 @samp{normal} or @samp{string}.  @xref{Init File Expansion Contexts}.  If
 @var{$context} is @code{undef}, the @samp{normal} context is assumed.
-The string will be translated if needed.
+The string will be translated if needed.  May return @code{undef}.
 @end deftypefun
 
 
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 830f0fdb20..c63b5642c6 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -2372,10 +2372,8 @@ sub get_info($$)
   return undef;
 }
 
-# This function should be used in formatting functions when some
-# Texinfo tree need to be converted.
-# FIXME make $context_string a non-optional argument?
-sub convert_tree_new_formatting_context($$;$$$$)
+# Call convert_tree out of the main conversion flow.
+sub convert_tree_new_formatting_context($$$;$$$)
 {
   my $self = shift;
   my $tree = shift;
@@ -2384,28 +2382,29 @@ sub convert_tree_new_formatting_context($$;$$$$)
   my $document_global_context = shift;
   my $block_command = shift;
 
-  my $context_string_str = '';
-  if (defined($context_string)) {
-    $self->_new_document_context($context_string, $document_global_context,
-                                 $block_command);
-    $context_string_str = "C($context_string)";
-  }
+  $self->_new_document_context($context_string, $document_global_context,
+                               $block_command);
+
+  my $context_string_str = "C($context_string)";
   my $multiple_pass_str = '';
+
   if ($multiple_pass) {
     $self->{'ignore_notice'}++;
     push @{$self->{'multiple_pass'}}, $multiple_pass;
     $multiple_pass_str = '|M'
   }
+
   print STDERR "new_fmt_ctx ${context_string_str}${multiple_pass_str}\n"
         if ($self->get_conf('DEBUG'));
   my $result = $self->convert_tree($tree, "new_fmt_ctx ${context_string_str}");
-  if (defined($context_string)) {
-    $self->_pop_document_context();
-  }
+
   if ($multiple_pass) {
     $self->{'ignore_notice'}--;
     pop @{$self->{'multiple_pass'}};
   }
+
+  $self->_pop_document_context();
+
   return $result;
 }
 
@@ -11533,7 +11532,8 @@ sub _default_format_special_body_shortcontents($$$)
   my $special_type = shift;
   my $element = shift;
 
-  return &{$self->formatting_function('format_contents')}($self, 
'shortcontents');
+  return &{$self->formatting_function('format_contents')}($self,
+                                                          'shortcontents');
 }
 
 sub _default_format_special_body_footnotes($$$)
@@ -11560,8 +11560,8 @@ sub _do_jslicenses_file {
 
   my $doctype = $self->get_conf('DOCTYPE');
   my $root_html_element_attributes = 
$self->_root_html_element_attributes_string();
-  my $a = $doctype . "\n" .
-"<html${root_html_element_attributes}>".'<head><title>jslicense 
labels</title></head>
+  my $a = $doctype . "\n" ."<html${root_html_element_attributes}>"
+   .'<head><title>jslicense labels</title></head>
 <body>
 <table id="jslicense-labels1">
 ';
@@ -11571,7 +11571,8 @@ sub _do_jslicenses_file {
     foreach my $file (sort(keys %{$jslicenses->{$category}})) {
       my $file_info = $jslicenses->{$category}->{$file};
       $a .= "<tr>\n";
-      $a .= '<td><a 
href="'.$self->url_protect_url_text($file)."\">$file</a></td>\n";
+      $a .= '<td><a href="'.
+                 $self->url_protect_url_text($file)."\">$file</a></td>\n";
       $a .= '<td><a href="'.$self->url_protect_url_text($file_info->[1])
                                          ."\">$file_info->[0]</a></td>\n";
       $a .= '<td><a href="'.$self->url_protect_url_text($file_info->[2])
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 280def38b4..b751df09ce 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -2776,8 +2776,8 @@ html_convert_tree (CONVERTER *self, const ELEMENT *tree, 
char *explanation)
   return result.text;
 }
 
-/* This function should be used in formatting functions when some
-   Texinfo tree need to be converted. */
+/* Call convert_tree out of the main conversion flow.
+ */
 char *
 convert_tree_new_formatting_context (CONVERTER *self, const ELEMENT *tree,
                               const char *context_string, char *multiple_pass,
@@ -2787,14 +2787,11 @@ convert_tree_new_formatting_context (CONVERTER *self, 
const ELEMENT *tree,
   char *result;
   char *multiple_pass_str = "";
   char *explanation;
-  char *context_string_str = "";
+  char *context_string_str;
 
-  if (context_string)
-    {
-      html_new_document_context (self, context_string,
-                                 document_global_context, block_cmd);
-      xasprintf (&context_string_str, "C(%s)", context_string);
-    }
+  html_new_document_context (self, context_string,
+                             document_global_context, block_cmd);
+  xasprintf (&context_string_str, "C(%s)", context_string);
 
   if (multiple_pass)
     {
@@ -2813,12 +2810,6 @@ convert_tree_new_formatting_context (CONVERTER *self, 
const ELEMENT *tree,
 
   free (explanation);
 
-  if (context_string)
-    {
-      html_pop_document_context (self);
-      free (context_string_str);
-    }
-
   if (multiple_pass)
     {
       self->ignore_notice--;
@@ -2826,6 +2817,9 @@ convert_tree_new_formatting_context (CONVERTER *self, 
const ELEMENT *tree,
       self->modified_state |= HMSF_multiple_pass | HMSF_ignore_notice;
     }
 
+  free (context_string_str);
+  html_pop_document_context (self);
+
   return result;
 }
 



reply via email to

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