[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/Plaintext.pm (_add_newline_i
From: |
Gavin D. Smith |
Subject: |
branch master updated: * tp/Texinfo/Convert/Plaintext.pm (_add_newline_if_needed): Replace with implementation that checks the end of the output stream rather than the 'empty_lines_count' counter. * tp/Texinfo/Convert/Info.pm (_info_header): Call _add_newline_if_needed to ensure a blank line at the end of the header. |
Date: |
Sun, 21 Jan 2024 16:25:19 -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 09f75309be * tp/Texinfo/Convert/Plaintext.pm (_add_newline_if_needed):
Replace with implementation that checks the end of the output stream rather
than the 'empty_lines_count' counter. * tp/Texinfo/Convert/Info.pm
(_info_header): Call _add_newline_if_needed to ensure a blank line at the end
of the header.
09f75309be is described below
commit 09f75309befa6d5be7c0a307e8b1b021fa747dac
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sun Jan 21 21:19:19 2024 +0000
* tp/Texinfo/Convert/Plaintext.pm (_add_newline_if_needed):
Replace with implementation that checks the end of the output
stream rather than the 'empty_lines_count' counter.
* tp/Texinfo/Convert/Info.pm (_info_header): Call
_add_newline_if_needed to ensure a blank line at the end of
the header.
---
ChangeLog | 9 +
tp/Texinfo/Convert/Info.pm | 1 +
tp/Texinfo/Convert/Plaintext.pm | 44 +-
.../converters_tests/contents_at_document_begin.pl | 1 +
.../contents_at_document_begin_inline.pl | 1 +
.../contents_at_document_begin_separate_element.pl | 1 +
tp/t/results/converters_tests/form_feeds.pl | 2 +
tp/t/results/converters_tests/image_formatting.pl | 1 -
tp/t/results/converters_tests/ref_in_sectioning.pl | 1 +
tp/t/results/coverage/commands_in_math.pl | 1 -
.../coverage/punctuation_in_line_commands.pl | 1 +
.../results/coverage_braces/empty_line_in_email.pl | 3 +-
.../coverage_braces/form_feed_in_brace_commands.pl | 1 +
.../results/float/comment_space_comand_in_float.pl | 2 +
tp/t/results/float/empty_caption.pl | 2 +
.../float/empty_listoffloats_with_floats.pl | 1 +
tp/t/results/float/float_type_with_tieaccent.pl | 1 +
.../results/float/multiple_spaces_in_float_type.pl | 1 +
.../float/numbering_captions_listoffloats.pl | 1 +
tp/t/results/float/ref_to_float.pl | 1 +
.../formats_encodings/at_commands_in_refs.pl | 18 +-
.../res_info/at_commands_in_refs_latin1.info | Bin 7998 -> 7997 bytes
.../res_info/at_commands_in_refs_utf8.info | Bin 8395 -> 8394 bytes
tp/t/results/indices/image_lines_count.pl | Bin 5768 -> 5766 bytes
tp/t/results/indices/image_text_lines_count.pl | Bin 6171 -> 6169 bytes
.../res_plaintext/Copying-and-indices.txt | 1 +
.../res_plaintext/Copying-and-indices.txt | 1 +
.../res_plaintext/Copying-and-indices.txt | 1 +
.../res_plaintext/Copying-and-indices.txt | 1 +
.../indices/printindex_between_part_chapter.pl | 5 +-
tp/t/results/info_tests/empty_caption.pl | 1 +
tp/t/results/info_tests/float_without_type.pl | 1 +
.../codequoteundirected_codequotebacktick.pl | 1 -
.../misc_commands/comment_space_command_on_line.pl | 1 +
.../misc_commands/heading_command_in_commands.pl | 1 -
.../moresectioning/contents_and_shortcontents.pl | 1 +
.../equivalent_nodes_defined_linked.pl | 1 +
.../section_in_unnumbered_plaintext.pl | 1 +
tp/t/results/multitable/empty_item_tab.pl | 3 +-
tp/t/results/paragraph/commands_in_flushright.pl | 4 +-
.../plaintext_tests/empty_line_in_example_end.pl | 1 -
.../plaintext_tests/line_passed_and_formats.pl | 2 -
tp/t/results/preformatted/nested_formats.pl | 1 -
.../preformatted/text_on_display_command_line.pl | 3 +-
.../preformatted/text_on_example_command_line.pl | 3 +-
tp/t/results/raw/beginning_and_end_on_line.pl | 3 +-
tp/t/results/raw/braces_in_tex.pl | 3 +-
tp/t/results/raw/raw_in_example.pl | 2 -
tp/t/results/raw/verbatim_and_verbatiminclude.pl | 1 -
.../results/sectioning/double_node_anchor_float.pl | 4 +-
.../results/sectioning/no_argument_and_contents.pl | 1 +
.../results/sectioning/section_below_unnumbered.pl | 1 +
.../res_parser/formatting_info/formatting.info | 1111 ++++++++++----------
.../res_parser/formatting_plaintext/formatting.txt | 1078 ++++++++++---------
.../non_ascii_test_info/os\303\251_utf8.info" | Bin 567 -> 566 bytes
.../res_parser/formatting_fr_info/formatting.info | 1111 ++++++++++----------
.../formatting.info | 1111 ++++++++++----------
.../formatting.info | 1111 ++++++++++----------
.../formatting.txt | 1078 ++++++++++---------
.../nested_cartouche/nested_formats.info | 1 -
.../res_parser/nested_deffn/nested_formats.info | 1 -
.../nested_enumerate/nested_formats.info | 1 -
.../res_parser/nested_example/nested_formats.info | 24 -
.../nested_flushright/nested_formats.info | 47 -
.../res_parser/nested_group/nested_formats.info | 1 -
.../res_parser/nested_itemize/nested_formats.info | 1 -
.../res_parser/nested_menu/nested_formats.info | 16 -
.../nested_multitable/nested_formats.info | 1 -
.../nested_quotation/nested_formats.info | 1 -
.../res_parser/nested_table/nested_formats.info | 1 -
70 files changed, 3384 insertions(+), 3454 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e951bc0dfc..cedf6b211a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-01-21 Gavin Smith <gavinsmith0123@gmail.com>
+
+ * tp/Texinfo/Convert/Plaintext.pm (_add_newline_if_needed):
+ Replace with implementation that checks the end of the output
+ stream rather than the 'empty_lines_count' counter.
+ * tp/Texinfo/Convert/Info.pm (_info_header): Call
+ _add_newline_if_needed to ensure a blank line at the end of
+ the header.
+
2024-01-21 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/Converter.pm (%common_converters_defaults):
diff --git a/tp/Texinfo/Convert/Info.pm b/tp/Texinfo/Convert/Info.pm
index b2167eafe6..5e9f3e5a97 100644
--- a/tp/Texinfo/Convert/Info.pm
+++ b/tp/Texinfo/Convert/Info.pm
@@ -475,6 +475,7 @@ sub _info_header($$$)
$self->{'ignored_commands'}->{'direntry'} = 1;
$self->_stream_output_encoded($dir_section);
}
+ $self->_add_newline_if_needed();
$result = $self->_stream_result();
pop @{$self->{'count_context'}};
return $result;
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 896ff81fad..29bc5299fc 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -1057,14 +1057,29 @@ sub _update_locations_counts($$)
}
}
+# Called at the beginning of a line. Add a blank line if the output does
+# not already end in one.
sub _add_newline_if_needed($) {
my $self = shift;
- if (defined($self->{'empty_lines_count'})
- and $self->{'empty_lines_count'} == 0) {
- _stream_output_encoded($self, "\n");
- _add_lines_count($self, 1);
- $self->{'empty_lines_count'} = 1;
+
+ if (defined($self->{'count_context'}->[-1]->{'pending_text'})
+ and $self->{'count_context'}->[-1]->{'pending_text'} =~ /(..)\z/s) {
+ # NB \z matches end of string, whereas $ can match *before* a newline
+ # at the end of a string.
+ if ($1 ne "\n\n") {
+ _stream_output_encoded($self, "\n");
+ _add_lines_count($self, 1);
+ $self->{'empty_lines_count'} = 1;
+ }
+ } else {
+ my $result = _stream_result($self);
+ if ($result ne '' and $result ne "\n" and $result !~ /\n\n\z/) {
+ _stream_output_encoded($self, "\n");
+ _add_lines_count($self, 1);
+ $self->{'empty_lines_count'} = 1;
+ }
}
+
return;
}
@@ -1966,7 +1981,24 @@ sub _convert($$)
add_text($formatter->{'container'}, "\n"));
$self->{'empty_lines_count'}++;
} else {
- $self->_add_newline_if_needed();
+ # inlined below for efficiency
+ #$self->_add_newline_if_needed();
+
+ if (defined($self->{'count_context'}->[-1]->{'pending_text'})
+ and $self->{'count_context'}->[-1]->{'pending_text'} =~ /(..\z)/s) {
+ if ($1 ne "\n\n") {
+ _stream_output_encoded($self, "\n");
+ _add_lines_count($self, 1);
+ $self->{'empty_lines_count'} = 1;
+ }
+ } else {
+ my $result = _stream_result($self);
+ if ($result ne '' and $result ne "\n" and $result !~ /\n\n\z/) {
+ _stream_output_encoded($self, "\n");
+ _add_lines_count($self, 1);
+ $self->{'empty_lines_count'} = 1;
+ }
+ }
}
return;
}
diff --git a/tp/t/results/converters_tests/contents_at_document_begin.pl
b/tp/t/results/converters_tests/contents_at_document_begin.pl
index 730df3f369..16fd3b3c33 100644
--- a/tp/t/results/converters_tests/contents_at_document_begin.pl
+++ b/tp/t/results/converters_tests/contents_at_document_begin.pl
@@ -485,6 +485,7 @@ $result_floats{'contents_at_document_begin'} = {};
$result_converted{'plaintext'}->{'contents_at_document_begin'} = 'Contents at
beginning
1 Chapter 1
+
Contents at beginning
*********************
diff --git a/tp/t/results/converters_tests/contents_at_document_begin_inline.pl
b/tp/t/results/converters_tests/contents_at_document_begin_inline.pl
index 35c2d51e0d..efba0cc72d 100644
--- a/tp/t/results/converters_tests/contents_at_document_begin_inline.pl
+++ b/tp/t/results/converters_tests/contents_at_document_begin_inline.pl
@@ -485,6 +485,7 @@ $result_floats{'contents_at_document_begin_inline'} = {};
$result_converted{'plaintext'}->{'contents_at_document_begin_inline'} =
'Contents at beginning
1 Chapter 1
+
Contents at beginning
*********************
diff --git
a/tp/t/results/converters_tests/contents_at_document_begin_separate_element.pl
b/tp/t/results/converters_tests/contents_at_document_begin_separate_element.pl
index cc46242850..f584dcab9c 100644
---
a/tp/t/results/converters_tests/contents_at_document_begin_separate_element.pl
+++
b/tp/t/results/converters_tests/contents_at_document_begin_separate_element.pl
@@ -485,6 +485,7 @@
$result_floats{'contents_at_document_begin_separate_element'} = {};
$result_converted{'plaintext'}->{'contents_at_document_begin_separate_element'}
= 'Contents at beginning
1 Chapter 1
+
Contents at beginning
*********************
diff --git a/tp/t/results/converters_tests/form_feeds.pl
b/tp/t/results/converters_tests/form_feeds.pl
index cb5e20b806..4a3d87f8a7 100644
--- a/tp/t/results/converters_tests/form_feeds.pl
+++ b/tp/t/results/converters_tests/form_feeds.pl
@@ -1371,9 +1371,11 @@ within
cation
+
in float
type 1
+
* Menu:
* type 1: fl.
diff --git a/tp/t/results/converters_tests/image_formatting.pl
b/tp/t/results/converters_tests/image_formatting.pl
index f036c161bb..2207db9ff8 100644
--- a/tp/t/results/converters_tests/image_formatting.pl
+++ b/tp/t/results/converters_tests/image_formatting.pl
@@ -2333,7 +2333,6 @@ ccc
[image src="f--ile.png" alt="a very long alt argument that could span more
than one line who knows" text="Image description\\"\\"\\\\."