| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
5. Overview of initialization files content and loading
The initialization files are perl files, read as explained
in Use initialization files for fine tuning. You don't need to know much of perl
to do some simple changes in variable values, however, to be able to
really take advantage of all the features of the initialization file,
a good knowledge of perl is required.
In initialization file two kind of variables appear. These are normal
variables (including arrays and hashes) and references on functions.
The later permits the dynamic redefinition of functions used to produce
the HTML manual. You should be able to change the value of some
normal variables without a deep knowledge of perl, by looking
at the existing examples. The possible mistakes in that case could be
omitted `;', and bad quoting.
Initialization file are loaded from the main program by
the mean of a require, while in the Texi2HTML::Config
namespace. This means that the namespace of the main program and
the namespace of inititalization files are distinct, which ensures
that no name clash should happen. The variables are declared with the
our specifier, such that it should be possible to use the
use strict pragma in the initialization file code.
To avoid messing with the variables in the main namespace
all the global variables which could be of use in the init files
are in the Texi2HTML namespace. Notice that the functions
of the main program are still in the main namespace.
| 5.1 Redefining functions in initialization files | Function redefinition is achieved with redefinition of references on functions. | |
| 5.2 Conventions used for function prototypes | Conventions used in that manual for function reference prototypes display. |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
5.1 Redefining functions in initialization files
To redefine a function you must replace the corresponding funtion
reference with a reference on your function.
Thus you should write your function, give it a name you
are certain it is unique in the Texi2HTML::Config namespace,
and override the value of the function reference with your own
function reference. When another function from the main program
(or from another functions of an initialization file) calls the reference,
your function will be used.
For example the function
reference corresponding with the function called when doing an
anchor is called
$anchor. Thus if you want to override the
corresponding function
you could write:
# override the function reference
$anchor = \&my_own_function;
# the function reference now refers to
sub my_own_function {
# process arguments and return an html anchor
}
|
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
5.2 Conventions used for function prototypes
As the functions are defined by a reference name, we will always
use the reference name in function prototypes. For the function arguments
we will use \@array for a reference on an array and similarly
\%hash for a reference on a hash.
Thus, the prototype for the function associated with the function reference `$formatting_function' will be:
- Function Reference: $text formatting_function $arg1 \@arg2
formatting_functiontakes as first argument $arg2, as second argument a reference on an array \@arg2 and returns the formatted text $text.
To redefined the corresponding function, you should write:
$formatting_function = \&my_formatting_function
sub my_formatting_function($ $)
{
my $arg1 = shift;
my $arg2 = shift;
# prepare $formatted_text
.....
return $formatted_text
}
|
| [ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by Derek R. Price on July, 14 2005 using texi2html 1.77.
![[ Valid XHTML 1.0! ]](/branding/w3c-valid-xhtml10-44x16.png)
![[ Valid CSS! ]](/branding/w3c-valid-css-44x16.png)
