User defined functions called for an @-command element conversion, after
arguments and contents have been formatted, are registered with
texinfo_register_command_formatting
:
$command_name is an @-command name, with the leading @. \&handler is the user defined function reference.
The call of the user defined functions is:
$text
command_conversion ($converter, $command_name, \%element, \@args, $content)
¶$converter is a converter object. $command_name is the @-command name without the @. \%element is the Texinfo element.
\@args, if defined, is a reference on the formatted arguments of the @-command. Each of the array items correspond to each of the @-command argument. Each array item is a hash references, with keys corresponding to possible argument formatting contexts:
normal
Argument formatted in a normal context
monospace
Argument formatted in a context where spaces are kept as is, as well as quotes and minus characters, for instance in ‘--’ and ‘``’. Both in preformatted and code context. See Init File Expansion Contexts: Normal, Preformatted, Code, String, Math.
monospacestring
Same as monospace, but in addition in string context. See Init File Expansion Contexts: Normal, Preformatted, Code, String, Math.
monospacetext
Same as monospace, but in addition the argument is converted to plain text. See Converter Object and Conversion Functions.
filenametext
Same as monospacetext, but in addition the document encoding is used
to convert accented letters and special insertion @-commands to plain
text even if ENABLE_ENCODING
is unset.
raw
Text is kept as is, special HTML characters are not protected. Appears only
as @inlineraw
second argument.
string
In string context. See Init File Expansion Contexts: Normal, Preformatted, Code, String, Math.
tree
The Texinfo tree element corresponding to the argument. See Texinfo Tree Elements in User Defined Functions.
url
Similar with filenametext. The difference is that UTF-8 encoding is always used for the conversion of accented and special insertion @-commands to plain text. This is best for percent encoding of URLs, which should always be produced from UTF-8 encoded strings.
The formatted arguments contexts depend on the @-command, there could be none,
for @footnote
argument which is not directly converted where the
footnote command is, or multiple, for example for the fourth argument of
@image
which is both available as ‘normal’ and
‘string’.
For example, $args->[0]->{'normal'}
is the first argument converted in
normal context.
$content is the @-command formatted contents. It corresponds to the
contents of block @-commands, and to Texinfo code following @node
,
sectioning commands, @tab
and @item
in @enumerate
and
@itemize
. $content can be undef
or the empty string.
The $text returned is the result of the @-command conversion.
To call a conversion function from user defined code, the function reference
should first be retrieved using command_conversion
:
\&command_conversion =
$converter->command_conversion ($command_name)
¶$command_name is the @-command name without the @. Returns the conversion function reference for $command_name, or ‘undef’ if there is none, which should only be the case for @-commands ignored in HTML not defined by the user.
for example, to call the conversion function for the @tab
@-command,
passing arguments that may correspond to another @-command:
&{$converter->command_conversion('tab')}($converter, $cmdname, $command, $args, $content);
It is possible to have access to the default conversion function reference. The function used is:
\&default_command_conversion =
$converter->default_command_conversion ($command_name)
¶$command_name is the @-command name without the @. Returns the default conversion function reference for $command_name, or ‘undef’ if there is none, which should only be the case for @-commands ignored in HTML.