RemexHtml
Fast HTML 5 parser
|
TreeBuilder is the receiver of events from the InsertionMode subclasses, and is responsible for forwarding events on to the TreeHandler, which is responsible for constructing a DOM. More...
Public Member Functions | |
__construct (TreeHandler $handler, $options=[]) | |
startDocument (Tokenizer $tokenizer, $namespace, $name) | |
Notify TreeBuilder and later pipeline stages of the start of a document. | |
Element null | adjustedCurrentNode () |
Get the adjusted current node. | |
insertCharacters ( $text, $start, $length, $sourceStart, $sourceLength) | |
Insert characters at the appropriate place for inserting a node. | |
Element | insertElement ( $name, Attributes $attrs, $void, $sourceStart, $sourceLength) |
Insert an element in the HTML namespace, at the appropriate place for inserting a node. | |
Element | insertForeign ( $ns, $name, Attributes $attrs, $void, $sourceStart, $sourceLength) |
Insert an element in any namespace, at the appropriate place for inserting a node. | |
Element | pop ( $sourceStart, $sourceLength) |
Pop the current node from the stack of open elements, and notify the handler that we are done with that node. | |
doctype ( $name, $public, $system, $quirks, $sourceStart, $sourceLength) | |
Insert a doctype node. | |
comment ( $place, $text, $sourceStart, $sourceLength) | |
Insert a comment node. | |
error ( $text, $pos) | |
Notify the handler of an error (if ignoreErrors is not set). | |
mergeAttributes (Element $elt, Attributes $attrs, $sourceStart, $sourceLength) | |
Add attributes to an existing element. | |
closePInButtonScope ( $pos) | |
If the stack of open elements has a p element in button scope, then close a p element. | |
checkUnclosed ( $allowed, $pos) | |
Check the stack to see if there is any element which is not on the list of allowed elements. | |
adoptionAgency ( $subject, $sourceStart, $sourceLength) | |
Run the "adoption agency algorithm" (AAA) for the given subject tag name. | |
anyOtherEndTag ( $name, $sourceStart, $sourceLength) | |
Perform the steps required when "any other end tag" is encountered in the "in body" insertion mode. | |
generateImpliedEndTags ( $name, $pos) | |
Generate implied end tags, optionally with an element to exclude. | |
generateImpliedEndTagsThoroughly ( $pos) | |
Generate all implied end tags thoroughly. | |
generateImpliedEndTagsAndPop ( $name, $sourceStart, $sourceLength) | |
Generate implied end tags, with an element to exclude, and if the current element is not now the named excluded element, raise an error. | |
popAllUpToElement (Element $elt, $sourceStart, $sourceLength) | |
Pop elements from the stack until the specified element is popped. | |
popAllUpToName ( $name, $sourceStart, $sourceLength) | |
Pop elements from the stack until an element in the HTML namespace with the specified name is popped. | |
popAllUpToNames ( $names, $sourceStart, $sourceLength) | |
Pop elements from the stack until an element with one of the specified names is popped. | |
clearStackBack ( $names, $pos) | |
The "clear stack back to" algorithm used by several template insertion modes. | |
stopParsing ( $pos) | |
Take the steps required when the spec says to "stop parsing". | |
Public Member Functions inherited from Wikimedia\RemexHtml\PropGuard | |
__set ( $name, $value) | |
Public Attributes | |
const | NO_QUIRKS = 0 |
const | LIMITED_QUIRKS = 1 |
const | QUIRKS = 2 |
const | BEFORE = 0 |
const | UNDER = 1 |
const | ROOT = 2 |
$isIframeSrcdoc | |
$scriptingFlag | |
$ignoreErrors | |
$ignoreNulls | |
TreeHandler | $handler |
SimpleStack | $stack |
ActiveFormattingElements | $afe |
Tokenizer | $tokenizer |
$isFragment = false | |
$fragmentContext | |
Element null | $headElement |
Element null | $formElement |
$framesetOK = true | |
$quirks = self::NO_QUIRKS | |
$fosterParenting = false | |
$pendingTableCharacters = array( ) | |
Additional Inherited Members | |
Static Public Attributes inherited from Wikimedia\RemexHtml\PropGuard | |
static | $armed = true |
TreeBuilder is the receiver of events from the InsertionMode subclasses, and is responsible for forwarding events on to the TreeHandler, which is responsible for constructing a DOM.
TreeBuilder contains most of the state referred to by the "tree construction" part of the HTML spec which is not handled elsewhere, such as the stack of open elements and the list of active formatting elements.
Miscellaneous helpers for InsertionMode subclasses are also in this class.
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::__construct | ( | TreeHandler | $handler, |
$options = [] ) |
TreeHandler | $handler | The handler which receives tree mutation events |
array | $options | Associative array of options. The options are:
|
Element null Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::adjustedCurrentNode | ( | ) |
Get the adjusted current node.
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::adoptionAgency | ( | $subject, | |
$sourceStart, | |||
$sourceLength ) |
Run the "adoption agency algorithm" (AAA) for the given subject tag name.
string | $subject | The subject tag name. |
int | $sourceStart | |
int | $sourceLength |
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::anyOtherEndTag | ( | $name, | |
$sourceStart, | |||
$sourceLength ) |
Perform the steps required when "any other end tag" is encountered in the "in body" insertion mode.
string | $name | |
int | $sourceStart | |
int | $sourceLength |
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::checkUnclosed | ( | $allowed, | |
$pos ) |
Check the stack to see if there is any element which is not on the list of allowed elements.
Raise an error if any are found.
array | $allowed | An array with the HTML element names in the key |
int | $pos |
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::clearStackBack | ( | $names, | |
$pos ) |
The "clear stack back to" algorithm used by several template insertion modes.
Similar to popAllUpToName(), except that the named element is not popped, and a set of names is used instead of a single name.
array | $names | |
int | $pos |
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::closePInButtonScope | ( | $pos | ) |
If the stack of open elements has a p element in button scope, then close a p element.
The above phrase appears many times in the spec.
int | $pos | The source position |
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::comment | ( | $place, | |
$text, | |||
$sourceStart, | |||
$sourceLength ) |
Insert a comment node.
array | null | $place | The place where the node is to be inserted. May be either a preposition/refNode pair or null. If it is null, the node will be inserted at the "appropriate place". |
string | $text | The comment contents |
int | $sourceStart | |
int | $sourceLength |
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::doctype | ( | $name, | |
$public, | |||
$system, | |||
$quirks, | |||
$sourceStart, | |||
$sourceLength ) |
Insert a doctype node.
string | $name | The doctype name |
string | $public | The public ID |
string | $system | The system ID |
int | $quirks | The quirks mode. May be either self::NO_QUIRKS, self::LIMITED_QUIRKS or self::QUIRKS to indicate no-quirks mode, limited-quirks mode or quirks mode respectively. |
int | $sourceStart | |
int | $sourceLength |
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::error | ( | $text, | |
$pos ) |
Notify the handler of an error (if ignoreErrors is not set).
string | $text | The error message |
int | $pos | The input position |
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::generateImpliedEndTags | ( | $name, | |
$pos ) |
Generate implied end tags, optionally with an element to exclude.
string | false | $name | The name to exclude |
int | $pos | The source position |
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::generateImpliedEndTagsAndPop | ( | $name, | |
$sourceStart, | |||
$sourceLength ) |
Generate implied end tags, with an element to exclude, and if the current element is not now the named excluded element, raise an error.
Then, pop all elements until an element with the name is popped from the list.
string | $name | The name to exclude |
int | $sourceStart | |
int | $sourceLength |
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::generateImpliedEndTagsThoroughly | ( | $pos | ) |
Generate all implied end tags thoroughly.
This was introduced in HTML 5.1 in order to expand the set of elements which can be implicitly closed by a </template>.
int | $pos |
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::insertCharacters | ( | $text, | |
$start, | |||
$length, | |||
$sourceStart, | |||
$sourceLength ) |
Insert characters at the appropriate place for inserting a node.
string | $text | The string which contains the emitted characters |
int | $start | The start of the range within $text to use |
int | $length | The length of the range within $text to use |
int | $sourceStart | The input position |
int | $sourceLength | The input length |
Element Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::insertElement | ( | $name, | |
Attributes | $attrs, | ||
$void, | |||
$sourceStart, | |||
$sourceLength ) |
Insert an element in the HTML namespace, at the appropriate place for inserting a node.
string | $name | The element name |
Attributes | $attrs | The element attributes |
bool | $void | The void (self-closing) element hint |
int | $sourceStart | The input position |
int | $sourceLength | The input length |
Element Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::insertForeign | ( | $ns, | |
$name, | |||
Attributes | $attrs, | ||
$void, | |||
$sourceStart, | |||
$sourceLength ) |
Insert an element in any namespace, at the appropriate place for inserting a node.
string | $ns | The namespace |
string | $name | The element name |
Attributes | $attrs | The element attributes |
bool | $void | The void (self-closing) element hint |
int | $sourceStart | The input position |
int | $sourceLength | The input length |
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::mergeAttributes | ( | Element | $elt, |
Attributes | $attrs, | ||
$sourceStart, | |||
$sourceLength ) |
Add attributes to an existing element.
Element | $elt | |
Attributes | $attrs | |
int | $sourceStart | |
int | $sourceLength |
Element Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::pop | ( | $sourceStart, | |
$sourceLength ) |
Pop the current node from the stack of open elements, and notify the handler that we are done with that node.
int | $sourceStart | |
int | $sourceLength |
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::popAllUpToElement | ( | Element | $elt, |
$sourceStart, | |||
$sourceLength ) |
Pop elements from the stack until the specified element is popped.
Element | $elt | |
int | $sourceStart | |
int | $sourceLength |
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::popAllUpToName | ( | $name, | |
$sourceStart, | |||
$sourceLength ) |
Pop elements from the stack until an element in the HTML namespace with the specified name is popped.
string | $name | |
int | $sourceStart | |
int | $sourceLength |
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::popAllUpToNames | ( | $names, | |
$sourceStart, | |||
$sourceLength ) |
Pop elements from the stack until an element with one of the specified names is popped.
array | $names | An array with the allowed names in the keys |
int | $sourceStart | |
int | $sourceLength |
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::startDocument | ( | Tokenizer | $tokenizer, |
$namespace, | |||
$name ) |
Notify TreeBuilder and later pipeline stages of the start of a document.
This is called by the Dispatcher when a startDocument event is received.
Tokenizer | $tokenizer | |
string | $namespace | |
string | $name |
Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::stopParsing | ( | $pos | ) |
Take the steps required when the spec says to "stop parsing".
This occurs when an end-of-file token is received, and is equivalent to the endDocument() methods elsewhere.
int | $pos |
ActiveFormattingElements Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::$afe |
Element null Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::$formElement |
TreeHandler Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::$handler |
Element null Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::$headElement |
SimpleStack Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::$stack |
Tokenizer Wikimedia\RemexHtml\TreeBuilder\TreeBuilder::$tokenizer |