PHP Class Text_Highlighter, yii

This class implements all functions necessary for highlighting, but it does not contain highlighting rules. Actual highlighting is done using a descendent of this class. One is not supposed to manually create descendent classes. Instead, describe highlighting rules in XML format and use {@link Text_Highlighter_Generator} to create descendent class. Alternatively, an instance of a descendent class can be created directly. Use {@link Text_Highlighter::factory()} to create an object for particular language highlighter Usage example require_once 'Text/Highlighter.php'; $hlSQL = Text_Highlighter::factory('SQL',array('numbers'=>true)); echo $hlSQL->highlight('SELECT * FROM table a WHERE id = 12');
Author: Andrey Demenev ([email protected])
Afficher le fichier Open project: yiisoft/yii Class Usage Examples

Méthodes publiques

Свойство Type Description
$_conditions array Conditionds
$_disabled array Disabled keywords
$_language string Language
$_options array Options. Keeped for BC
$_renderer array Renderer object.
$_syntax array Auto-generated classes set this var

Méthodes publiques

Méthode Description
_checkDefines ( ) Called by subclssses' constructors to enable/disable optional highlighter rules
_getToken ( )
_matchingBrackets ( $str ) Helper function to find matching brackets
factory ( string $lang, array $options = [] ) : mixed Create a new Highlighter object for specified language
highlight ( string $str ) : string Highlights code
setRenderer ( object $renderer ) Set renderer object

Method Details

_checkDefines() public méthode

Called by subclssses' constructors to enable/disable optional highlighter rules
public _checkDefines ( )

_getToken() public méthode

public _getToken ( )

_matchingBrackets() public méthode

Helper function to find matching brackets
public _matchingBrackets ( $str )

factory() public static méthode

Create a new Highlighter object for specified language
public static factory ( string $lang, array $options = [] ) : mixed
$lang string language, for example "SQL"
$options array Rendering options. This parameter is only keeped for BC reasons, use {@link Text_Highlighter::setRenderer()} instead
Résultat mixed a newly created Highlighter object, or a PEAR error object on error

highlight() public méthode

Highlights code
public highlight ( string $str ) : string
$str string Code to highlight
Résultat string Highlighted text

setRenderer() public méthode

Set renderer object
public setRenderer ( object $renderer )
$renderer object Text_Highlighter_Renderer

Property Details

$_conditions public_oe property

Conditionds
public array $_conditions
Résultat array

$_disabled public_oe property

Disabled keywords
public array $_disabled
Résultat array

$_language public_oe property

Language
public string $_language
Résultat string

$_options public_oe property

Options. Keeped for BC
public array $_options
Résultat array

$_renderer public_oe property

Renderer object.
public array $_renderer
Résultat array

$_syntax public_oe property

Auto-generated classes set this var
See also: _init
public array $_syntax
Résultat array