SimpleParser
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.
Table of Contents
Properties
- $attribute : string|null
- $currentData : string
- $currentType : int
- $nodes : array<string|int, SimpleNode>
Methods
- __construct() : mixed
- fromString() : self
- getFirstNode() : SimpleNode|null
- getLastNode() : SimpleNode|null
- getNodes() : array<string|int, SimpleNode>
- append() : void
- finish() : void
- 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!
- inAttribute() : bool
- isType() : bool
- next() : void
- Triggers creating "next" node instance, resets current state.
- process() : void
- Processes token sequence and creates corresponding `Node` instances.
Properties
$attribute
protected
string|null
$attribute
$currentData
protected
string
$currentData
= ''
$currentType
protected
int
$currentType
= \TYPO3\CMS\Core\Html\SimpleNode::TYPE_TEXT
$nodes
protected
array<string|int, SimpleNode>
$nodes
= []
Methods
__construct()
public
__construct(string $string) : mixed
Parameters
- $string : string
fromString()
public
static fromString(string $string) : self
Parameters
- $string : string
Return values
selfgetFirstNode()
public
getFirstNode([int|null $type = null ]) : SimpleNode|null
Parameters
- $type : int|null = null
-
using
Node::TYPE_*
Return values
SimpleNode|nullgetLastNode()
public
getLastNode([int|null $type = null ]) : SimpleNode|null
Parameters
- $type : int|null = null
-
using
Node::TYPE_*
Return values
SimpleNode|nullgetNodes()
public
getNodes(int ...$types) : array<string|int, SimpleNode>
Parameters
- $types : int
-
using
Node::TYPE_*
Return values
array<string|int, SimpleNode>append()
protected
append(string $string) : void
Parameters
- $string : string
finish()
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!
protected
finish() : void
inAttribute()
protected
inAttribute() : bool
Return values
boolisType()
protected
isType(int $type) : bool
Parameters
- $type : int
Return values
boolnext()
Triggers creating "next" node instance, resets current state.
protected
next(int $nextType) : void
Parameters
- $nextType : int
process()
Processes token sequence and creates corresponding `Node` instances.
protected
process(string $string) : void
Parameters
- $string : string