[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/HTML.pm (_convert_heading_co
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Convert/HTML.pm (_convert_heading_command) (_open_node_part_command), tp/Texinfo/XS/convert/convert_html.c (convert_heading_command, open_node_part_command): set in_skipped_node_top when opening a @node (or associated @part), not after processing the contents. |
Date: |
Thu, 05 Sep 2024 05:58:06 -0400 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 9fc241f19a * tp/Texinfo/Convert/HTML.pm (_convert_heading_command)
(_open_node_part_command), tp/Texinfo/XS/convert/convert_html.c
(convert_heading_command, open_node_part_command): set in_skipped_node_top when
opening a @node (or associated @part), not after processing the contents.
9fc241f19a is described below
commit 9fc241f19a3151ba315daf2149211866a1467653
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Sep 5 11:58:03 2024 +0200
* tp/Texinfo/Convert/HTML.pm (_convert_heading_command)
(_open_node_part_command), tp/Texinfo/XS/convert/convert_html.c
(convert_heading_command, open_node_part_command): set
in_skipped_node_top when opening a @node (or associated @part), not
after processing the contents.
* tp/Makefile.tres, tp/t/40moresectioning.t
(nodes_no_section_footnote_no_top_node_output): add test with
footnote in a node after a skipped Top node, with USE_NODES=0.
* tp/t/*.t: Use the hash notation to set USE_NODES.
---
ChangeLog | 14 ++
tp/Makefile.tres | 1 +
tp/Texinfo/Convert/HTML.pm | 59 ++++--
tp/Texinfo/XS/convert/convert_html.c | 78 ++++---
tp/t/27float.t | 3 +
tp/t/40moresectioning.t | 8 +
tp/t/converters_tests.t | 4 +-
tp/t/html_tests.t | 6 +-
...nodes_no_section_footnote_no_top_node_output.pl | 232 +++++++++++++++++++++
9 files changed, 347 insertions(+), 58 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f19b146750..1c1c6d64ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-09-05 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/HTML.pm (_convert_heading_command)
+ (_open_node_part_command), tp/Texinfo/XS/convert/convert_html.c
+ (convert_heading_command, open_node_part_command): set
+ in_skipped_node_top when opening a @node (or associated @part), not
+ after processing the contents.
+
+ * tp/Makefile.tres, tp/t/40moresectioning.t
+ (nodes_no_section_footnote_no_top_node_output): add test with
+ footnote in a node after a skipped Top node, with USE_NODES=0.
+
+ * tp/t/*.t: Use the hash notation to set USE_NODES.
+
2024-09-04 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/HTML.pm (_convert_xref_commands),
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index a379462266..7a9e6ce260 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -1630,6 +1630,7 @@ test_files_generated_list =
$(test_tap_files_generated_list) \
t/results/moresectioning/no_element.pl \
t/results/moresectioning/nodes_before_after_top_xref.pl \
t/results/moresectioning/nodes_before_after_top_xref/res_latex \
+ t/results/moresectioning/nodes_no_section_footnote_no_top_node_output.pl \
t/results/moresectioning/non_automatic_internal_top_node_up.pl \
t/results/moresectioning/non_automatic_top_node_up_and_url.pl \
t/results/moresectioning/non_automatic_top_node_up_url.pl \
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index bb26474d7a..9ee82bc4e5 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -4887,26 +4887,6 @@ sub _convert_heading_command($$$$$)
my $in_skipped_node_top
= $self->get_shared_conversion_state('top', 'in_skipped_node_top');
$in_skipped_node_top = 0 if (!defined($in_skipped_node_top));
- my $node_element;
- if ($cmdname eq 'node') {
- $node_element = $element;
- } elsif ($cmdname eq 'part' and $element->{'extra'}
- and $element->{'extra'}->{'part_following_node'}) {
- $node_element = $element->{'extra'}->{'part_following_node'};
- }
- if ($node_element or $cmdname eq 'part') {
- if ($node_element and $node_element->{'extra'}
- and $node_element->{'extra'}->{'normalized'}
- and $node_element->{'extra'}->{'normalized'} eq 'Top') {
- $in_skipped_node_top = 1;
- $self->set_shared_conversion_state('top', 'in_skipped_node_top',
- $in_skipped_node_top);
- } elsif ($in_skipped_node_top == 1) {
- $in_skipped_node_top = -1;
- $self->set_shared_conversion_state('top', 'in_skipped_node_top',
- $in_skipped_node_top);
- }
- }
if ($in_skipped_node_top == 1) {
my $id_class = $cmdname;
$result .= &{$self->formatting_function('format_separate_anchor')}($self,
@@ -6363,7 +6343,7 @@ sub _convert_printindex_command($$$$)
}
#foreach my $letter_entry (@{$index_entries_by_letter->{$index_name}}) {
- # print STDERR "IIIIIII $letter_entry->{'letter'}\n";
+ # print STDERR "IDXLETTER $letter_entry->{'letter'}\n";
# foreach my $index_entry (@{$letter_entry->{'entries'}}) {
# print STDERR " ".join('|', keys(%$index_entry))."|||
$index_entry->{'key'}\n";
# }
@@ -6996,6 +6976,43 @@ foreach my $small_command
(keys(%small_block_associated_command)) {
=
$default_commands_conversion{$small_block_associated_command{$small_command}};
}
+sub _open_node_part_command($$$)
+{
+ my $self = shift;
+ my $cmdname = shift;
+ my $element = shift;
+
+ if ($self->get_conf('NO_TOP_NODE_OUTPUT')) {
+ my $in_skipped_node_top
+ = $self->get_shared_conversion_state('top', 'in_skipped_node_top');
+ $in_skipped_node_top = 0 if (!defined($in_skipped_node_top));
+ my $node_element;
+ if ($cmdname eq 'node') {
+ $node_element = $element;
+ } elsif ($cmdname eq 'part' and $element->{'extra'}
+ and $element->{'extra'}->{'part_following_node'}) {
+ $node_element = $element->{'extra'}->{'part_following_node'};
+ }
+ if ($node_element or $cmdname eq 'part') {
+ if ($node_element and $node_element->{'extra'}
+ and $node_element->{'extra'}->{'normalized'}
+ and $node_element->{'extra'}->{'normalized'} eq 'Top') {
+ $in_skipped_node_top = 1;
+ $self->set_shared_conversion_state('top', 'in_skipped_node_top',
+ $in_skipped_node_top);
+ } elsif ($in_skipped_node_top == 1) {
+ $in_skipped_node_top = -1;
+ $self->set_shared_conversion_state('top', 'in_skipped_node_top',
+ $in_skipped_node_top);
+ }
+ }
+ }
+ return '';
+}
+
+$default_commands_open{'node'} = \&_open_node_part_command;
+$default_commands_open{'part'} = \&_open_node_part_command;
+
sub _open_quotation_command($$$)
{
my $self = shift;
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index fc18f5ca20..b6d7004cec 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -10160,41 +10160,9 @@ convert_heading_command (CONVERTER *self, const enum
command_id cmd,
if (self->conf->NO_TOP_NODE_OUTPUT.o.integer > 0
&& builtin_command_data[cmd].flags & CF_root)
{
- const ELEMENT *node_element = 0;
int in_skipped_node_top
= self->shared_conversion_state.in_skipped_node_top;
- if (cmd == CM_node)
- node_element = element;
- else if (cmd == CM_part)
- {
- const ELEMENT *part_following_node
- = lookup_extra_element (element, "part_following_node");
- if (part_following_node)
- node_element = part_following_node;
- }
- if (node_element || cmd == CM_part)
- {
- int node_is_top = 0;
- if (node_element)
- {
- const char *normalized = lookup_extra_string (node_element,
- "normalized");
- if (normalized && !strcmp (normalized, "Top"))
- {
- node_is_top = 1;
- in_skipped_node_top = 1;
- self->shared_conversion_state.in_skipped_node_top
- = in_skipped_node_top;
- }
- }
- if (!node_is_top && in_skipped_node_top == 1)
- {
- in_skipped_node_top = -1;
- self->shared_conversion_state.in_skipped_node_top
- = in_skipped_node_top;
- }
- }
if (in_skipped_node_top == 1)
{
format_separate_anchor (self, element_id,
@@ -13929,6 +13897,50 @@ static const COMMAND_INTERNAL_CONVERSION
commands_internal_conversion_table[] =
{0, 0},
};
+void
+open_node_part_command (CONVERTER *self, const enum command_id cmd,
+ const ELEMENT *element, TEXT *result)
+{
+ if (self->conf->NO_TOP_NODE_OUTPUT.o.integer > 0)
+ {
+ const ELEMENT *node_element = 0;
+ int in_skipped_node_top
+ = self->shared_conversion_state.in_skipped_node_top;
+
+ if (cmd == CM_node)
+ node_element = element;
+ else if (cmd == CM_part)
+ {
+ const ELEMENT *part_following_node
+ = lookup_extra_element (element, "part_following_node");
+ if (part_following_node)
+ node_element = part_following_node;
+ }
+ if (node_element || cmd == CM_part)
+ {
+ int node_is_top = 0;
+ if (node_element)
+ {
+ const char *normalized = lookup_extra_string (node_element,
+ "normalized");
+ if (normalized && !strcmp (normalized, "Top"))
+ {
+ node_is_top = 1;
+ in_skipped_node_top = 1;
+ self->shared_conversion_state.in_skipped_node_top
+ = in_skipped_node_top;
+ }
+ }
+ if (!node_is_top && in_skipped_node_top == 1)
+ {
+ in_skipped_node_top = -1;
+ self->shared_conversion_state.in_skipped_node_top
+ = in_skipped_node_top;
+ }
+ }
+ }
+}
+
void
open_quotation_command (CONVERTER *self, const enum command_id cmd,
const ELEMENT *element, TEXT *result)
@@ -13975,6 +13987,8 @@ open_inline_container_type (CONVERTER *self, const enum
element_type type,
/* associate command to the C function implementing the opening */
static const COMMAND_INTERNAL_OPEN commands_internal_open_table[] = {
+ {CM_node, &open_node_part_command},
+ {CM_part, &open_node_part_command},
{CM_quotation, &open_quotation_command},
{CM_smallquotation, &open_quotation_command},
{0, 0},
diff --git a/tp/t/27float.t b/tp/t/27float.t
index 529a9b3af2..7d85610da6 100644
--- a/tp/t/27float.t
+++ b/tp/t/27float.t
@@ -140,6 +140,9 @@ In float
@caption{}
@end float
'],
+# NOTE for formats that ignore the node Top, most of the test
+# is skipped. This could be considered a feature, to check
+# ignore top node output, or could be changed.
['complex_float',
'@node Top
@top Test floats
diff --git a/tp/t/40moresectioning.t b/tp/t/40moresectioning.t
index 86a5bbb88b..4f7ce32a98 100644
--- a/tp/t/40moresectioning.t
+++ b/tp/t/40moresectioning.t
@@ -63,6 +63,14 @@ $test_text
['section_in_unnumbered_plaintext',
undef, {'test_file' => 'section_in_unnumbered_text.texi'},
],
+# tests that the footnotes segment is output in HTML
+['nodes_no_section_footnote_no_top_node_output',
+'@node Top
+@node chap
+
+a@footnote{my feet}
+', {}, {'USE_NODES' => 0, 'NO_TOP_NODE_OUTPUT' => 1},
+],
);
diff --git a/tp/t/converters_tests.t b/tp/t/converters_tests.t
index 12d8540790..d8b9c4e5b7 100644
--- a/tp/t/converters_tests.t
+++ b/tp/t/converters_tests.t
@@ -1287,13 +1287,13 @@ undef,{'test_file' => 'simplest.texi',},
],
['indices_in_begin_tables_lists',
undef, {'test_file' =>
'../../tests/formatting/indices_in_begin_tables_lists.texi'},
-{'SPLIT' => '', 'USE_NODES', 0}],
+{'SPLIT' => '', 'USE_NODES' => 0}],
# HTML still different from tests/indices indices_in_begin_tables_lists,
# as there is no relate_index_entries_to_items tree transformation
['indices_in_begin_tables_lists_entries_after_item',
undef, {'test_file' =>
'../../tests/formatting/indices_in_begin_tables_lists.texi',
'TREE_TRANSFORMATIONS' => 'move_index_entries_after_items'},
-{'SPLIT' => '', 'USE_NODES', 0}],
+{'SPLIT' => '', 'USE_NODES' => 0}],
['combined_fonts',
'@setfilename combined_fonts.info
diff --git a/tp/t/html_tests.t b/tp/t/html_tests.t
index 9ad695249e..f6a5e227ef 100644
--- a/tp/t/html_tests.t
+++ b/tp/t/html_tests.t
@@ -307,7 +307,7 @@ in @code{documentdescri---ption} --- @bullet{} @enddots{}
@verb{:"verb:} @aa{} @
@cindex entry
@printindex cp
-', {'test_split' => 'section'}, {'USE_NODES', 0}],
+', {'test_split' => 'section'}, {'USE_NODES' => 0}],
['letter_command_in_index',
'@node Top
@top top
@@ -1163,7 +1163,7 @@ Need 2 elements for separate footnotes.
@top top
-', {}, {'TOP_FILE' => 'my-node.html', 'USE_NODES', 0}],
+', {}, {'TOP_FILE' => 'my-node.html', 'USE_NODES' => 0}],
['command_in_node_redirection',
'@node Top
@top t @r{in r}
@@ -1266,7 +1266,7 @@ $itemize_arguments_text
],
['check_htmlxref_no_use_nodes',
$check_htmlxref_text
-, {}, {'CHECK_HTMLXREF' => 1, 'USE_NODES', 0}],
+, {}, {'CHECK_HTMLXREF' => 1, 'USE_NODES' => 0}],
['check_htmlxref_menu',
$check_htmlxref_text
, {'FORMAT_MENU' => 'menu',}, {'FORMAT_MENU' => 'menu', 'CHECK_HTMLXREF' =>
1}],
diff --git
a/tp/t/results/moresectioning/nodes_no_section_footnote_no_top_node_output.pl
b/tp/t/results/moresectioning/nodes_no_section_footnote_no_top_node_output.pl
new file mode 100644
index 0000000000..8224c0d44e
--- /dev/null
+++
b/tp/t/results/moresectioning/nodes_no_section_footnote_no_top_node_output.pl
@@ -0,0 +1,232 @@
+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{'nodes_no_section_footnote_no_top_node_output'} = {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'type' => 'preamble_before_content'
+ }
+ ],
+ 'type' => 'before_node_section'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'Top'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => {
+ 'text' => '
+'
+ }
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'is_target' => 1,
+ 'normalized' => 'Top'
+ },
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'source_info' => {
+ 'line_nr' => 1
+ }
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'chap'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => {
+ 'text' => '
+'
+ }
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'node',
+ 'contents' => [
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'a'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'my feet'
+ }
+ ],
+ 'type' => 'paragraph'
+ }
+ ],
+ 'type' => 'brace_command_context'
+ }
+ ],
+ 'cmdname' => 'footnote',
+ 'extra' => {},
+ 'source_info' => {
+ 'line_nr' => 4
+ }
+ },
+ {
+ 'text' => '
+'
+ }
+ ],
+ 'type' => 'paragraph'
+ }
+ ],
+ 'extra' => {
+ 'is_target' => 1,
+ 'normalized' => 'chap'
+ },
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'source_info' => {
+ 'line_nr' => 2
+ }
+ }
+ ],
+ 'type' => 'document_root'
+};
+
+$result_texis{'nodes_no_section_footnote_no_top_node_output'} = '@node Top
+@node chap
+
+a@footnote{my feet}
+';
+
+
+$result_texts{'nodes_no_section_footnote_no_top_node_output'} = '
+a
+';
+
+$result_nodes{'nodes_no_section_footnote_no_top_node_output'} = [
+ {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'node_directions' => {
+ 'next' => {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'node_directions' => {
+ 'prev' => {}
+ },
+ 'normalized' => 'chap'
+ }
+ }
+ },
+ 'normalized' => 'Top'
+ }
+ },
+ {}
+];
+$result_nodes{'nodes_no_section_footnote_no_top_node_output'}[0]{'extra'}{'node_directions'}{'next'}{'extra'}{'node_directions'}{'prev'}
= $result_nodes{'nodes_no_section_footnote_no_top_node_output'}[0];
+$result_nodes{'nodes_no_section_footnote_no_top_node_output'}[1] =
$result_nodes{'nodes_no_section_footnote_no_top_node_output'}[0]{'extra'}{'node_directions'}{'next'};
+
+$result_menus{'nodes_no_section_footnote_no_top_node_output'} = [
+ {
+ 'extra' => {
+ 'normalized' => 'Top'
+ }
+ },
+ {
+ 'extra' => {
+ 'normalized' => 'chap'
+ }
+ }
+];
+
+$result_errors{'nodes_no_section_footnote_no_top_node_output'} = [];
+
+
+$result_floats{'nodes_no_section_footnote_no_top_node_output'} = {};
+
+
+
+$result_converted{'plaintext'}->{'nodes_no_section_footnote_no_top_node_output'}
= 'a(1)
+
+ ---------- Footnotes ----------
+
+ (1) my feet
+
+';
+
+
+$result_converted{'html'}->{'nodes_no_section_footnote_no_top_node_output'} =
'<!DOCTYPE html>
+<html>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>Untitled Document</title>
+
+<meta name="description" content="Untitled Document">
+<meta name="keywords" content="Untitled Document">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+
+
+</head>
+
+<body lang="en">
+<a class="node" id="Top"></a><a class="node" id="chap"></a>
+<p>a<a class="footnote" id="DOCF1" href="#FOOT1"><sup>1</sup></a>
+</p><div class="footnotes-segment">
+<hr>
+<h4 class="footnotes-heading">Footnotes</h4>
+
+<h5 class="footnote-body-heading"><a id="FOOT1" href="#DOCF1">(1)</a></h5>
+<p>my feet</p>
+</div>
+
+
+
+</body>
+</html>
+';
+
+$result_converted_errors{'html'}->{'nodes_no_section_footnote_no_top_node_output'}
= [
+ {
+ 'error_line' => 'warning: must specify a title with a title command or @top
+',
+ 'text' => 'must specify a title with a title command or @top',
+ 'type' => 'warning'
+ }
+];
+
+
+1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Convert/HTML.pm (_convert_heading_command) (_open_node_part_command), tp/Texinfo/XS/convert/convert_html.c (convert_heading_command, open_node_part_command): set in_skipped_node_top when opening a @node (or associated @part), not after processing the contents.,
Patrice Dumas <=