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.

Internal

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

Methods

__construct()

public __construct(string $string) : mixed
Parameters
$string : string

fromString()

public static fromString(string $string) : self
Parameters
$string : string
Return values
self

getFirstNode()

public getFirstNode([int|null $type = null ]) : SimpleNode|null
Parameters
$type : int|null = null

using Node::TYPE_*

Return values
SimpleNode|null

getLastNode()

public getLastNode([int|null $type = null ]) : SimpleNode|null
Parameters
$type : int|null = null

using Node::TYPE_*

Return values
SimpleNode|null

getNodes()

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
bool

isType()

protected isType(int $type) : bool
Parameters
$type : int
Return values
bool

next()

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

        
On this page

Search results