12.1.3 Heading Commands Formatting

You can change the heading commands formatting by setting customization variables. In particular, you can change the navigation information output in headers associated with heading commands by selecting a different type of navigation (see HTML Output Structure Customization in Texinfo), by changing the links formatting (see File Names and Links Customization for HTML in Texinfo), the navigation panels formatting (see Customization of Navigation and Headers in Texinfo) and the heading levels (see Specific Customization of HTML Formatting in Texinfo).

@node and sectioning commands default conversion function call format_heading_text (see Basic Formatting Customization) and format_element_header (see Element Header and Footer Formatting). The @node and sectioning elements are formatted like any other elements associated with @-commands. The corresponding function references can therefore be replaced by user defined functions for a precise control of conversion (See Command Tree Element Conversion Functions).

In the default formatting, when a sectioning command is encountered, a <div> element is opened for the extent of the sectioning command including its children sectioning commands. This extent need to be closed at different places, for instance when another sectioning command is reached, at the end of a file, or at the end of the document.

The user defined formatting function should take care of registering and closing opened section levels. In the default code, registering is done in the sectioning commands conversion function only.

The function for registering opened section extent is register_opened_section_level:

Function: $converter->register_opened_section_level ($filename, $level, $closing_text)

$filename is the filename the section belongs to. You could use $converter->current_filename() for $filename. $level is the sectioning command level. It is typically obtained with section->{'extra'}->{'section_level'} (see Texinfo Tree Elements in User Defined Functions). $closing_text is the text that should be output when the section level $level is closed.

The function for closing registered section extents is close_registered_sections_level:

Function: \@closing_texts = $converter->close_registered_sections_level ($filename, $level)

$filename is the filename the closed sections belong to. You could use $converter->current_filename() for $filename. $level is the sectioning command level. Opened section are closed down to section level $level. The closing texts are returned in the \@closing_texts array reference in order.

Example of use:

my $level = $opening_section->{'extra'}->{'section_level'};
my $closed_strings
   = $converter->close_registered_sections_level(
                    $converter->current_filename(), $level);
$result .= join('', @{$closed_strings});

# ....

$converter->register_opened_section_level(
                 $converter->current_filename(), $level, "</div>\n");