Texi2HTML - Texinfo to HTML v1.77: 7. Customizing HTML and text style in init files
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7. Customizing HTML and text style in init files

Some simple customization may be achieved with the redefinition of the variables associated with the command line options. For the description and an explanation of the meaning of these variables, Customizing the HTML and text style.

Other variables and hash entries can be modified in initialization file to achieve more customization. Lastly, functions references corresponding with functions called from the main program and initialization files may be redefined.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.1 Three contexts for expansions: preformatted, normal and string

There are three contexts of interest, one is the normal context, the other is a special context, called the preformatted context and the last is the string context. The preformatted context occurs when the spacing between words is kept. This is the case, for example, in @display or @example regions, and in menu comments (see section Menu formatting). The preformatted regions are usually rendered in <pre> elements in HTML. The string context occurs when rendering strings without formatting elements, in comments or titles for example.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.2 Customizing the formatting of commands without argument

This includes the commands whose name is a nonletter character like @@, the commands with lettered characters and braces but whose braces should be empty, like @TeX{}, or some commands associated with accentted letters like @AA{}. If there happens to be something within the braces, it is put after the command, thus

 
@TeX{something}

leads to the same than

 
@TeX{} something

Each of these categories of commands have three associated hashes, one for normal context, the other for preformatted context and the last in strings. The keys of the hashes are the command names, the associated value is the text replacing the command.

The hashes are:

command type

normal text

preformatted text

string

one nonlettered character

%simple_map

%simple_map_pre

%simple_map_texi

nothing in braces

%things_map

%pre_map

%texi_map

To change the HTML resulting from these constructs, just change the value. For example, if you want &shy; to be outputted for @- in normal and preformatted context, write in your init file:

 
$simple_map{'-'} = '&shy;';
$simple_map_pre{'-'} = '&shy;';

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.3 Customizing accent, style and other simple commands

