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])
Mostrar archivo Open project: yiisoft/yii Class Usage Examples

Public Properties

Property 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

Public Methods

Method 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 method

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

_getToken() public method

public _getToken ( )

_matchingBrackets() public method

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

factory() public static method

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
return mixed a newly created Highlighter object, or a PEAR error object on error

highlight() public method

Highlights code
public highlight ( string $str ) : string
$str string Code to highlight
return string Highlighted text

setRenderer() public method

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

Property Details

$_conditions public_oe property

Conditionds
public array $_conditions
return array

$_disabled public_oe property

Disabled keywords
public array $_disabled
return array

$_language public_oe property

Language
public string $_language
return string

$_options public_oe property

Options. Keeped for BC
public array $_options
return array

$_renderer public_oe property

Renderer object.
public array $_renderer
return array

$_syntax public_oe property

Auto-generated classes set this var
See also: _init
public array $_syntax
return array