texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/Plaintext.pm (ensure_end_of_


From: Gavin D. Smith
Subject: branch master updated: * tp/Texinfo/Convert/Plaintext.pm (ensure_end_of_line, _ensure_end_of_line): Move function in file to be right after _add_newline_if_needed, as the implementation is similar. Rename with leading underscore to mark as "internal", and do not call with method call syntax throughout. No functional change intended.
Date: Sun, 28 Jan 2024 11:45:30 -0500

This is an automated email from the git hooks/post-receive script.

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 2b058df216 * tp/Texinfo/Convert/Plaintext.pm (ensure_end_of_line, 
_ensure_end_of_line): Move function in file to be right after 
_add_newline_if_needed, as the implementation is similar.  Rename with leading 
underscore to mark as "internal", and do not call with method call syntax 
throughout.  No functional change intended.
2b058df216 is described below

commit 2b058df21651666e6963adde65aec0de1107514d
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sun Jan 28 16:45:23 2024 +0000

    * tp/Texinfo/Convert/Plaintext.pm
    (ensure_end_of_line, _ensure_end_of_line):
    Move function in file to be right after _add_newline_if_needed,
    as the implementation is similar.  Rename with leading underscore
    to mark as "internal", and do not call with method call syntax
    throughout.  No functional change intended.
---
 ChangeLog                       |  9 ++++++++
 tp/Texinfo/Convert/Plaintext.pm | 46 +++++++++++++++++++++--------------------
 2 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ddde1168ec..91576a5e24 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-01-28  Gavin Smith <gavinsmith0123@gmail.com>
+
+       * tp/Texinfo/Convert/Plaintext.pm
+       (ensure_end_of_line, _ensure_end_of_line):
+       Move function in file to be right after _add_newline_if_needed,
+       as the implementation is similar.  Rename with leading underscore
+       to mark as "internal", and do not call with method call syntax
+       throughout.  No functional change intended.
+
 2024-01-28  Gavin Smith <gavinsmith0123@gmail.com>
 
        * info/infodoc.c (describe_key): Fix handling of keys with
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index b8c9025c32..9273a04a90 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -1069,6 +1069,24 @@ sub _add_newline_if_needed($) {
   return;
 }
 
+# Ensure the output ends in a newline character.
+sub _ensure_end_of_line($)
+{
+  my $self = shift;
+
+  my $result = _stream_result($self);
+
+  return if !defined($result) or $result eq '';
+
+  if (substr($result, -1) ne "\n") {
+    _stream_output($self, "\n");
+    _add_lines_count($self, 1);
+    $self->{'text_element_context'}->[-1]->{'counter'} = 0;
+  }
+  return;
+}
+
+
 sub _open_code($)
 {
   my $formatter = shift;
@@ -1763,22 +1781,6 @@ sub _anchor($$)
 
 my $listoffloat_entry_length = 41;
 
-sub ensure_end_of_line($)
-{
-  my $self = shift;
-
-  my $result = _stream_result($self);
-
-  return if !defined($result) or $result eq '';
-
-  if (substr($result, -1) ne "\n") {
-    _stream_output($self, "\n");
-    _add_lines_count($self, 1);
-    $self->{'text_element_context'}->[-1]->{'counter'} = 0;
-  }
-  return;
-}
-
 sub image_formatted_text($$$$)
 {
   my ($self, $element, $basefile, $text) = @_;
@@ -3087,7 +3089,7 @@ sub _convert($$)
              {'indent_length' =>
                  ($self->{'format_context'}->[-1]->{'indent_level'} -1)
                    * $indent_length});
-        $self->ensure_end_of_line();
+        _ensure_end_of_line($self);
       }
     } elsif ($command eq 'item' and $element->{'parent'}->{'cmdname'}
              and $block_commands{$element->{'parent'}->{'cmdname'}}
@@ -3149,7 +3151,7 @@ sub _convert($$)
               'contents' => [$element->{'args'}->[0]]},
              {'indent_length' => 0});
       }
-      $self->ensure_end_of_line();
+      _ensure_end_of_line($self);
       my $result = _stream_result($self);
       if ($result ne '') {
 
@@ -3184,7 +3186,7 @@ sub _convert($$)
                    * $indent_length});
         }
       }
-      $self->ensure_end_of_line();
+      _ensure_end_of_line($self);
       return;
     } elsif ($command eq 'verbatiminclude') {
       my $expansion = Texinfo::Convert::Utils::expand_verbatiminclude(
@@ -3881,7 +3883,7 @@ sub _convert($$)
                        add_pending_word($formatter->{'container'}),
                        $formatter->{'container'});
         end_line($formatter->{'container'});
-        $self->ensure_end_of_line();
+        _ensure_end_of_line($self);
       }
 
       return;
@@ -4030,7 +4032,7 @@ sub _convert($$)
       $self->{'format_context'}->[-1]->{'row_counts'} = [];
       _stream_output_encoded($self, $result);
     } elsif ($type eq 'before_node_section') {
-      ensure_end_of_line($self);
+      _ensure_end_of_line($self);
       $self->{'text_before_first_node'} = _stream_result($self);
     }
   }
@@ -4051,7 +4053,7 @@ sub _convert($$)
     _stream_output($self,
                Texinfo::Convert::Paragraph::end($preformatted->{'container'}),
                $preformatted->{'container'});
-    $self->ensure_end_of_line();
+    _ensure_end_of_line($self);
 
     if ($self->{'context'}->[-1] eq 'flushright') {
       my $result = _stream_result($self);



reply via email to

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