The formatting of the HTML produced by style and indicatric commands (@tt, @code, @email, @titlefont), the accentuation related commands taking argument (@', @udotaccent, @dotless) and miscalleneous commands (@email, @verb, @w, @uref, @math, @asis) is controlled by two hash in the default case, %style_map for normal context, %style_map_pre for preformatted context and %style_map_texi in string context.

The key of the hashes are the command names. There are two possibilities for the values corresponding with two interfaces. The values may be strings or hash references, and you can chose the interface depending on the one you prefer. The interface with hash reference is a bit more flexible but might also be regarded as more complex. If you don't like either of these interfaces you can define your own.

Some remarks are in order:

  • The nonlettered accent commands which following character is considered to be the argument (like in @`a) should be keys of the hash %accent_map hash, even if no value is associated.
  • @math is handled differently if LaTeX2HTML is used.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.3.1 An interface for commands formatting with a hash reference

The key of the hashes are the command names. The value determine how the command argument is formatted. This value is a reference on a hash. In this hash each key corresponds with a type of information for the formatting, and the value is the corresponding information. For example, in

 
$style_map{'command'} = { 'args' => ['code'], 'attribute' => 'code'};

the arguments for @command are interpreted as specified by the values associated with the `args' key while the attribute associated with that command is `code'.

The following keys in the hashes associated with each command have the following meaning:

`args'

The value associated is a reference on an array. Each element of the array defines how the arguments (separated by `,' in the texinfo code) for the @-command should be formatted. The possibilities are

normal

for normal text,

code

for text with `---', `--', `''' and ```' kept as is,

keep

if the texinfo should be kept as is, without interpretation of the @-commands.

For example, we have

 
$style_map{'email'}->{'args'} = ['code', 'normal'];

because `---', `--', `''' and ```' should be kept as is in the first argument of @email.

The default is `['normal']'.

`attribute'

If the associated value is a word, it is considered to be an HTML element name, and the argument is enclosed between the element opening and the element closing. For example, if the value is elem, the resulting HTML is <elem>arg</elem>.

If the text is a word followed by some text, the word and is interpreted as above, and the text is considered to be the attributes text of the element. Thus elem class="elem" leads to <elem class="elem">arg</elem>.

This works only if there is only one argument.

`begin'

The associated value is added in front of the text.

`begin'

The associated value is added after the text.

`quotes'

If the corresponding value is true, the result is enclosed in quotes $OPEN_QUOTE_SYMBOL and $CLOSE_QUOTE_SYMBOL, with defaults ``' and `''.

`function'

The corresponding value should be a function reference. The corresponding function is called with the following arguments:

$command

The @-command name

$args

A reference on an array containing the arguments of the @-command.

$style_stack

A reference on an array containing the name of the @-commands containing the @-command being formatted.

$state

A reference on a hash containing a lot of informations about the context of the @-command.

$line_nr

An opaque structure containing the information about the line number of the @-command. It can be used to call main::echo_error or main::echo_warning with first argument a message, and second argument $line_nr.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.3.2 An interface for commands formatting with a string

The keys of the hashes are the command names. The value determine how the command argument is formatted. If the value begins with `"', the result is enclosed in quotes $OPEN_QUOTE_SYMBOL and $CLOSE_QUOTE_SYMBOL, with defaults ``' and `''.

The command argument is allready formatted as HTML. The remaining of the value text (or the value text if there were no `"') is interpreted as follow:

  • If the text is empty the argument of the command is left as is.
  • If the text is a `&' followed by a name, like `&function', the name is considered to be a function name, and this function is called to format the argument of the command. The first argument of the function is the command name, the second is the command argument. For example, if the value associated with the (fictituous) command @foo is &my_func and we have:
     
    sub my_func
    {
        my @args = split /,\s*/ $_[1];
        return "$_[0]: $args[0]" if ($args[1] = 1);
        return "$args[0]";
    }
    

    The result of

     
    @foo{truc, 1}
    @foo{truc, bidule}
    

    will be

     
    foo: truc
    truc
    
  • If the text is a word, it is considered to be an HTML element name, and the argument is enclosed between the element opening and the element closing. For example, if the value is elem, the resulting HTML is <elem>arg</elem>. Similarly "quoted leads to `<quoted>arg</quoted>'.
  • If the text is a word followed by some text, the word and is interpreted as above, and the text is considered to be the attributes text of the element. Thus elem class="elem" leads to <elem class="elem">arg</elem>.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.3.3 Defining the style and indicatric commands interface

If you don't like this scheme, it is possible to change how those commands are processed by redefining the following function reference:

Function Reference: $resulting_text style $style $command $text $args $no_close $no_open $line_nr $state $style_stack

$command is the @-command, $style is the value associated with the $command in the %style_map, %style_map_pre or %style_map_texi hashes. The $text is the text appearing within the @-command braces. args is a reference on an array contening the command arguments formatted according to the same conventions than with the reference hash style (provided the value associated with the @-command is a hash reference with a $arg key as described in Reference hash args). If $text is split in paragraphs each paragraph is passed through the function, and $no_close is true if it is not the last paragraph, while $no_open is true if it is not the first paragraph. $line_nr is an opaque structure containing the information about the line number of the @-command. It can be used to call main::echo_error or main::echo_warning with first argument a message, and second argument $line_nr. $state is a reference on a hash containing a lot of informations about the context of the @-command. $style_stack is a reference on an array containing the name of the @-commands containing the @-command being formatted.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.4 Formatting of special simple commands

The formatting of special simple commands is controlled by functions. To customize the output, the corresponding function references should be redefined. All these functions return a formatted text.

The formatting of anchors is controlled by $anchor, but the function associated with the function reference does more, it is usefull to produce a reference target or link.

Function Reference: $anchor anchor $identifier $href $text $attributes

If $identifier is not empty, this value should be used to create a target for links (typically associated with a name or id attribute in HTML). The $href argument specifies a hpertextual reference which should be used to link to a target. In case both $identifier and $href are given the text produced should be both a target for $identifier and a link to $href. $text is the text to be displayed. $attributes are additional attributes. It should be reasonable to assume that the attributes are for a <a> HTML element.

The formatting of @image is controlled by:

Function Reference: $image image $file_path $basename $preformatted $file_name

$file_path is the image file name with the path, $basename is the alternate text or the file name without extension if no alternate text is given. $preformatted is true if the image appears in preformatted text. $file_name is the file name without path but with extension.

The formatting of @sp is controlled by:

Function Reference: $sp sp $number $preformatted

$number is the numeric argument of @sp. $preformatted is true if the @sp appears in preformatted text.

The formatting of @acronym and @abbr is controlled by:

Function Reference: $acronym acronym_like $acronym_texi $acronym_text $with_explanation \@explanation_lines $explanation_text $explanation_simply_formatted

$acronym_texi is the acronym argument with texinfo @-commands, $acronym_text is formatted.

The other arguments are related with the explanation, the second arg of the acronym. $with_explanation is true if the second argument of the acronym command is present. If an explanation exists, coming from previous @acronym or as an arg of this command, the other args are defined: \@explanation_lines is a reference on an array containing the unformatted explanation lines, $explanation_text is the explanation text formatted, $explanation_simply_formatted is the explanation with a light formatting, unabling in HTML (or XML) the explanation to be in an attribute.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.5 Processing special characters in text

Some characters are processed especially in text: `---', `--', ```' and `'''. This is done only if in normal text and not in some commands (@code, @env…). A function reference is called to process those characters in text

Function Reference: $processed_text normal_text $text

The function processes `---', `--', ```' and `''' in $text and returns $processed_text. The default is to change `---' to `--', `--' to `-', and ```' and `''' to `"'.

Some characters are special in HTML (`&', `"', `<' and `>') and should be protected. This is done by the function associated with the function reference

Function Reference: $protected_text protect_text $text

The function processes the unprotected text $text and returns the resulting protected text $protected_text.

Empty lines are processed by the following function reference, which could be usefull if empty lines are to be removed for example

Function Reference: $resulting_text empty_line $empty_line

This function processes an $empty_line and returns the resulting text $resulting_text. Empty lines are left as is by default.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.6 Customizing strings written by texi2html

texi2html writes some strings in the generated document at various places, at the page footers, on the help page, for special section headings, buttons alt text and so on. These strings are customizable. The string chosen depends on the language of the document (set by `--lang', $LANG or @documentlanguage). This is the basis for internationalization as it allows for strings translations.

The strings are found in a hash reference, $LANGUAGES. Each key is a language code. The associated value is also a hash reference. The key is an english string and the associated value is the string replacing the english string, if present. For example, we have

 
$LANGUAGES->{'fr'} = {
              ' Up ' => 'Plus haut',
};

It means that whenever the string ` Up ' is to be written and the language is `fr', `Plus haut' is written. It is possible to customize the english strings by redefining the `en' language hash.

When a string contains a `%' followed by `{' name `}' it means that the string will be expanded by texi2html. For example, if we have

 
$LANGUAGES->{'fr'} = {
              'See %{node_file_href}' => 'Voir %{node_file_href}',
};

`%{node_file_href}' will be expanded to an href for a node in a file by texi2html in the string. A `%%' will be expanded as `%'.

For more on internationalization, see Internationalization.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.7 References


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.7.1 Reference to external manual

The references are produced with two function references, one for the hypertextual reference construction, the other for the full reference to external manual.

Function Reference: $href external_href $node $node_identifier $xml_node_identifier $manual_file_name

$node is the node name, with @-commands. $node_identifer is the node name mapped to an identifier acceptable as a file name. $xml_node_identifier is the node name mapped to an identifier acceptable as an XML identifier. Those identifiers are built as explained in (texinfo)HTML Xref, thus allowing for cross references to external manuals. $file is the manual or file name of the external reference. This function should return an href leading to the external manual.

The default for this function is to make a reference compatible with makeinfo (see (texinfo)HTML Xref).

Function Reference: $text external_ref $command $section $book $node_and_file $href $cross_ref_name

This function formats a reference to an external texinfo manual. The $command is the ref command (ref, xref or pxref, in text, at sentence beginning or in parenthesis). The optionnal $section argument is the section in the book and book is the book title. $node_and_file is the node and file name formatted according to the convention used in info: `(file)node'. $href it an hypertextual reference to the distant manual constructed using the above function. $cross_ref_name is an optionnal cross reference name appearing in the reference command. This function returns the text corresponding with the external html manual reference. This function returns the full formatted text of the external reference.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.7.2 Reference to an internal node

A function reference is available for internal references.

Function Reference: $text internal_ref $command $href $short_name $name $is_section

This function formats a reference to a node in the current manual. The $command is the ref command (ref, xref or pxref, in text, at sentence beginning or in parenthesis). $href it an hypertextual reference linking to the corresponding node or section. $short_name and $name hold the text for the reference but $short_name can be the node name which is assumed to be shorter than the section name. $is_section is a boolean true if the reference is a reference to a section. This function returns the full formatted text of the internal reference.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.8 Commands used for centering and flushing of text

When a command controlling the alignement of text is used (@center, @flushleft and @flushright), the main program takes care of opening and closing paragraphs. The alignement commands are the key of the %paragraph_style hash. The value is used in the function doing the formatting of the paragraphs. See section Formatting or not a paragraph or a preformatted region.

A function references allows for a customization of the formatting of the text appearing in the command block.

Function Reference: $result paragraph_style_command $command $text

$command is the command name, $text is the text appearing within the command. This function returns a formatted text. The default is to return the text unmodified.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.9 Formatting or not a paragraph or a preformatted region


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.9.1 Paragraph and preformatted region formatting

The formatting of a paragraph region or a preformatted region, is controlled by function references:

Function Reference: $paragraph_text paragraph $text $alignement $formatting_command $formatting_command_formatted \$paragraph_number $format $item_number $enumerate_style $number

This function formats a paragraph. $text is the text of the paragraph, $alignement is the empty string when no alignement command has been seen, otherwise it is the current alignement command name. See section Commands used for centering and flushing of text.

The remaining arguments are usefull when the paragraph appears within a list or table. It is usefull whenever the paragraph has to be formatted differently when appearing in such environments. Moreover in that case the format command (@itemize…) may have an associated formatting command. $formatting_command is this formatting command (like @minus). $formatting_command_formatted is the command formatted in html in case the formatting command is a leading command (like @minus) which should be leading the first paragraph. \$paragraph_number is a reference on the number of paragraphs in that format command. The corresponding variable should be increased when a paragraph is added. $format is the format command. See section Formatting individual table and list items.

If the $format is an enumerate, $item_number is the number of the item in the list, $enumerate_style is the argument of the enumerate, $number is the number or letter corresponding with this item.

Function Reference: $preformatted_text preformatted $text $style $region_name $formatting_command $formatting_command_formatted \$preformatted_number $format $item_number $enumerate_style $number

This function formats a preformatted region. $text is the text of the preformatted region, $style is the css style associated with that preformatted region (See section Customizing the texi2html css lines). $region_name is the name of the command opening the preformatted region (example…, see Formatting of complex formats (@example, @display…)) or a identifier for the preformatted context (for example menu-comment, see Menu formatting). The alignment commands are not taken into account, as the spaces are preserved in preformatted regions, you should flush and center by hand.

The remaining arguments are usefull when the preformatted region appears within a list or table. It is usefull whenever the preformatted region has to be formatted differently when appearing in such environments. Moreover in that case the format command (@itemize…) may have an associated formatting command. $formatting_command is this formatting command (like @minus). $formatting_command_formatted is the command formatted in html in case the formatting command is a leading command (like @minus) which should be leading the first preformatted region. \$preformatted_number is a reference on the number of preformatted regions in that format command. The corresponding variable should be increased when a preformatted region is added. $format is the format command. See section Formatting individual table and list items.

If the $format is an enumerate, $item_number is the number of the item in the list, $enumerate_style is the argument of the enumerate, $number is the number or letter corresponding with this item.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.9.2 Avoiding paragraphs in formats

It is possible to avoid that a format closes the previous paragraph or preformatted region and reopens one, by putting the format command in a hash, %format_in_paragraph with a true value.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.10 Formatting of complex formats (@example, @display…)

Here we see how a whole complex format is formatted. For the formatting of the text, see Formatting or not a paragraph or a preformatted region.

The formatting of the complex formats is ultimately controlled by a function, however the default for this function uses a hash reference and changing the hash reference values should be enough in most cases. This hash reference is called $complex_format_map. It has a key for each of the complex format commands (example, smallexample, lisp, smalllisp, display, smalldisplay, format, smallformat).

The associated value is also a reference on a hash. The keys are begin and end. An eval of begin should lead to the beginning of the formatted HTML, an eval of end should lead to the end of the formatted HTML. The enclosed text will be formatted as described in Formatting or not a paragraph or a preformatted region, and the name of the complex format will be available to the function formatting the text.

If you aren't satisfied with this scheme, you can redefine the following function reference for a better control over the complex format formatting:

Function Reference: $complex_format_text complex_format $format_name $preformatted_text

$format_name is the complex format name, $preformatted_text is the text allready formatted as described in Formatting or not a paragraph or a preformatted region. This function returns the whole complex format.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.11 Customizing the formatting of lists and tables

The formatting of lists and tables is done at two levels:

  • At the level of the whole region (table or list),
  • At the level of the individual items, rows or cells of the list or table.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.11.1 Formatting individual table and list items

In texinfo it is possible to give @itemize or table command (hereafter called a format command) a formatting command. For example @minus is the formatting command here:

 
@table @minus

The default is to apply the command to the text item, however it is possible to avoid it. The hash %special_list_commands has an entry for each of the format command. Each of these entries is a hash reference. If a formatting command is a key of the hash reference, then the formatting command is not applied to the text item for that format command. For example, if we have:

 
$special_list_commands{'itemize'} = { 'bullet' => '' };

and we have the following @itemize:

 
@itemize @bullet
@item an item
@end itemize

then @bullet will not be applied to an item.

lists

The items of lists are formatted using the following function reference:

Function Reference: $list_item list_item $text $format $command $formatted_command $item_number $enumerate_style $number

This function formats the text between @item commands. $text is the text corresponding with the item. $format is the type of format, `itemize' or `enumerate'. $command is the formatting command given in argument to @itemize, $formatted_command is this command formatted if it is a leading command, like @minus.

If the $format is an enumerate, $item_number is the number of the item in the list, $enumerate_style is the argument of the enumerate, $number is the number or letter corresponding with this item.

two column tables

The two columns tables (@table, @ftable and @vtable), items are formatted using two function references, one for the first line located on the @item line corresponding with the first column, the other for the text appearing on the following lines, corresponding with the second column text.

Function Reference: $table_item table_item $item_text $index_label_text $format $command $formatted_command

This function is used to format the text on the @item line. $text_item is the text line. In case there is an index entry associated with the @item (as with @ftable and @vtable), $index_label_text is the text inserted at the place where an index entry appears. See section Formatting of index entries. $format is the type of format, `table', `ftable' or `vtable'. $command is the formatting command given in argument to the table format command, $formatted_command is this command formatted if it is a leading command, like @minus.

Function Reference: $table_line table_line $text

This function is used to format the text on the lines following the @item line. $text is the corresponding text.

multitable

The multitable elements formatting is controlled by the functions associated with two function references. One for a cell, and the other for a row.

Function Reference: $multitable_cell cell $text

This function is used to format the text of a multitable cell, the text following a @item or a @tab. $text is the corresponding text.

Function Reference: $multitable_row row $text $item_command

This function is used to format a multitable row. $text is the row text, with cells allready formatted with the $cell function reference. $item_command is the command used to introduce the row, such that it is possible to distinguish between @item and @headitem.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.11.2 Formatting of a whole table or list

If the Texinfo command is a key of the %format_map, the associated value is used to specify the formatting of the construct, otherwise a function is called. The value in %format_map associated with a command is interpreted similarly with values associated with more simpler commands:

  • If the text is a word, it is considered to be an HTML element name, and the whole table or list is enclosed between the element opening and the element closing.
  • If the text is a word followed by some text, the word and is interpreted as above, and the text is considered to be the attributes text of the element.
  • If the text is empty nothing is added to the text.

In case the %format_map isn't used, a function reference called $table_list should be redefined, the associated function will be called each time a command isn't found in %format_map.

Function Reference: $whole_table_list table_list $command $text

$command is the Texinfo command name, $text is the formatted items.

If you still want to use %format_map but differently from the default, it is possible to redefine the following function reference:

Function Reference: $whole_table_list format $command $format $text

$command is the @-command, $format is the entry associated with $command in %format_map. $text is the formatted items.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.12 Definition commands formatting

The formatting of definition commands is controlled by a hash and four functions. The hash describes how the text on the definition line is interpreted, the functions control the formatting of the definition line and the definition function text.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.12.1 Customizing the interpretation of a definition line

The keys of the hash %def_map are definition command names. There are two types of entries:

  • If the command is a shortcut for another definition command the value is a text and the definition command is replaced by the text.

    For example if we have:

     
    $def_map{'deftruc'} = '@defvr {A truc}';
    

    and a line like

     
    @deftruc var
    

    the line will be transformed in

     
    @defvr {A truc} var
    
  • If the command isn't a shortcut, it is associated with an array reference. The first element is `f', `v' or `t' corresponding with the index type (`f' for function, `v' for variable, `t' for type).

    The remaining of the array describes how to interpret the text following the definition command on the definition command line. The entry item specify what corresponds with the next bracketed item or word. Currently the possibilities are `category', `name', `type', `class' and `arg'.

    For example if we have

     
    def_map{'defvr'} = [ 'v', 'category', 'name' ];
    

    The first bracketed item following @defvr is considered to be the category and the next one is the name. The index associated with the definition line is the variables index.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.12.2 Customization of the definition formatting

Four functions are used when formatting a definition command:

category name
Function Reference: $category definition_category $category_or_name $class $style

This function precise a category or an index entry name associating a class $class (if given) with $category_or_name. The $style of the definition may be `f', for function, `v', for variable or `t', for type.

formatting of the definition line
Function Reference: $line def_line $category $name $type $arguments $index_label

This function formats the definition line. $category is the category formatted with $definition_category, $name, $type and arguments are the element of the definition line. $index_label is the text inserted at the place where an index entry appears. See section Formatting of index entries.

definition text
Function Reference: $definition_text def_item $text

This function formats the definition text, $text.

the whole definition
Function Reference: $definition def $text

This function formats the whole definition. The definition line and text formatted by the above functions are in $text.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.13 Customizing headings formatting

A function controls the formatting of sectioning element headings, with the corresponding function reference:

Function Reference: $heading_text heading \%element_reference

The \%element_reference is a reference on a hash corresponding with the sectioning element. The following keys are of interest:

text

The heading text

name

The heading text without section number

node

true if the sectioning element is a node without associated structuring command

level

The level of the element in the document tree. `0' is for @top, `1' for @chapter and so on

tag_level

the sectioning element name, with @raisesections and @lowersections taken into account


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.14 Formatting of special regions (@verbatim, @cartouche, @quotation)

Regions corresponding with raw text, like @verbatim, @html or @tex are formatted according to the following function reference:

Function Reference: $raw_region raw $command $text

$command is the command name, $text is the raw text.

If LaTeX2HTML is used, @tex regions are handled differently, from within the main program.

The @cartouche command formatting is controlled by the function reference:

Function Reference: $cartouche cartouche $text

$text is the text appearing within the cartouche.

The formatting of @quotation is controlled by two function references. The first one is usefull in case the @quotation has an argument, as it allows to prepend a string to the quotation text:

Function Reference: $prepended_string quotation_prepend_text $style $text

$style is the first argument of the @quotation if there are two arguments. $text is the second argument or the first if there is one argument. There are still @-commands in these strings. This function can return a string which will be prepended to the quotation text.

The whole quotation is formatted by:

Function Reference: $quotation quotation $quotation_text $argument_text $argument_style_texi $argument_style_id

$quotation_text is the quotation text, formatted, with the text prepended by the function above. $argument_text is the second argument of the @quotation or the first if there is one argument, formatted. The other arguments are defiend if there are two arguments for the @quotation, $argument_style_texi is this argument, with @-commands, and $argument_style_id is this argument transformed in an identifier which can be used as an XML identifier.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.15 Menu formatting

To understand how the formatting of menus is controlled, the different parts of a menu are first described, then how to control the formatting of each of these parts.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.15.1 The structure of a menu

In texi2html, a menu is considered to be composed of 2 parts, the menu entries and the menu comments. Menu entries are further divided in an entry link and optionnaly an entry description. The entry link consists in a node name and an optionnal menu entry name.

A menu entry begins with `*' at the beginning of the line. It begins with the entry link, followed by the description. The description spans until the next menu entry, or some text begining at the first character of a line or an empty line, not contained within a command block which begun in the description. An empty line or a line with text at the first character starts a menu comment, which spans until the next menu entry.

Here is an illustration of these rules:

 
@menu
* node name: entry name.        description begins
   description continues
* another menu entry::
   description begins
                    description continues

   A menu comment, after an empty line

* node::                        description begins
A menu comment. The line starts at the first character

* last entry::         description begins text
of the description, even if the line begins at the first character,
because we are in @emph.
@end menu

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.15.2 The formatting of the different menu components

In the default case, the name of the section corresponding with the node is used instead of the node name. If $NODE_NAME_IN_MENU is true, however, node names are used. If $AVOID_MENU_REDUNDANCY is true and menu entry equal menu description the description isn't printed. This is the default. Likewise, if node or section name equal entry name, do not print entry name.

A symbol, $MENU_SYMBOL is put at the beginning of menu entries when the node name is used. The default is `&bull;'. If $UNNUMBERED_SYMBOL_IN_MENU is true it is also put at the beginning of unnumbered section names. This is not done by default.

The menu comments are considered to be preformatted text. The style associated with this preformatted text is determined by $MENU_PRE_STYLE. Default is `font-family: serif'. The css class associated with menu comments is menu-comments.

Three function references are associated with the formatting of the different parts of a menu:

Function Reference: $link menu_link $section \%state $href $node $name $ending

$section is the section name corresponding with the link, $href is the link hypertextual reference. $href may be absent. \%state holds informations about the current context. The only key which could be of interest is preformatted, true if the context is a preformatted context. See section Three contexts for expansions: preformatted, normal and string. $node is the node name, $name is the name of the node, and $ending is the text ending the link entry.

Function Reference: $description menu_description $description_text \%state

$description_text is the text of the menu description. \%state should be used similarly than for the menu link.

Function Reference: $menu_comment menu_comment $text

$text is the text of the menu comment. It is in a preformatted environment.

The following function reference controls the formatting of a wole menu:

Function Reference: $menu menu $menu_components_text

$menu_components_text is the formatted menu components text, obtained as explained above.

The last function reference corresponds with a special case. It is used when a menu entry appears within another block command, to avoid the possibilities of invalid HTML production. In that case the menu description and menu comments are not formatted specially, but treated like normal text.

Function Reference: $link simple_menu_link $link_text $href $node $name $ending

$link_text is the text corresponding with the link name, $href is the link hypertextual reference. $node is the node name, $name is the name of the node, and $ending is the text ending the link entry.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.16 Indices formatting

Two different things needs to be handled for indices formatting, the place where the index term appears, the index entry, and the index list itself. The indexing commands like @cindex determines where index entries appear, and the index list is printed with a @printindex command.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.16.1 Formatting of index entries

Index entry places in the main text may be the target for hypertext references. Their formatting is controlled by the function associated with the following function reference:

Function Reference: $target index_entry_label $identifier $preformatted

$identifier should be used to create a target for links (typically associated with a name or id attribute in HTML). $preformatted is true if the index entry appeared in preformatted text.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.16.2 Customizing the formatting of index lists

The index entries are sorted alphabetically. A whole index list is considered to be composed of letter entries. A letter entry is composed by all the index entries beginning with that letter. A letter may be a non alphabetical character, but we call it letter here.

An index summary appears at the beginning and at the end of an index list, and should be used to jump directly to a letter entry. Indices lists may be split across pages, thus the different letters may appear on different files. The number of index entries appearing on each page is determined by a variable $SPLIT_INDEX if set. The default is to split indices after 100 entries.

The formatting of all these elements is controlled by the following function references:

formatting of a letter in a summary
Function Reference: $letter summary_letter $letter $file $identifier

This function is used to format a letter appearing in a summary, refering to a letter entry in the index list. $letter is the letter. $file is the file name where the letter entry appears. More precisely, it is empty when the letter entry is on the same page than the summary, it contains the file name when the index page is split accross page. $identifier is an identifier for the target letter entry.

formatting of a summary
Function Reference: $summary index_summary \@alphabetical_letters \@nonalphabetical_letters

\@alphabetical_letters and \@nonalphabetical_letters contain the formatted summary letters, formatted with the above function.

formatting of an index entry
Function Reference: $entry index_entry $entry_href $entry_text $section_href $section_heading

$entry_href is a reference to the place where the index entry appeared, $entry_text is the corresponding text. $section_href is a reference to the beginning of the sectioning element containing the index entry, $section_heading is the heading of the element.

formatting of letter entry
Function Reference: $letter_entry index_letter $letter $identifier $index_entries_text

This function formats a letter entry, consisting in all the index entries beginning with this letter. $letter is the letter, $identifier should be used to create a target for links (typically links from summaries), and $index_entries_text is the text of the index entries formatted as described above.

formatting of whole index
Function Reference: $index print_index $index_text $index_name

$index_text is the text of all the index entries grouped by letter appearing in that page formatted as above. index_name is the name of the index, the argument of @printindex.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.17 Floats and lists of floats

Floats appear in the @float environment, optionaly with a style and a label, and with optionnal @caption and @shortcaption. Their list appear after a @listoffloats.

A hash reference is associated with each float, it is available in some formatting functions. The keys are:

caption_texi
shortcaption_texi

A reference on an array containing the caption or shortcaption lines, unformatted.

style_texi

The style with texi @-commands.

style_id

The unique identifier associated with the style.

nr

The number with the same conventions than makeinfo (use the chapter number a dot and then the number of the float of that style in the chapter, or an absolute number if in unnumbered).

chapter_nr

The number of the chapter containing the float.

nr_in_chapter

The number of the float in the chapter.

absolut_nr

The number of the float in the document.

texi

The label with @-commands.

id

The unique identifier associated with the label. Usefull to make an anchor or a reference.

element

A reference on a structure representing the element the float appear in.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.17.1 Formatting a float

First there is an occasion to construct a texinfo text for the caption, using the caption texinfo lines and the informations in the float structure. The returned lines will be formatted in the main program. A function reference is used here:

Function Reference: (\@caption_lines_returned, \@shortcaption_lines_returned) caption_shortcaption \%float \@caption_lines \@shortcaption_lines

\%float is the structure defined above. \@caption_lines and \@shortcaption_lines are references on arrays containing the texinfo lines for caption and short caption. \@caption_lines_returned and \@shortcaption_lines_returned are references on an array containing the texinfo lines for the caption and shortcaption.

Then the float is formatted with the following function reference:

Function Reference: $text float $float_text \%float $caption_text $shortcaption_text

$float_text is the text appearing within the @float, formatted. \%float is still the structure defined above. $caption_text and $shortcaption_text are the caption and short caption build with the above function and formatted.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.17.2 Formatting lists of floats

A list of floats is introduced by @listoffloats. The argument of @listoffloats is the style. First the style texinfo can be modified with the following function reference:

Function Reference: $style_texi_returned listoffloats_style $style_texi

$style_texi is the @listoffloats argument with texinfo @-commands kept. It is possible to make changes to the $style_texi and return a modified string, still with @-commands. The modified string is formatted in the main program.

After that, for each of the floats with that style, first there is a possibility to modify the float style and the float caption before they are formatted in the main program, with the following function references:

Function Reference: $float_style_texi_returned listoffloats_float_style $style_texi \%float

$style_texi is the style, and \%float is the structure described above. This function reference returns a style to be formatted in the main program.

Function Reference: $caption_texi_returned listoffloats_caption \%float

\%float is the structure described above. This function reference returns a caption to be formatted in the main program.

Each entry is formatted by:

Function Reference: $listoffloats_entry listoffloats_entry $style_texi \%float $float_style $caption $href

$style_texi is the style with @-commands, $float_style is the style returned by the above function and formatted. $caption is the caption returned by the above function formatted. \%float is the structure corresponding with the float, and $href is an href pointing to the float location.

Lastly, the whole @listoffloats is formatted by:

Function Reference: $listoffloats listoffloats $style_texi $style \@listoffloats_entries

$style_texi is the style with @-commands, $style is the style returned by the above function and formatted. The array reference \@listoffloats_entries holds the entries formatted by the above function.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.18 Customizing the footnotes formatting

Each footnote is associated with a footnote entry. Several footnote entries are grouped in a footnote section. When a footnote appears, two things must be formatted: in the main text the place where the footnote appear and the footnote text.

Two functions, with corresponding function references control the formatting of the footnotes:

Function Reference: (\@lines $text_for_document) foot_line_and_ref $number_in_doc $number_in_page $footnote_id $place_id $document_file $footnote_file \@lines \%state

$number_in_doc is the footnote number in the whole document, $number_in_page is the footnote number in the current page. $footnote_id is an identifier for the footnote in the footnote text which should be used to make target for references to that footnote, while $place_id is an identifier for the location of the footnote in the main document. Similarly, $document_file is the file name of the file containing the text where the footnote appears in the main document, while $footnote_file is the file name of the file where the footnote text appears.

\@lines is a reference on an array containing the footnote text lines, allready formatted. And \%state holds informations about the context at the footnote place in the main document. As usual the most usefull entry is preformatted which is true if the footnote appears in a preformatted context.

This function returns a reference on an array, \@lines containing the updated footnote text for the footnote entry, and $text_for_document, the text appearing at the footnote place in the main document, linking to the footnote entry.

The following function is only used when footnotes are at the bottom of a page and the document is split. For customization of the footnotes page in case they are on a separated page or section, Customizing the layout of the special pages. For the determination of the footnote locations, Page layout related command line options.

Function Reference: foot_section \@footnotes_lines

This function formats a group of footnotes. \@footnotes_lines is a reference on an array holding the lines of all the footnote entries formatted as explained above. This function modifies the reference.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.19 Customizing other commands, and unknown commands

Many commands without braces are available in texinfo, sometimes with a specific syntax. For example we have @sp, @noindent, @documentlanguage, @oddheading, @headings, @shortcontents, @shorttitlepage or @comment. texi2html interprets some of these commands and some functions or variables are used for their formatting or to access their information. In the default case, however, most of these constructs are ignored.

It is possible to change how the things following these commands on the line are handled, what is considered to be an arg for those commands and it is also possible to keep them instead of discarding them such that it is possible to handle them specially, with the same function than the one used for unknown commands.

Those special commands without braces are the key of a hash: %misc_command. The associated value is a reference on a hash enabling to set the properties of these commands. The keys of this hash reference is the name of a property, the value is the value of the property. For example here we have line for the arg property for the command @-command.

 
$misc_command{'command'} = {'arg' => 'line', 'skip' => 'space'};

The properties and possible values are:

skip

This property enables to set what is skipped after the command arguments. Here are the possible values:

line

The remaining of the line is skipped.

space

Spaces are skipped but not newline.

whitespace

Spaces are skipped

linewhitespace

Spaces are skipped if there are only spaces remaining on the line.

linespace

Spaces are skipped, but not newline if there are only spaces remaining on the line

arg

If the associated value is line the line is considered to be the argument. If it is a number it is the number of args (separated by spaces).

texi

If true the arguments are considered to real texinfo, therefore @value and @macro are expanded.

keep

If true the args and the macro are kept, otherwise they are discarded. The defaut is to have keep undef for all the commands. If keep is true for @verbatiminclude the default action for this macro isn't done.

Commands which don't appear in the hashes %simple_map, %simple_map_pre, %simple_map_texi and %misc_command, or that appear in %misc_command but with keep true are processed by the following function reference:

Function Reference: ($result_line, $result, $result_text, $message) unknown $command $line

$command is the @-command, $line is the line following the $command. $result is a boolean. If it is true then the other return values are taken into account otherwise the default actions are used. In case $result is true, $result_line is the new line to be processed further, $result_text is the resulting f