Class HTMLPurifier_Lexer
Forgivingly lexes HTML (SGML-style) markup into tokens.
A lexer parses a string of SGML-style markup and converts them into corresponding tokens. It doesn't check for well-formedness, although its internal mechanism may make this automatic (such as the case of HTMLPurifier_Lexer_DOMLex). There are several implementations to choose from.
A lexer is HTML-oriented: it might work with XML, but it's not recommended, as we adhere to a subset of the specification for optimization reasons. This might change in the future. Also, most tokenizers are not expected to handle DTDs or PIs.
This class should not be directly instantiated, but you may use create() to retrieve a default copy of the lexer. Being a supertype, this class does not actually define any implementation, but offers commonly used convenience functions for subclasses.
Indirect known subclasses
HTMLPurifier_Lexer_PH5PNote: We use tokens rather than create a DOM representation because DOM would:
Par
Par: -# Require more processing and memory to create, -# Is not streamable, and -# Has the entire document structure (html and body not needed).
Par: However, DOM is helpful in that it makes it easy to move around nodes without a lot of lookaheads to see when a tag is closed. This is a limitation of the token system and some workarounds would be nice.
Located at x2engine/framework/vendors/htmlpurifier/HTMLPurifier.standalone.php
public static
|
|
public
|
|
public
string
|
|
public
|
#
tokenizeHTML( mixed $string,
Lexes an HTML string into tokens. |
protected static
string
|
|
protected static
string
|
#
escapeCommentedCDATA( string $string )
Special CDATA case that is especially convoluted for <script> |
protected static
string
|
#
removeIEConditional( string $string )
Special Internet Explorer conditional comments should be removed. |
protected static
string
|
|
public
string
|
#
normalize( string $html,
Takes a piece of HTML and normalizes it by converting entities, fixing encoding, extracting bits, and other good stuff. |
public
|
public
boolean
|
$tracksLineNumbers | false |
#
Whether or not this lexer implements line-number/column-number tracking. If it does, set to true. |
protected
array
|
$_special_entity2str | array(
'"' => '"',
'&' => '&',
'<' => '<',
'>' => '>',
''' => "'",
''' => "'",
''' => "'"
) |
#
Most common entity to raw value conversion table for special entities. |