‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Html\SimpleParser Class Reference

Public Member Functions

 __construct (string $string)
 
SimpleNode[] getNodes (int ... $types)
 
 getFirstNode (int $type=null)
 
 getLastNode (int $type=null)
 

Static Public Member Functions

static fromString (string $string)
 

Protected Member Functions

 process (string $string)
 
 next (int $nextType)
 
 finish ()
 
 append (string $string)
 
 isType (int $type)
 
 inAttribute ()
 

Protected Attributes

string null $attribute
 
SimpleNode[] $nodes = array( )
 
int $currentType = SimpleNode::TYPE_TEXT
 
string $currentData = ''
 

Detailed Description

Simple HTML node parser. The main focus is to determine "runaway nodes" like <span attribute="<runaway attribute="other"> and better nod boundaries.

(Most of) the behavior is similar to Mozilla's behavior on handling those nodes. (e.g. ‘div.innerHTML = 'x =<y>= z’;` - but without creating closing node blocks)

This parser does not resolve nested nodes - it just provides a flat node sequence.

Definition at line 31 of file SimpleParser.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Html\SimpleParser::__construct ( string  $string)

Definition at line 54 of file SimpleParser.php.

References TYPO3\CMS\Core\Html\SimpleParser\process().

Member Function Documentation

◆ append()

TYPO3\CMS\Core\Html\SimpleParser::append ( string  $string)
protected

Definition at line 218 of file SimpleParser.php.

Referenced by TYPO3\CMS\Core\Html\SimpleParser\process().

◆ finish()

TYPO3\CMS\Core\Html\SimpleParser::finish ( )
protected

Finishes missing text node instance - anything else (all of those are tag-like "runaway" scenarios e.g. <anything<!-- anything... without being closed correctly - those nodes are ignored on purpose!

Definition at line 202 of file SimpleParser.php.

References TYPO3\CMS\Core\Html\SimpleNode\fromString(), TYPO3\CMS\Core\Html\SimpleParser\isType(), and TYPO3\CMS\Core\Html\SimpleNode\TYPE_TEXT.

Referenced by TYPO3\CMS\Core\Html\SimpleParser\process().

◆ fromString()

static TYPO3\CMS\Core\Html\SimpleParser::fromString ( string  $string)
static

◆ getFirstNode()

TYPO3\CMS\Core\Html\SimpleParser::getFirstNode ( int  $type = null)
Parameters
int | null$type‪using Node::TYPE_*

Definition at line 85 of file SimpleParser.php.

◆ getLastNode()

TYPO3\CMS\Core\Html\SimpleParser::getLastNode ( int  $type = null)
Parameters
int | null$type‪using Node::TYPE_*

Definition at line 98 of file SimpleParser.php.

◆ getNodes()

SimpleNode [] TYPO3\CMS\Core\Html\SimpleParser::getNodes ( int ...  $types)
Parameters
int‪...$types using Node::TYPE_*
Returns
SimpleNode[]

Definition at line 63 of file SimpleParser.php.

References TYPO3\CMS\Core\Html\SimpleParser\$nodes, and TYPO3\CMS\Core\Html\SimpleNode\getType().

◆ inAttribute()

TYPO3\CMS\Core\Html\SimpleParser::inAttribute ( )
protected

Definition at line 228 of file SimpleParser.php.

Referenced by TYPO3\CMS\Core\Html\SimpleParser\process().

◆ isType()

TYPO3\CMS\Core\Html\SimpleParser::isType ( int  $type)
protected

◆ next()

TYPO3\CMS\Core\Html\SimpleParser::next ( int  $nextType)
protected

Triggers creating "next" node instance, resets current state.

Definition at line 184 of file SimpleParser.php.

References TYPO3\CMS\Core\Html\SimpleNode\fromString().

Referenced by TYPO3\CMS\Core\Html\SimpleParser\process().

◆ process()

Member Data Documentation

◆ $attribute

string null TYPO3\CMS\Core\Html\SimpleParser::$attribute
protected

Definition at line 35 of file SimpleParser.php.

◆ $currentData

string TYPO3\CMS\Core\Html\SimpleParser::$currentData = ''
protected

Definition at line 47 of file SimpleParser.php.

◆ $currentType

int TYPO3\CMS\Core\Html\SimpleParser::$currentType = SimpleNode::TYPE_TEXT
protected

Definition at line 43 of file SimpleParser.php.

◆ $nodes

SimpleNode [] TYPO3\CMS\Core\Html\SimpleParser::$nodes = array( )
protected

Definition at line 39 of file SimpleParser.php.

Referenced by TYPO3\CMS\Core\Html\SimpleParser\getNodes().