[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Structuring.pm (new_node_menu_entry)
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Structuring.pm (new_node_menu_entry): do not protect colons in node name, but protect in section name used as menu entry name. |
Date: |
Sat, 13 Aug 2022 12:20:47 -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 603c21e18b * tp/Texinfo/Structuring.pm (new_node_menu_entry): do not
protect colons in node name, but protect in section name used as menu entry
name.
603c21e18b is described below
commit 603c21e18b9bfcf2f73690e14dddb8d86b84c5c2
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Aug 13 18:20:36 2022 +0200
* tp/Texinfo/Structuring.pm (new_node_menu_entry): do not
protect colons in node name, but protect in section name used as
menu entry name.
---
ChangeLog | 6 ++++++
tp/Texinfo/Structuring.pm | 18 ++++++++++------
tp/t/automatic_menus.t | 52 ++++++++++++++++++++++++++++++++++++++++++++---
3 files changed, 67 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 376e64abb8..0baf69b59a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-08-13 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Structuring.pm (new_node_menu_entry): do not
+ protect colons in node name, but protect in section name used as
+ menu entry name.
+
2022-08-13 Patrice Dumas <pertusus@free.fr>
Do not output node menus with pod2texi in the default case
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index fc2110dd02..d46e324213 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -1418,7 +1418,7 @@ sub get_node_node_childs_from_sectioning
}
# returns the texinfo tree corresponding to a single menu entry pointing to
$NODE.
-# if $USE_SECTIONS is set, use the section name instead of node name.
+# if $USE_SECTIONS is set, use the section name as menu entry name.
sub new_node_menu_entry
{
my ($node, $use_sections) = @_;
@@ -1431,7 +1431,8 @@ sub new_node_menu_entry
my ($name_contents, $menu_entry_name);
if ($use_sections) {
if (defined $node->{'extra'}->{'associated_section'}) {
- $name_contents =
$node->{'extra'}->{'associated_section'}->{'args'}->[0]->{'contents'};
+ $name_contents
+ =
$node->{'extra'}->{'associated_section'}->{'args'}->[0]->{'contents'};
} else {
$name_contents = $node_contents; # shouldn't happen
}
@@ -1446,6 +1447,9 @@ sub new_node_menu_entry
foreach my $content (@{$menu_entry_name->{'contents'}}) {
$content->{'parent'} = $menu_entry_name;
}
+ # colons could be doubly protected, but it is probably better
+ # than not protected at all.
+ Texinfo::Common::protect_colon_in_tree($menu_entry_name);
}
my $menu_entry_node = {'type' => 'menu_entry_node'};
@@ -1455,13 +1459,15 @@ sub new_node_menu_entry
foreach my $content (@{$menu_entry_node->{'contents'}}) {
$content->{'parent'} = $menu_entry_node;
}
- Texinfo::Common::protect_colon_in_tree($menu_entry_node);
+ # do not protect here, as it could already be protected, and
+ # the menu entry should be the same as the node
+ #Texinfo::Common::protect_colon_in_tree($menu_entry_node);
my $description = {'type' => 'menu_entry_description'};
$description->{'contents'}->[0] = {'type' => 'preformatted',
'parent' => $description};
- $description->{'contents'}->[0]->{'contents'}->[0] = {'text' =>"\n",
- 'parent' => $description->{'contents'}->[0]};
+ $description->{'contents'}->[0]->{'contents'}->[0] = {'text' => "\n",
+ 'parent' => $description->{'contents'}->[0]};
if ($use_sections) {
$entry->{'args'}
@@ -1492,7 +1498,7 @@ sub new_node_menu_entry
if ($content) {
$entry->{'extra'}->{'menu_entry_node'}->{'normalized'}
= Texinfo::Convert::NodeNameNormalization::normalize_node(
- {'contents' => $content } );
+ {'contents' => $content } );
}
$entry->{'extra'}->{'menu_entry_description'} = $description;
diff --git a/tp/t/automatic_menus.t b/tp/t/automatic_menus.t
index 1058b795d2..62abd10128 100644
--- a/tp/t/automatic_menus.t
+++ b/tp/t/automatic_menus.t
@@ -15,12 +15,13 @@ use Data::Dumper;
ok(1);
-sub test($$$;$)
+sub test($$$;$$)
{
my $in = shift;
my $out = shift;
my $name = shift;
my $complete_missing_menus = shift;
+ my $use_sections = shift;
my $parser = Texinfo::Parser::parser();
my $tree = $parser->parse_texi_text($in);
@@ -34,10 +35,11 @@ sub test($$$;$)
= Texinfo::Structuring::sectioning_structure($registrar,
$parser, $tree);
if ($complete_missing_menus) {
- Texinfo::Transformations::complete_tree_nodes_missing_menu($tree);
+ Texinfo::Transformations::complete_tree_nodes_missing_menu($tree,
+ $use_sections);
#print STDERR "".Texinfo::Common::print_tree($tree)."\n";
} else {
- Texinfo::Transformations::complete_tree_nodes_menus($tree);
+ Texinfo::Transformations::complete_tree_nodes_menus($tree, $use_sections);
}
my $texi_result = Texinfo::Convert::Texinfo::convert_to_texinfo($tree);
@@ -121,6 +123,50 @@ test('@node Top
@chapter chap2
', 'menu completed before');
+my $colon_in_menu_entry_text = '@node Top
+@top top
+
+@node nc::ha. p1
+@chapter ch:ap::1
+
+@node nch@asis{:}ap2
+@chapter chap@asis{:}2
+';
+
+test($colon_in_menu_entry_text,
+'@node Top
+@top top
+
+@menu
+* nc::ha. p1::
+* nch@asis{:}ap2::
+@end menu
+
+@node nc::ha. p1
+@chapter ch:ap::1
+
+@node nch@asis{:}ap2
+@chapter chap@asis{:}2
+',
+, 'colon in menu entries');
+
+test($colon_in_menu_entry_text,
+'@node Top
+@top top
+
+@menu
+* ch@asis{:}ap@asis{::}1: nc::ha. p1.
+* chap@asis{@asis{:}}2: nch@asis{:}ap2.
+@end menu
+
+@node nc::ha. p1
+@chapter ch:ap::1
+
+@node nch@asis{:}ap2
+@chapter chap@asis{:}2
+',
+, 'colon in menu entries use sections', undef, 1);
+
test('@node Top
@top top
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Structuring.pm (new_node_menu_entry): do not protect colons in node name, but protect in section name used as menu entry name.,
Patrice Dumas <=