[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/Plaintext.pm (_stream_byte_c
From: |
Gavin D. Smith |
Subject: |
branch master updated: * tp/Texinfo/Convert/Plaintext.pm (_stream_byte_count): Recognize an 'encoding_disabled' flag on the count context, and if set, do not encode the output. (process_printindex): Set this flag when converting an index entry and output the result with _stream_output rather than _stream_output_encoded, and to get the display width call string_width rather than string_width_encoded. |
Date: |
Tue, 23 Jan 2024 13:34:09 -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 07cc94000d * tp/Texinfo/Convert/Plaintext.pm (_stream_byte_count):
Recognize an 'encoding_disabled' flag on the count context, and if set, do not
encode the output. (process_printindex): Set this flag when converting an index
entry and output the result with _stream_output rather than
_stream_output_encoded, and to get the display width call string_width rather
than string_width_encoded.
07cc94000d is described below
commit 07cc94000da4acb87611d1462e84f4f54a8ec4a9
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Tue Jan 23 18:33:43 2024 +0000
* tp/Texinfo/Convert/Plaintext.pm (_stream_byte_count):
Recognize an 'encoding_disabled' flag on the count context, and
if set, do not encode the output.
(process_printindex): Set this flag when converting an index
entry and output the result with _stream_output rather than
_stream_output_encoded, and to get the display width call
string_width rather than string_width_encoded.
---
ChangeLog | 10 ++++++++++
tp/Texinfo/Convert/Plaintext.pm | 21 ++++++++++++++-------
2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ac9d2d3af6..86d30fed05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-01-23 Gavin Smith <gavinsmith0123@gmail.com>
+
+ * tp/Texinfo/Convert/Plaintext.pm (_stream_byte_count):
+ Recognize an 'encoding_disabled' flag on the count context, and
+ if set, do not encode the output.
+ (process_printindex): Set this flag when converting an index
+ entry and output the result with _stream_output rather than
+ _stream_output_encoded, and to get the display width call
+ string_width rather than string_width_encoded.
+
2024-01-22 Patrice Dumas <pertusus@free.fr>
* tp/Makefile.tres, tp/t/html_tests.t (contents_with_only_top_node)
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index b6ce658d88..d2c0cb7ec8 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -1005,10 +1005,17 @@ sub _stream_byte_count($)
if (defined($count_context->{'pending_text'})
and $count_context->{'pending_text'} ne '') {
- my $new_encoded = _stream_encode($self, $count_context->{'pending_text'});
- $count_context->{'pending_text'} = '';
- $count_context->{'result'} .= $new_encoded;
- $count_context->{'bytes'} += length($new_encoded);
+ if (!$count_context->{'encoding_disabled'}) {
+ my $new_encoded
+ = _stream_encode($self, $count_context->{'pending_text'});
+ $count_context->{'pending_text'} = '';
+ $count_context->{'result'} .= $new_encoded;
+ $count_context->{'bytes'} += length($new_encoded);
+ } else {
+ $count_context->{'result'} .= $count_context->{'pending_text'};
+ $count_context->{'pending_text'} = '';
+ $count_context->{'bytes'} = -1;
+ }
}
return $count_context->{'bytes'};
}
@@ -1623,6 +1630,7 @@ sub process_printindex($$;$)
# Convert entry text in a new context in order to capture result.
push @{$self->{'count_context'}}, {'lines' => 0, 'bytes' => 0};
+ $self->{'count_context'}->[-1]->{'encoding_disabled'} = 1;
$self->_convert($entry_tree);
$self->_convert($subentries_tree)
if (defined($subentries_tree));
@@ -1657,10 +1665,9 @@ sub process_printindex($$;$)
$entry_nr = ' <'.$entry_counts{$entry_text}.'>';
}
my $entry_line = "* $entry_text${entry_nr}: ";
- _stream_output_encoded($self, $entry_line);
-
- my $line_width = _string_width_encoded($self, $entry_line);
+ _stream_output($self, undef, $entry_line);
+ my $line_width = Texinfo::Convert::Unicode::string_width($entry_line);
if ($line_width < $index_length_to_node) {
my $spaces = ' ' x ($index_length_to_node - $line_width);
_stream_output($self, undef, $spaces);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Convert/Plaintext.pm (_stream_byte_count): Recognize an 'encoding_disabled' flag on the count context, and if set, do not encode the output. (process_printindex): Set this flag when converting an index entry and output the result with _stream_output rather than _stream_output_encoded, and to get the display width call string_width rather than string_width_encoded.,
Gavin D. Smith <=