[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Paragraph formatter for @listoffloats output
From: |
Gavin D. Smith |
Subject: |
branch master updated: Paragraph formatter for @listoffloats output |
Date: |
Wed, 20 Dec 2023 16:09:48 -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 59368287ae Paragraph formatter for @listoffloats output
59368287ae is described below
commit 59368287aee7db685bed6146f73d55d708b9594a
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Wed Dec 20 21:09:14 2023 +0000
Paragraph formatter for @listoffloats output
* tp/Texinfo/Convert/Plaintext.pm (_convert) <@listoffloats>:
Use a single paragraph formatter to convert a whole entry in the
list of floats. Use 'indent_length_next' setting for indenting
subsequent lines, rather than adding spaces to the results string.
Do not process the result of converting a caption twice. Do not
process the converted caption with a regex splitting into words.
Do not truncate caption at a fixed column or append "...".
Eliminate use of Texinfo::Convert::Unicode::string_width on
converted output.
---
ChangeLog | 14 +++++
tp/Texinfo/Convert/Plaintext.pm | 60 ++++++++++++----------
tp/t/results/coverage_braces/test_image.pl | 10 +---
tp/t/results/float/complex_float.pl | 6 ++-
tp/t/results/float/float_with_at_commands.pl | 3 +-
.../float/numbering_captions_listoffloats.pl | 3 +-
.../float/special_characters_in_float_type.pl | 6 ++-
tp/t/results/info_tests/error_in_footnote.pl | 10 ++--
tp/t/results/info_tests/float_long_captions.pl | 6 ++-
9 files changed, 72 insertions(+), 46 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d7b0d220b3..17d226b4cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-12-20 Gavin Smith <gavinsmith0123@gmail.com>
+
+ Paragraph formatter for @listoffloats output
+
+ * tp/Texinfo/Convert/Plaintext.pm (_convert) <@listoffloats>:
+ Use a single paragraph formatter to convert a whole entry in the
+ list of floats. Use 'indent_length_next' setting for indenting
+ subsequent lines, rather than adding spaces to the results string.
+ Do not process the result of converting a caption twice. Do not
+ process the converted caption with a regex splitting into words.
+ Do not truncate caption at a fixed column or append "...".
+ Eliminate use of Texinfo::Convert::Unicode::string_width on
+ converted output.
+
2023-12-19 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/HTML.pm
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index cd22b3b4c6..904a85e6c7 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -1625,7 +1625,6 @@ sub _anchor($$)
}
my $listoffloat_entry_length = 41;
-my $listoffloat_append = '...';
sub ensure_end_of_line($$)
{
@@ -2979,7 +2978,12 @@ sub _convert($$)
my $float_entry = $self->float_type_number($float);
next if !defined($float_entry);
- my $formatter = $self->new_formatter('line');
+ my $formatter = $self->new_formatter('paragraph',
+ {
+ 'indent_length' => 0,
+ 'indent_length_next' => $listoffloat_entry_length,
+ 'max' => $self->{'text_element_context'}->[-1]->{'max'},
+ });
my $container = $formatter->{'container'};
push @{$self->{'formatters'}}, $formatter;
@@ -2999,7 +3003,7 @@ sub _convert($$)
$result .= _count_added($self, $container,
add_next($container, '.'));
$result .= _count_added($self, $container,
- Texinfo::Convert::Paragraph::end($container));
+ Texinfo::Convert::Paragraph::add_pending_word($container));
# NB we trust that only $container was used to format text
# inside the call to convert_line so that all output text is
@@ -3007,17 +3011,15 @@ sub _convert($$)
my $line_width
= Texinfo::Convert::Paragraph::counter($formatter->{'container'});
- pop @{$self->{'formatters'}};
-
if ($line_width > $listoffloat_entry_length) {
- $result .= "\n" . ' ' x $listoffloat_entry_length;
+ $result .= _count_added($self, $container,
+ Texinfo::Convert::Paragraph::end_line($container));
$lines_count++;
} else {
- $result .= ' ' x ($listoffloat_entry_length - $line_width);
+ $result .= _count_added($self, $container, add_next($container,
+ ' ' x ($listoffloat_entry_length - $line_width)));
}
- $line_width = $listoffloat_entry_length;
- my $float_line = '';
my $caption;
if ($float->{'extra'}->{'shortcaption'}) {
$caption = $float->{'extra'}->{'shortcaption'};
@@ -3026,29 +3028,35 @@ sub _convert($$)
}
if ($caption and $caption->{'args'}->[0]
and $caption->{'args'}->[0]->{'contents'}) {
- $self->{'multiple_pass'} = 1;
push @{$self->{'context'}}, 'listoffloats';
- my $caption_text = _convert($self, $caption->{'args'}->[0]);
- my $old_context = pop @{$self->{'context'}};
- delete $self->{'multiple_pass'};
- die if ($old_context ne 'listoffloats');
- while ($caption_text
- =~
s/^\s*(\p{Unicode::EastAsianWidth::InFullwidth}\s*|\S+\s*)//) {
- my $new_word = $1;
- $new_word =~ s/\n//g;
- if ((Texinfo::Convert::Unicode::string_width($new_word) +
- $line_width) >
- ($self->{'text_element_context'}->[-1]->{'max'} - 3)) {
- $float_line .= $listoffloat_append;
+ $self->{'multiple_pass'} = 1;
+ my $caption_arg = $caption->{'args'}->[0];
+
+ # we do not want to start a new paragraph formatter so
+ # we iterate over the contents of a paragraph rather than
+ # converting the paragraph itself.
+ for my $element (@{$caption_arg->{'contents'}}) {
+ if (defined($element->{'type'})
+ and $element->{'type'} eq 'paragraph'
+ and defined($element->{'contents'})) {
+ for my $subelement (@{$element->{'contents'}}) {
+ $result .= _convert($self, $subelement);
+ }
last;
} else {
- $float_line .= $new_word;
- $line_width +=
- Texinfo::Convert::Unicode::string_width($new_word);
+ $result .= _convert($self, $element);
+ last;
}
}
+ delete $self->{'multiple_pass'};
+ my $old_context = pop @{$self->{'context'}};
}
- $result .= $float_line. "\n";
+ # flush
+ $result .= _count_added($self, $container,
+ Texinfo::Convert::Paragraph::end($container));
+
+ pop @{$self->{'formatters'}};
+
$lines_count++;
}
$result .= "\n";
diff --git a/tp/t/results/coverage_braces/test_image.pl
b/tp/t/results/coverage_braces/test_image.pl
index 4ed71412ec..40c44366c7 100644
--- a/tp/t/results/coverage_braces/test_image.pl
+++ b/tp/t/results/coverage_braces/test_image.pl
@@ -3195,7 +3195,7 @@ In text [alt î-le.. a
* Menu:
-* Image 1: Image with commands. [f@i--le.. a@<"%@ < & @ % ...
+* Image 1: Image with commands.
';
@@ -3234,14 +3234,6 @@ $result_converted_errors{'plaintext'}->{'test_image'} = [
},
{
'error_line' => 'warning: could not find @image file `f@i--le.. a@<"%@ <
& @ % " .txt\' nor alternate text (possibly involving @files-char)
-',
- 'line_nr' => 27,
- 'macro' => 'files-char',
- 'text' => 'could not find @image file `f@i--le.. a@<"%@ < & @ % " .txt\'
nor alternate text',
- 'type' => 'warning'
- },
- {
- 'error_line' => 'warning: could not find @image file `f@i--le.. a@<"%@ <
& @ % " .txt\' nor alternate text (possibly involving @files-char)
',
'line_nr' => 27,
'macro' => 'files-char',
diff --git a/tp/t/results/float/complex_float.pl
b/tp/t/results/float/complex_float.pl
index 524724d207..ab5ee3db8b 100644
--- a/tp/t/results/float/complex_float.pl
+++ b/tp/t/results/float/complex_float.pl
@@ -3677,9 +3677,11 @@ A list of floats at the beginning.
* Menu:
-* Text 1: text with a lot of features. TeX and _téî<an_url>_ AND ...
+* Text 1: text with a lot of features. TeX and _téî<an_url>_ AND
+ it is @verb a word !@ Æ.
* Text 1.1: float with a lot of features and no shortcaption.
- An example of float ...
+ An example of float caption...
+ 2 An example 2.
After the listoffloats.
diff --git a/tp/t/results/float/float_with_at_commands.pl
b/tp/t/results/float/float_with_at_commands.pl
index 9acfc7b190..39447d95a8 100644
--- a/tp/t/results/float/float_with_at_commands.pl
+++ b/tp/t/results/float/float_with_at_commands.pl
@@ -388,7 +388,8 @@ entrée 1: La première entrée est importante
* Menu:
-* entrée 1: première entrée. La première entrée est ...
+* entrée 1: première entrée. La première entrée est
+ importante
';
diff --git a/tp/t/results/float/numbering_captions_listoffloats.pl
b/tp/t/results/float/numbering_captions_listoffloats.pl
index 19fdc00fe4..3ede6e373b 100644
--- a/tp/t/results/float/numbering_captions_listoffloats.pl
+++ b/tp/t/results/float/numbering_captions_listoffloats.pl
@@ -6201,7 +6201,8 @@ text with a lot of features.
* Text 1: text with a lot of features. TeX and someething
* Text 1.1: text in chapter. C Text in chapter
* Text 1.2: float with a lot of features and no shortcaption.
- An example of float ...
+ An example of float caption, no
+ shortcaption...
* Text 1.3: text in section.
* Text 5: unnumbered float. SC unnumbered float
* Text 6: Section within unnumbered float.
diff --git a/tp/t/results/float/special_characters_in_float_type.pl
b/tp/t/results/float/special_characters_in_float_type.pl
index d62c9a39b5..d2eef9dad7 100644
--- a/tp/t/results/float/special_characters_in_float_type.pl
+++ b/tp/t/results/float/special_characters_in_float_type.pl
@@ -561,7 +561,8 @@ VAR
* Menu:
* A < " " \' \' \' \\aaa . -- IN VAR 1.1: L < " `` ` \' \' \\aaa . --- IN VAR.
- float A < " " \' \' \' \\aaa . ...
+ float A < " " \' \' \' \\aaa . --
+ IN VAR
';
@@ -592,7 +593,8 @@ VAR
* Menu:
* A < " " \' \' \' \\aaa . -- IN VAR 1.1: L < " `` ` \' \' \\aaa . --- IN VAR.
- float A < " " \' \' \' \\aaa . ...
+ float A < " " \' \' \' \\aaa . --
+ IN VAR
diff --git a/tp/t/results/info_tests/error_in_footnote.pl
b/tp/t/results/info_tests/error_in_footnote.pl
index 4b537d3f81..3f65be9e50 100644
--- a/tp/t/results/info_tests/error_in_footnote.pl
+++ b/tp/t/results/info_tests/error_in_footnote.pl
@@ -438,11 +438,15 @@ Text 1: Caption. TeX. In caption *note caption*. Now
footnote(1)
* Menu:
-* Text 1: label. Caption. TeX. In caption ...
+* Text 1: label. Caption. TeX. In caption
+ *note caption*. Now
+ footnote(1)
* Menu:
-* Text 1: label. Caption. TeX. In caption ...
+* Text 1: label. Caption. TeX. In caption
+ *note caption*. Now
+ footnote(1)
---------- Footnotes ----------
@@ -453,7 +457,7 @@ Text 1: Caption. TeX. In caption *note caption*. Now
footnote(1)
Tag Table:
Node: Top27
Ref: label61
-Ref: Top-Footnote-1343
+Ref: Top-Footnote-1565
End Tag Table
diff --git a/tp/t/results/info_tests/float_long_captions.pl
b/tp/t/results/info_tests/float_long_captions.pl
index 109391e1a5..755db1c51c 100644
--- a/tp/t/results/info_tests/float_long_captions.pl
+++ b/tp/t/results/info_tests/float_long_captions.pl
@@ -395,8 +395,10 @@ Text 2: AAAAAAAAAAAAAAAA BBBBBB CCCCCCCCCCC
* Menu:
-* Text 1: text1. AAAAAAAAAAAAAAAA BBBBB ...
-* Text 2: text2. AAAAAAAAAAAAAAAA BBBBBB ...
+* Text 1: text1. AAAAAAAAAAAAAAAA BBBBB
+ CCCCCCCCCCC
+* Text 2: text2. AAAAAAAAAAAAAAAA BBBBBB
+ CCCCCCCCCCC
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Paragraph formatter for @listoffloats output,
Gavin D. Smith <=