RemexHtml
Fast HTML 5 parser
Loading...
Searching...
No Matches
Wikimedia\RemexHtml\TreeBuilder\SimpleStack Class Reference

An implementation of the "stack of open elements" which, unlike CachingStack, iterates through the stack in order to answer queries about which elements are in scope. More...

+ Inheritance diagram for Wikimedia\RemexHtml\TreeBuilder\SimpleStack:

Public Member Functions

 push (Element $elt)
 Push an element.
 
 pop ()
 Pop an element from the stack.
 
 replace (Element $oldElt, Element $elt)
 Replace an element which is on the stack with another element of the same type (i.e.
 
 remove (Element $elt)
 Remove an element, potentially from the middle of the stack.
 
 isInScope ( $name)
 Is there an element in (default) scope which is in the HTML namespace and has the given tag name?
 
 isElementInScope (Element $elt)
 Is the given element in (default) scope?
 
 isOneOfSetInScope ( $names)
 Is there any element in the (default) scope which is in the HTML namespace and has one of the given tag names?
 
 isInListScope ( $name)
 Is there an element in list scope which is an HTML element with the given name?
 
 isInButtonScope ( $name)
 Is there an element in button scope which is an HTML element with the given name?
 
 isInTableScope ( $name)
 Is there an element in table scope which is an HTML element with the given name?
 
 isInSelectScope ( $name)
 Is there an element in select scope which is an HTML element with the given name?
 
 item ( $idx)
 Get an element from the stack, where 0 is the first element inserted, and $this->length() - 1 is the most recently inserted element.
 
 length ()
 Get the number of elements in the stack.
 
 hasTemplate ()
 Is there a template element in the stack of open elements?
 
- Public Member Functions inherited from Wikimedia\RemexHtml\TreeBuilder\Stack
string dump ()
 Get a string representation of the stack for debugging purposes.
 

Additional Inherited Members

- Public Attributes inherited from Wikimedia\RemexHtml\TreeBuilder\Stack
 $current
 

Detailed Description

An implementation of the "stack of open elements" which, unlike CachingStack, iterates through the stack in order to answer queries about which elements are in scope.

This is presumably faster for best case input.

Member Function Documentation

◆ hasTemplate()

Wikimedia\RemexHtml\TreeBuilder\SimpleStack::hasTemplate ( )

Is there a template element in the stack of open elements?

Returns
bool

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ isElementInScope()

Wikimedia\RemexHtml\TreeBuilder\SimpleStack::isElementInScope ( Element $elt)

Is the given element in (default) scope?

Parameters
Element$elt
Returns
bool

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ isInButtonScope()

Wikimedia\RemexHtml\TreeBuilder\SimpleStack::isInButtonScope ( $name)

Is there an element in button scope which is an HTML element with the given name?

Parameters
string$name
Returns
bool

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ isInListScope()

Wikimedia\RemexHtml\TreeBuilder\SimpleStack::isInListScope ( $name)

Is there an element in list scope which is an HTML element with the given name?

Parameters
string$name
Returns
bool

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ isInScope()

Wikimedia\RemexHtml\TreeBuilder\SimpleStack::isInScope ( $name)

Is there an element in (default) scope which is in the HTML namespace and has the given tag name?

Parameters
string$name
Returns
bool

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ isInSelectScope()

Wikimedia\RemexHtml\TreeBuilder\SimpleStack::isInSelectScope ( $name)

Is there an element in select scope which is an HTML element with the given name?

Parameters
string$name
Returns
bool

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ isInTableScope()

Wikimedia\RemexHtml\TreeBuilder\SimpleStack::isInTableScope ( $name)

Is there an element in table scope which is an HTML element with the given name?

Parameters
string$name
Returns
bool

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ isOneOfSetInScope()

Wikimedia\RemexHtml\TreeBuilder\SimpleStack::isOneOfSetInScope ( $names)

Is there any element in the (default) scope which is in the HTML namespace and has one of the given tag names?

Parameters
array<string,mixed>$names An array with the tag names in the keys, the value arbitrary
Returns
bool

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ item()

Wikimedia\RemexHtml\TreeBuilder\SimpleStack::item ( $idx)

Get an element from the stack, where 0 is the first element inserted, and $this->length() - 1 is the most recently inserted element.

This will raise a PHP notice if the index is out of range.

Parameters
int$idx
Returns
Element|null

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ length()

Wikimedia\RemexHtml\TreeBuilder\SimpleStack::length ( )

Get the number of elements in the stack.

Returns
int

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ pop()

Wikimedia\RemexHtml\TreeBuilder\SimpleStack::pop ( )

Pop an element from the stack.

Returns
Element|null

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ push()

Wikimedia\RemexHtml\TreeBuilder\SimpleStack::push ( Element $elt)

Push an element.

Parameters
Element$elt

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ remove()

Wikimedia\RemexHtml\TreeBuilder\SimpleStack::remove ( Element $elt)

Remove an element, potentially from the middle of the stack.

Parameters
Element$elt

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.

◆ replace()

Wikimedia\RemexHtml\TreeBuilder\SimpleStack::replace ( Element $old,
Element $new )

Replace an element which is on the stack with another element of the same type (i.e.

with the same tag name).

Parameters
Element$oldThe element to be removed
Element$newThe element to be inserted

Reimplemented from Wikimedia\RemexHtml\TreeBuilder\Stack.


The documentation for this class was generated from the following file: