Text_Highlighter
[ class tree: Text_Highlighter ] [ index: Text_Highlighter ] [ all elements ]

Class: Text_Highlighter

Source Location: /Text_Highlighter-0.4.1/Highlighter.php

Class Overview


Text highlighter base class


Author(s):

Variables

Methods


Child classes:

Text_Highlighter_XML
Auto-generated class. XML syntax highlighting
Text_Highlighter_PHP
Auto-generated class. PHP syntax highlighting
Text_Highlighter_DIFF
Auto-generated class. DIFF syntax highlighting
Text_Highlighter_SQL
Auto-generated class. SQL syntax highlighting
Text_Highlighter_JAVASCRIPT
Auto-generated class. JAVASCRIPT syntax highlighting
Text_Highlighter_MYSQL
Auto-generated class. MYSQL syntax highlighting
Text_Highlighter_CSS
Auto-generated class. CSS syntax highlighting
Text_Highlighter_DTD
Auto-generated class. DTD syntax highlighting
Text_Highlighter_PYTHON
Auto-generated class. PYTHON syntax highlighting

Inherited Variables

Inherited Methods


Class Details

[line 90]
Text highlighter base class

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 Text_Highlighter_Generator to create descendent class. Alternatively, an instance of a descendent class can be created directly.

Use Text_Highlighter::factory() to create an object for particular language highlighter

Usage example

  1. require_once 'Text/Highlighter.php';
  2. $hlSQL =Text_Highlighter::factory('SQL',array('numbers'=>true));
  3. echo $hlSQL->highlight('SELECT * FROM table a WHERE id = 12');



[ Top ]


Class Variables

$_syntax =

[line 101]

Syntax highlighting rules.

Auto-generated classes set this var


Type:   array


[ Top ]



Method Detail

factory   [line 163]

mixed &factory( string $lang, [array $options = array()])

Create a new Highlighter object for specified language

Parameters:

string   $lang   —  language, for example "SQL"
array   $options   —  Highlighting options. This array is passed to new object's constructor, and the constructor, in turn, passes it to Text_Highlighter::_init()

[ Top ]

highlight   [line 222]

string highlight( string $str)

Highlights code
  • Return: Highlighted text
  • Access: public

Parameters:

string   $str   —  Code to highlight

[ Top ]

_init   [line 198]

void _init( [array $options = array()])

Initilizes highlighting options
  • Access: protected

Parameters:

array   $options   — 

Output options. Assocative array with following elements (each being optional):

  • 'tag' - HL_TAG_PRE or HL_TAG_CODE
  • 'numbers' - Whether to add line numbering
  • 'tabsize' - Tab size
  • 'style' - CSS style of top-level tag
Passing any of these elements overwrites the default value of corresponding variable.

Descendents of Text_Highlighter call this method from the constructor, passing $options they get as parameter.


[ Top ]


Documentation generated on Mon, 11 Mar 2019 13:51:46 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.