use Texinfo::Common;
my @commands_to_collect = ('math');
my $collected_commands
= Texinfo::Common::collect_commands_in_tree($document_root,
\@commands_to_collect);
my $package_version
= Texinfo::Common::get_build_constant('PACKAGE_AND_VERSION');
The Texinfo Perl module main purpose is to be used in texi2any to convert
Texinfo to other formats. There is no promise of API stability.
Texinfo::Common holds hashes with miscellaneous information and some hashes with information on Texinfo @-commands, as well as miscellaneous methods.
Values defined for a Texinfo build independently of any document or
output format are available by calling get_build_constant:
The following build constants are available:
Texinfo package name and versions. Values of build constants without
_CONFIG appended are set by configure. For each variable set by
configure there is another one with _CONFIG appended
to the name set to the same value, to match the name of the macros set in
C. So, for example PACKAGE_VERSION_CONFIG value is the same as
PACKAGE_VERSION, set to the PACKAGE_VERSION value set by configure.
Hashes are defined as our variables, and are therefore available
outside of the module.
Keys are customization options corresponding to @-commands. For example
frenchspacing or footnotestyle.
Keys are null devices names, such as /dev/null or NUL.
Cannonical output formats that have associated conditionals. In
practice corresponds to format_raw %block_commands plus info
and plaintext.
Hashes are defined as our variables, and are therefore available
outside of the module.
The key of the hashes are @-command names without the @. The following hashes are available:
All the @-commands.
%def_aliases associates an aliased command to the original command, for
example defun is associated to deffn.
%def_no_var_arg_commands associates a definition command name with
a true value if the argument on the definition command line can contain
non-metasyntactic variables. For instance, it is true for deftypevr
but false for defun, since @defun argument is supposed to contain
metasyntactic variables only.
Associate small command like smallexample to the regular command
example.
Two methods are exported in the default case for Texinfo modules messages
translation in the Uniforum gettext framework, __ and __p.
The Texinfo tree and Texinfo tree elements used in argument of some functions
are documented in TEXINFO TREE. When customization
information is needed, an object that defines set_conf and/or get_conf is
expected, for example a converter inheriting from
Texinfo::Convert::Converter, see Getting and setting customization variables.
Returns the $msgid string translated in the Texinfo messages text domain.
__p can be used instead of __ to pass a $msgctxt context string to
provide translators with information on the string context when the string is
short or if the translation could depend on the context. __ corresponds to
the gettext function and __p to the pgettext function.
It is not advised to use those functions in user-defined code. It is not
practical either, as the translatable strings marked by __ or __p need to
be collected and added to the Texinfo messages domain. This facility could
only be used in user-defined code with translatable strings already present in
the domain anyway. In fact, these functions are documented mainly because they
are automatically exported.
See Locale::Messages,
gettext C interface,
Perl in GNU Gettext.
For translation of strings in output, see Texinfo::Translations.
Returns a hash reference with keys @-commands names specified in the $commands_list array reference and values arrays of tree elements corresponding to those @-command found in $tree by traversing the tree.
Return a list reference containing the tree elements corresponding to the @-commands names specified in the $commands_list found in $tree by traversing the tree. The order of the @-commands should be kept.
Returns the encoding name that can be used for decoding derived from the encoding that was set where $element appeared.
Return true if the element passed in argument is in running text context. If the optional $check_current argument is set, check the element itself, in addition to the parent context.
Encode the $file_name text string to a binary string $encoded_file_name
based on $input_encoding. Also returns the $encoding name actually
used which may have undergone some normalization. This function is mostly
a wrapper around Encode Encode::encode which avoids calling the module if not
needed. Do nothing if $input_encoding is undef.
This function returns the number or letter correponding to item
number $number for an @enumerate specification $specification,
appearing on an @enumerate line. For example
enumerate_item_representation('c', 3)
is e.
$element should be an accent command Texinfo tree element. Returns
an element containing the innermost accent @-command contents,
normally a text element with one or two letter, and an array reference
containing the accent commands nested in $element (including
$element). If there is no argument at all for the accent command,
$contents_element is undef.
Find the parent root command (sectioning command or node) of a tree element.
The $object argument is optional, its global_commands field is used
to continue through @insertcopying if in a @copying.
Return a Texinfo tree element corresponding to the content of the index
entry associated to $element. If $prefer_reference_element is set,
prefer an untranslated element. If the element is an index command like
@cindex or an @ftable @item, the content element is the argument
of the command. If the element is a definition line, the index entry
element is based on the name and class.
Returns the encoding assumed for input file names. $name_encoding is used as encoding name if defined. If $doc_encoding_for_input_file_name is set, the encoding is based on the input file content encoding, otherwise $locale_encoding is used. The $document argument is an optional Texinfo parsed document used to get the input document content encoding. The $input_file_encoding argument is optional, it will be used in priority if the the encoding is based on the input file encoding. If $input_file_encoding is not given, it is recommended to pass $document, otherwise there is no way to determine the input document content encoding.
Return true if the $tree has content that could be formatted. $do_not_ignore_index_entries is optional. If set, index entries are considered to be formatted.
Locate $file_path. If $file_path is an absolute path or has .
or .. in the path directories it is checked that the path exists and is a
file. Otherwise, the file name in $file_path is located in include
directories also used to find texinfo files included in Texinfo documents.
$file_path should be a binary string. undef is returned if the file was
not found, otherwise the file found is returned as a binary string.
Returns an $index_entry hash based on the $index_entry_info and
$indices_information. Also returns the $index_info hash with information on
the index associated to the index entry. $index_entry_info should be
an array reference with an index name as first element and the index entry number
in that index (1-based) as second element. In general, the $index_entry_info
is an extra index_entry associated to an element.
The $index_entry hash is described in Texinfo::Document index_entries. The
$index_info hash is described in Texinfo::Document::indices_information.
Normalize the node name string given in argument, by normalizing Top node case.
Remove first occurence of $element in the array reference $array.
If the optional $replacement argument is given, replace the $element
by $replacement. Return the removed element, or undef if not found.
Return numbered level of the tree sectioning element $section, as modified by raise/lowersections.
Set the Texinfo customization variable corresponding to $cmdname in $customization_information. The $global_commands_information should contain information about global commands in a Texinfo document, typically obtained from a parsed document $document->global_commands_information(). $command_location specifies where in the document the value should be taken from, for commands that may appear more than once. The possibilities are:
Set to the last value for the command.
Set sequentially to the values in the Texinfo preamble.
Set to the first value of the command if the first command is not in the Texinfo preamble, else set as with preamble, sequentially to the values in the Texinfo preamble.
The $element returned is the last element that was used to set the
customization value, or undef if no customization value was found.
Notice that the only effect of this function is to set a customization variable value, no @-command side effects are run, no associated customization variables are set.
Set the Texinfo customization option corresponding to the tree element
$element. The command associated to the tree element should be
a command that sets some information, such as @documentlanguage,
@contents or @footnotestyle for example. Return true if the command
argument was found and the customization variable was set.
If not already set, set OUTPUT_ENCODING_NAME based on input file
encoding.
Split the $element contents at @| in at max three parts.
Return an element containing the split parts in contents, or undef if
the $element has no useful content. The input $element
is supposed to be the argument line element of
%Texinfo::Commands::heading_spec_commands commands such as @everyheading.
Return true if the $name is a known customization option.
Return true if the $name is a known tree transformation name
that may be passed with TREE_TRANSFORMATIONS to modify a Texinfo
tree.
Copyright 2010- Free Software Foundation, Inc. See the source file for all copyright years.
This library 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.