Disabling styling of some Lexics - GeSHi/geshi-1.0 GitHub Wiki
One disadvantage of GeSHi is that for large source files using complex languages, it can be quite slow with every option turned on. Although future releases will concentrate on the speed/resource side of highlighting, you can gain speed by disabling some of the highlighting options. This is done by using a series of set_*_highlighting
methods:
-
set_keyword_group_highlighting($group, $flag):
- Sets whether a particular
$group
of keywords is to be highlighted or not. Consult the necessary language file(s) to see what$group
should be for each group (typically a positive integer).$flag
isfalse
if you want to disable highlighting of this group, andtrue
if you want to re-enable higlighting of this group. If you disable a keyword group then even if the keyword group has a related URL one will not be generated for that keyword.
- Sets whether a particular
-
set_comments_highlighting($group, $flag):
- Sets whether a particular
$group
of comments is to be highlighted or not. Consult the necessary language file(s) to see what$group
should be for each group (typically a positive integer, or th string'MULTI'
for multiline comments.$flag
isfalse
if you want to disable highlighting of this group, andtrue
if you want to re-enable highlighting of this group.
- Sets whether a particular
-
set_regexps_highlighting($regexp, $flag):
- Sets whether a particular
$regexp
is to be highlighted or not. Consult the necessary language file(s) to see what$regexp
should be for each regexp (typically a positive integer, or the string'MULTI'
for multiline comments.$flag
isfalse
if you want to disable highlighting of this group, andtrue
if you want to re-enable highlighting of this group.
- Sets whether a particular
The following methods:
set_escape_characters_highlighting($flag)
set_symbols_highlighting($flag)
set_strings_highlighting($flag)
set_numbers_highlighting($flag)
set_methods_highlighting($flag)
Work on their respective lexics (e.g. set_methods_highlighting()
will disable/enable highlighting of methods). For each method, if $flag
is false
then the related lexics will not be highlighted at all (this means no HTML will surround the lexic like usual, saving on time and bandwidth.
In case all highlighting should be disabled or reenabled GeSHi provides two methods called disable_highlighting()
and enable_highlighting($flag)
. The optional paramter $flag
has been added in 1.0.7.21 and specifies the desired state, i.e. true
(default) to turn all highlighting on, or false
to turn all highlighting off. Since 1.0.7.21 the method disnable_highlighting()
has become deprecated.