# ManipulateTree.pm: common Texinfo tree manipulation
#
# Copyright 2010-2024 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License,
# or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Original author: Patrice Dumas
# functions useful for Texinfo tree transformations
# and some tree transformations functions, mostly those
# used in conversion to main output formats. In general,
# tree transformations functions are documented in the POD section.
# Some helper functions defined here are used in other
# modules but are not generally useful in converters
# and therefore not public.
package Texinfo::ManipulateTree;
use 5.006;
# stop \s from matching non-ASCII spaces, etc. \p{...} can still be
# used to match Unicode character classes.
use if $] >= 5.014, re => '/a';
use strict;
# To check if there is no erroneous autovivification
#no autovivification qw(fetch delete exists store strict);
# debugging
use Carp qw(cluck confess);
use Texinfo::StructTransfXS;
use Texinfo::XSLoader;
use Texinfo::Common;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(
move_index_entries_after_items_in_tree
relate_index_entries_to_table_items_in_tree
protect_colon_in_tree
protect_comma_in_tree
protect_first_parenthesis
protect_node_after_label_in_tree
);
our $VERSION = '7.2';
my $XS_structuring = Texinfo::XSLoader::XS_structuring_enabled();
our %XS_overrides = (
"Texinfo::ManipulateTree::copy_tree"
=> "Texinfo::StructTransfXS::copy_tree",
"Texinfo::ManipulateTree::relate_index_entries_to_table_items_in_tree"
=> "Texinfo::StructTransfXS::relate_index_entries_to_table_items_in_tree",
"Texinfo::ManipulateTree::move_index_entries_after_items_in_tree"
=> "Texinfo::StructTransfXS::move_index_entries_after_items_in_tree",
"Texinfo::ManipulateTree::protect_colon_in_tree"
=> "Texinfo::StructTransfXS::protect_colon_in_tree",
"Texinfo::ManipulateTree::protect_comma_in_tree"
=> "Texinfo::StructTransfXS::protect_comma_in_tree",
"Texinfo::ManipulateTree::protect_node_after_label_in_tree"
=> "Texinfo::StructTransfXS::protect_node_after_label_in_tree",
);
our $module_loaded = 0;
sub import {
if (!$module_loaded) {
if ($XS_structuring) {
for my $sub (keys %XS_overrides) {
Texinfo::XSLoader::override ($sub, $XS_overrides{$sub});
}
}
$module_loaded = 1;
}
# The usual import method
goto &Exporter::import;
}