texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Gavin D. Smith
Date: Thu, 4 Jan 2024 15:44:24 -0500 (EST)

branch: master
commit 4f38c0c059af0e5476d48aaad12cdabe1860f856
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Thu Jan 4 20:44:16 2024 +0000

    * tp/Texinfo/Convert/Plaintext.pm (_convert) <process contents>:
    Remove zeroing of 'empty_lines_count' from here for 'preformatted'
    and 'rawpreformatted' elements also.
    <close preformatted>: Move it into a code block dealing with
    other preformatted content.  Base the zeroing on inspection of
    the document tree rather than conversion output.
---
 ChangeLog                                          |  9 +++++++++
 tp/Texinfo/Convert/Plaintext.pm                    | 18 ++++++++++++++----
 tp/t/results/coverage/flushright_example_nested.pl |  1 -
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e7763f4bfc..66e10c03c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-01-04  Gavin Smith <gavinsmith0123@gmail.com>
+
+       * tp/Texinfo/Convert/Plaintext.pm (_convert) <process contents>:
+       Remove zeroing of 'empty_lines_count' from here for 'preformatted'
+       and 'rawpreformatted' elements also.
+       <close preformatted>: Move it into a code block dealing with
+       other preformatted content.  Base the zeroing on inspection of
+       the document tree rather than conversion output.
+
 2024-01-04  Gavin Smith <gavinsmith0123@gmail.com>
 
        * tp/Texinfo/Convert/Plaintext.pm (_convert) <process contents>:
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index a2ecae8541..36fd737c78 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -3704,10 +3704,6 @@ sub _convert($$)
 
     for my $content (@$contents) {
       my $text = _convert($self, $content);
-      if (defined($type) and ($type eq 'preformatted'
-             or $type eq 'rawpreformatted')) {
-        $self->{'empty_lines_count'} = 0 if ($text =~ /\S/);
-      }
       $result .= $text;
     }
     pop @{$self->{'current_contents'}};
@@ -3859,6 +3855,20 @@ sub _convert($$)
   } elsif ($preformatted) {
     $result .= _count_added($self, $preformatted->{'container'},
                Texinfo::Convert::Paragraph::end($preformatted->{'container'}));
+    if (defined($type) and ($type eq 'preformatted'
+           or $type eq 'rawpreformatted')) {
+      if ($element->{'contents'}
+          and $element->{'contents'}->[-1]) {
+        my $last_child = $element->{'contents'}->[-1];
+        if (!defined($last_child->{'type'})
+                       or $last_child->{'type'} ne 'empty_line') {
+          if (!defined($last_child->{'text'})
+                       or $last_child->{'text'} =~ /\S/) {
+            $self->{'empty_lines_count'} = 0;
+          }
+        }
+      }
+    }
     if ($result ne '') {
       $result = $self->ensure_end_of_line($result);
     }
diff --git a/tp/t/results/coverage/flushright_example_nested.pl 
b/tp/t/results/coverage/flushright_example_nested.pl
index 39d884a8c5..48a8ede1e5 100644
--- a/tp/t/results/coverage/flushright_example_nested.pl
+++ b/tp/t/results/coverage/flushright_example_nested.pl
@@ -283,7 +283,6 @@ $result_floats{'flushright_example_nested'} = {};
 
 $result_converted{'plaintext'}->{'flushright_example_nested'} = '              
                                      in   --- flushright
 
-
      in   --- example
 
      flush then example



reply via email to

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