[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sun, 29 Sep 2024 09:50:04 -0400 (EDT) |
branch: master
commit 42e11fb08512895ad4b6e3e09d1bf6875c9cc781
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Jul 1 19:41:02 2024 +0200
* tp/Texinfo/Convert/HTML.pm (_prepare_converted_output_info),
tp/Texinfo/Convert/LaTeX.pm (_title_font),
tp/Texinfo/Convert/Plaintext.pm (_convert),
tp/Texinfo/XS/convert/convert_html.c (convert_titlefont_command):
simplify args conditions for titlefont and/or handle titlefont element
without braces and with 0 args.
* tp/Makefile.tres, tp/t/03coverage_braces.t (titlefont_no_braces):
test of @titlefont without braces at end of document.
---
ChangeLog | 12 +++++
tp/Makefile.tres | 1 +
tp/Texinfo/Convert/HTML.pm | 6 +--
tp/Texinfo/Convert/LaTeX.pm | 5 +-
tp/Texinfo/Convert/Plaintext.pm | 10 ++--
tp/Texinfo/XS/convert/convert_html.c | 2 +-
tp/t/03coverage_braces.t | 1 +
.../results/coverage_braces/titlefont_no_braces.pl | 56 ++++++++++++++++++++++
8 files changed, 80 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index dc0e84abe3..e54585bc67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-07-01 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/HTML.pm (_prepare_converted_output_info),
+ tp/Texinfo/Convert/LaTeX.pm (_title_font),
+ tp/Texinfo/Convert/Plaintext.pm (_convert),
+ tp/Texinfo/XS/convert/convert_html.c (convert_titlefont_command):
+ simplify args conditions for titlefont and/or handle titlefont element
+ without braces and with 0 args.
+
+ * tp/Makefile.tres, tp/t/03coverage_braces.t (titlefont_no_braces):
+ test of @titlefont without braces at end of document.
+
2024-07-01 Patrice Dumas <pertusus@free.fr>
* tp/Makefile.tres, tp/t/03coverage_braces.t (U_no_braces): test of
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index 3aa8342644..e0373192c0 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -444,6 +444,7 @@ test_files_generated_list =
$(test_tap_files_generated_list) \
t/results/coverage_braces/strong_no_braces.pl \
t/results/coverage_braces/test_image.pl \
t/results/coverage_braces/test_w.pl \
+ t/results/coverage_braces/titlefont_no_braces.pl \
t/results/coverage_braces/too_much_args.pl \
t/results/coverage_braces/two_footnotes_in_nodes.pl \
t/results/coverage_braces/two_footnotes_in_nodes_separate.pl \
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 31e284844a..d9be241512 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -12865,11 +12865,7 @@ sub _prepare_converted_output_info($)
}
if (!$fulltitle_tree and $global_commands->{'titlefont'}
and $global_commands->{'titlefont'}->[0]->{'args'}
- and defined($global_commands->{'titlefont'}->[0]->{'args'}->[0])
- and $global_commands->{'titlefont'}->[0]
- ->{'args'}->[0]->{'contents'}
- and @{$global_commands->{'titlefont'}->[0]
-
->{'args'}->[0]->{'contents'}}) {
+ and $global_commands->{'titlefont'}->[0]->{'args'}->[0]->{'contents'})
{
$fulltitle_tree = $global_commands->{'titlefont'}->[0];
}
}
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 3f31ecedef..d891231fd6 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -2312,11 +2312,10 @@ sub _title_font($$)
my $self = shift;
my $element = shift;
- if ($element->{'args'}->[0] and $element->{'args'}->[0]->{'contents'}) {
+ if ($element->{'args'} and $element->{'args'}->[0]->{'contents'}) {
# in Texinfo TeX seems a bit smaller, but LARGE seems too small
my $result = "{\\huge \\bfseries ";
- $result
- .= _convert($self, {'contents' =>
$element->{'args'}->[0]->{'contents'}});
+ $result .= _convert($self, $element->{'args'}->[0]);
$result .= '}';
return $result;
}
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 55c4c8462b..0b2901df47 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -3188,15 +3188,17 @@ sub _convert($$)
die if ($old_context ne $command);
return;
} elsif ($command eq 'titlefont') {
- my $result = $self->_text_heading(
+ if ($element->{'args'}) {
+ my $result = $self->_text_heading(
{'extra' => {'section_level' => 0},
'cmdname' => 'titlefont'},
$element->{'args'}->[0],
$self->get_conf('NUMBER_SECTIONS'),
($self->{'format_context'}->[-1]->{'indent_level'}) *$indent_length);
- $result =~ s/\n$//; # final newline has its own tree element
- _stream_output($self, $result);
- _add_lines_count($self, 1);
+ $result =~ s/\n$//; # final newline has its own tree element
+ _stream_output($self, $result);
+ _add_lines_count($self, 1);
+ }
return;
} elsif ($command eq 'U') {
if ($element->{'args'}
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 163f7b27b4..ae092db2cc 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -10153,7 +10153,7 @@ convert_titlefont_command (CONVERTER *self, const enum
command_id cmd,
const HTML_ARGS_FORMATTED *args_formatted,
const char *content, TEXT *result)
{
- if (args_formatted->number > 0
+ if (args_formatted && args_formatted->number > 0
&& args_formatted->args[0].formatted[AFT_type_normal]
&& strlen (args_formatted->args[0].formatted[AFT_type_normal]))
{
diff --git a/tp/t/03coverage_braces.t b/tp/t/03coverage_braces.t
index f58a8c30d0..ee8545aeee 100644
--- a/tp/t/03coverage_braces.t
+++ b/tp/t/03coverage_braces.t
@@ -100,6 +100,7 @@ my @test_cases = (
['footnote_no_braces', '@footnote'],
['U_no_braces', '@U'],
['hyphenation_no_braces', '@hyphenation'],
+['titlefont_no_braces', '@titlefont'],
['verb_in_xref',
'@anchor{point}
diff --git a/tp/t/results/coverage_braces/titlefont_no_braces.pl
b/tp/t/results/coverage_braces/titlefont_no_braces.pl
new file mode 100644
index 0000000000..0f4e021abe
--- /dev/null
+++ b/tp/t/results/coverage_braces/titlefont_no_braces.pl
@@ -0,0 +1,56 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors
+ %result_indices %result_sectioning %result_nodes %result_menus
+ %result_floats %result_converted %result_converted_errors
+ %result_elements %result_directions_text %result_indices_sort_strings);
+
+use utf8;
+
+$result_trees{'titlefont_no_braces'} = {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'cmdname' => 'titlefont',
+ 'source_info' => {
+ 'line_nr' => 1
+ }
+ }
+ ],
+ 'type' => 'before_node_section'
+ }
+ ],
+ 'type' => 'document_root'
+};
+
+$result_texis{'titlefont_no_braces'} = '@titlefont';
+
+
+$result_texts{'titlefont_no_braces'} = '';
+
+$result_errors{'titlefont_no_braces'} = [
+ {
+ 'error_line' => '@titlefont expected braces
+',
+ 'line_nr' => 1,
+ 'text' => '@titlefont expected braces',
+ 'type' => 'error'
+ }
+];
+
+
+$result_floats{'titlefont_no_braces'} = {};
+
+
+
+$result_converted{'plaintext'}->{'titlefont_no_braces'} = '';
+
+
+$result_converted{'html_text'}->{'titlefont_no_braces'} = '';
+
+
+$result_converted{'latex_text'}->{'titlefont_no_braces'} = '';
+
+
+$result_converted{'docbook'}->{'titlefont_no_braces'} = '';
+
+1;