[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Fri, 4 Aug 2023 08:16:20 -0400 (EDT) |
branch: master
commit 49a4e646682e1b0f27067378f3a5ce71e5b9df07
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Fri Aug 4 13:15:47 2023 +0100
Generate master menu in plaintext output
* tp/Texinfo/Common.pm (new_master_menu): Take extra optional
argument which is the menu in the Top node.
* tp/Texinfo/Convert/Plaintext.pm (_convert) <sectioning commands>:
At the Top node, call new_master_menu after calling
Texinfo::Structuring::new_complete_node_menu, so to also generate
a detailed menu.
---
ChangeLog | 11 +++++++++++
tp/Texinfo/Common.pm | 19 ++++++++++++++-----
tp/Texinfo/Convert/Plaintext.pm | 14 +++++++++++++-
.../indices/printindex_between_node_section.pl | 9 +++++++--
.../res_info/end_of_line_command_in_node_lines.info | Bin 1124 -> 1267 bytes
.../regions/ref_in_copying_insert_in_chapter.pl | 9 +++++++--
.../sectioning/automatic_menu_referencing_node.pl | 9 +++++++--
7 files changed, 59 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 484cc92bba..0c7001441f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-08-04 Gavin Smith <gavinsmith0123@gmail.com>
+
+ Generate master menu in plaintext output
+
+ * tp/Texinfo/Common.pm (new_master_menu): Take extra optional
+ argument which is the menu in the Top node.
+ * tp/Texinfo/Convert/Plaintext.pm (_convert) <sectioning commands>:
+ At the Top node, call new_master_menu after calling
+ Texinfo::Structuring::new_complete_node_menu, so to also generate
+ a detailed menu.
+
2023-08-04 Gavin Smith <gavinsmith0123@gmail.com>
* tp/Texinfo/Common.pm (_print_down_menus):
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 7a4136fc45..12ee3748f4 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1971,18 +1971,27 @@ sub _normalized_entry_associated_internal_node($;$)
}
# used in Plaintext converter and tree transformations
-sub new_master_menu($$)
+sub new_master_menu($$;$)
{
my $self = shift;
my $labels = shift;
+ my $top_menu = shift;
+
my $node = $labels->{'Top'};
return undef if (!defined($node));
+ my @menus;
+ if (defined($top_menu)) {
+ @menus = ( $top_menu );
+ } elsif ($node->{'extra'}
+ and $node->{'extra'}->{'menus'}
+ and scalar(@{$node->{'extra'}->{'menus'}})) {
+ @menus = @{$node->{'extra'}->{'menus'}};
+ }
+
my @master_menu_contents;
- if ($node->{'extra'}
- and $node->{'extra'}->{'menus'}
- and scalar(@{$node->{'extra'}->{'menus'}})) {
- foreach my $menu (@{$node->{'extra'}->{'menus'}}) {
+ if (@menus) {
+ foreach my $menu (@menus) {
foreach my $entry (@{$menu->{'contents'}}) {
if ($entry->{'type'} and $entry->{'type'} eq 'menu_entry') {
my ($normalized_entry_node, $node)
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index eed028ba2a..dbd5d71dbc 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -3832,7 +3832,19 @@ sub _convert($$)
if ($node and $automatic_directions
and !$self->{'seenmenus'}->{$node}) {
$self->{'seenmenus'}->{$node} = 1;
- my $menu_node = Texinfo::Structuring::new_complete_node_menu($node);
+ my $menu_node;
+ $menu_node = Texinfo::Structuring::new_complete_node_menu($node);
+ if ($command eq 'top' and $menu_node) {
+ my $detailmenu = Texinfo::Common::new_master_menu($self,
+ $self->{'labels'},
+ $menu_node);
+ if ($detailmenu) {
+ # TODO: add a blank line before detailmenu, as in
+ # regenerate_master_menu.
+ $detailmenu->{'parent'} = $menu_node;
+ push @{$menu_node->{'contents'}}, $detailmenu;
+ }
+ }
if ($menu_node) {
my $menu_text = $self->_convert($menu_node);
if ($menu_text) {
diff --git a/tp/t/results/indices/printindex_between_node_section.pl
b/tp/t/results/indices/printindex_between_node_section.pl
index 13584bbac9..fcacb9e022 100644
--- a/tp/t/results/indices/printindex_between_node_section.pl
+++ b/tp/t/results/indices/printindex_between_node_section.pl
@@ -668,6 +668,11 @@ top
* Menu:
* node chap1::
+ -- The Detailed Node Listing --
+
+chapter 1
+
+* node sec1::
File: , Node: node chap1, Prev: Top, Up: Top
@@ -699,8 +704,8 @@ File: , Node: node sec1, Up: node chap1
Tag Table:
Node: Top27
-Node: node chap1114
-Node: node sec1214
+Node: node chap1173
+Node: node sec1273
End Tag Table
diff --git
a/tp/t/results/info_tests/end_of_line_command_in_node_lines/res_info/end_of_line_command_in_node_lines.info
b/tp/t/results/info_tests/end_of_line_command_in_node_lines/res_info/end_of_line_command_in_node_lines.info
index bcfd399ea6..abe87481c1 100644
Binary files
a/tp/t/results/info_tests/end_of_line_command_in_node_lines/res_info/end_of_line_command_in_node_lines.info
and
b/tp/t/results/info_tests/end_of_line_command_in_node_lines/res_info/end_of_line_command_in_node_lines.info
differ
diff --git a/tp/t/results/regions/ref_in_copying_insert_in_chapter.pl
b/tp/t/results/regions/ref_in_copying_insert_in_chapter.pl
index 1717a01d4f..ac9bc8e2c1 100644
--- a/tp/t/results/regions/ref_in_copying_insert_in_chapter.pl
+++ b/tp/t/results/regions/ref_in_copying_insert_in_chapter.pl
@@ -634,6 +634,11 @@ top
* Menu:
* Intro::
+ -- The Detailed Node Listing --
+
+Introduction
+
+* GFDL::
File: , Node: Intro, Prev: Top, Up: Top
@@ -657,8 +662,8 @@ File: , Node: GFDL, Up: Intro
Tag Table:
Node: Top41
-Node: Intro118
-Node: GFDL228
+Node: Intro175
+Node: GFDL285
End Tag Table
diff --git a/tp/t/results/sectioning/automatic_menu_referencing_node.pl
b/tp/t/results/sectioning/automatic_menu_referencing_node.pl
index eee939225c..696ffa33e5 100644
--- a/tp/t/results/sectioning/automatic_menu_referencing_node.pl
+++ b/tp/t/results/sectioning/automatic_menu_referencing_node.pl
@@ -363,6 +363,11 @@ top
* Menu:
* Chapter::
+ -- The Detailed Node Listing --
+
+chap
+
+* section::
File: , Node: Chapter, Prev: Top, Up: Top
@@ -384,8 +389,8 @@ File: , Node: section, Up: Chapter
Tag Table:
Node: Top27
-Node: Chapter108
-Node: section193
+Node: Chapter160
+Node: section245
End Tag Table