6.2.1 Texinfo Tree Conversion Functions

One important converter method that can be used in user defined functions is convert_tree that convert a Texinfo tree rooted at any element. There is no reason to use that function often, as the converter already goes through the tree calling reference functions to convert the elements, but it can be interesting in some cases.

Function: $converted_text = $converter->convert_tree (\%element, $explanation)

\%element is a Texinfo tree element. $explanation is optional, it is a string explaining why the function was called, to help in case of debugging. The function returns \%element converted.

convert_tree is suitable when the conversion is in the flow of the Texinfo tree conversion. Sometime, it is better to ignore the formatting context of the main conversion, for example for the formatting of a caption, or the formatting of footnotes texts. Another special case is the case of tree elements being converted more than once, even if in the flow of the Texinfo tree conversion, for example if there are multiple @insertcopying in a document. A last special case arise, with formatting done in advance or out of the main conversion. This is the case, in practice, for sectioning commands or node commands which may be formatted as directions in navigation panels, menus or indices, may appear more than once in the document and be converted more than once, if language changes, for example.

For such cases, the function is convert_tree_new_formatting_context which sets the context appropriately. convert_tree_new_formatting_context ultimately calls convert_tree.

Function: $converted_text = $converter->convert_tree_new_formatting_context (\%element, $context, $multiple_pass, $global_context, $block_command_name)

\%element is a Texinfo tree element. $context is an optional string describing the new context to be setup to format out of the main conversion flow. If not defined, the conversion is done in the main document flow. $multiple_pass is an optional string that marks that the conversion is done more than once. It should be unique and suitable for inclusion in targets and identifiers. $global_context is an optional string that marks that the formatting may be done in advance, and can be redone. $block_command_name is an optional block command name that is used to initialized the new context. It can be useful, in particular, to propagate the topmost block command in the new context.

The function returns \%element converted, setting the conversion context according to the arguments.

See Setting the Context for Conversion on how to set a specific context for a Texinfo tree conversion.