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_float_comm


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/HTML.pm (_convert_float_command): use register_pending_formatted_inline_content() to have the float number and type prepended to the caption instead of modifying the tree.
Date: Mon, 10 Jan 2022 15:25:36 -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 1b847b75ad * tp/Texinfo/Convert/HTML.pm (_convert_float_command): use 
register_pending_formatted_inline_content() to have the float number and type 
prepended to the caption instead of modifying the tree.
1b847b75ad is described below

commit 1b847b75ad8d10be89f54864bae1e3c1e3036f9e
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Jan 10 21:24:03 2022 +0100

    * tp/Texinfo/Convert/HTML.pm (_convert_float_command): use
    register_pending_formatted_inline_content() to have the float
    number and type prepended to the caption instead of modifying the
    tree.
---
 ChangeLog                  |  7 +++++++
 tp/Texinfo/Convert/HTML.pm | 47 +++++++++++++++-------------------------------
 2 files changed, 22 insertions(+), 32 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e0d2f94b41..db7dec7657 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-01-10  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (_convert_float_command): use
+       register_pending_formatted_inline_content() to have the float
+       number and type prepended to the caption instead of modifying the
+       tree.
+
 2022-01-10  Gavin Smith  <gavinsmith0123@gmail.com>
 
        TODO update
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 9753cb3bbb..d676346bb3 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -3888,15 +3888,15 @@ sub _convert_float_command($$$$$)
   if (defined($caption)) {
     $caption_command_name = $caption->{'cmdname'};
   }
-  my $caption_text = '';
-  my $prepended_text;
   if ($self->in_string()) {
+    my $prepended_text;
     if ($prepended) {
       $prepended_text = $self->convert_tree_new_formatting_context(
         $prepended, 'float prepended');
     } else {
       $prepended_text = '';
     }
+    my $caption_text = '';
     if ($caption) {
       $caption_text = $self->convert_tree_new_formatting_context(
         {'contents' => $caption->{'args'}->[0]->{'contents'}}, 
@@ -3911,38 +3911,21 @@ sub _convert_float_command($$$$$)
     $id_str = " id=\"$id\"";
   }
 
+  my $prepended_text;
+  my $caption_text = '';
   if ($prepended) {
     if ($caption) {
-      # prepend the prepended tree to the first paragraph
-      my @caption_original_contents = @{$caption->{'args'}->[0]->{'contents'}};
-      my @caption_contents;
-      my $new_paragraph;
-      while (@caption_original_contents) {
-        my $content = shift @caption_original_contents;
-        if ($content->{'type'} and $content->{'type'} eq 'paragraph') {
-          %{$new_paragraph} = %{$content};
-          $new_paragraph->{'contents'} = [@{$content->{'contents'}}];
-          unshift (@{$new_paragraph->{'contents'}}, {'cmdname' => 'strong',
-               'args' => [{'type' => 'brace_command_arg',
-                          'contents' => [$prepended]}]});
-          push @caption_contents, $new_paragraph;
-          last;
-        } else {
-          push @caption_contents, $content;
-        }
-      }
-      push @caption_contents, @caption_original_contents;
-      #$self->register_pending_formatted_inline_content($caption_command_name, 
-      #         $self->convert_tree({'cmdname' => 'strong',
-      #         'args' => [{'type' => 'brace_command_arg',
-      #                    'contents' => [$prepended]}]}), 'float number 
type');
-      if ($new_paragraph) {
-        $caption_text = $self->convert_tree_new_formatting_context(
-         #$caption->{'args'}->[0], 'float caption');
-         {'contents' => \@caption_contents}, 'float caption');
-        $prepended_text = '';
-      }
-      #$self->cancel_pending_formatted_inline_content($caption_command_name);
+      # format and register the prepended tree to be prepended to
+      # the first paragraph in caption formatting
+      $self->register_pending_formatted_inline_content($caption_command_name,
+           $self->convert_tree({'cmdname' => 'strong',
+                                'args' => [{'type' => 'brace_command_arg',
+                                            'contents' => [$prepended]}]}),
+           'float number type');
+      $caption_text = $self->convert_tree_new_formatting_context(
+               $caption->{'args'}->[0], 'float caption');
+      $prepended_text = '';
+      $self->cancel_pending_formatted_inline_content($caption_command_name);
     }
     if ($caption_text eq '') {
       $prepended_text = $self->convert_tree_new_formatting_context(



reply via email to

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