RemexHtml
Fast HTML 5 parser
|
This is a debugging helper class which calls the supplied callback function each time there is a TreeHandler event, giving a descriptive message. More...
Public Member Functions | ||||||||||||||||||||||
__construct (TreeHandler $handler, callable $callback, $verbosity=0) | ||||||||||||||||||||||
Constructor. | ||||||||||||||||||||||
startDocument ( $fns, $fn) | ||||||||||||||||||||||
Called when parsing starts.
| ||||||||||||||||||||||
endDocument ( $pos) | ||||||||||||||||||||||
Called when parsing stops.
| ||||||||||||||||||||||
characters ( $preposition, $refNode, $text, $start, $length, $sourceStart, $sourceLength) | ||||||||||||||||||||||
Insert characters.
| ||||||||||||||||||||||
insertElement ( $preposition, $refNode, Element $element, $void, $sourceStart, $sourceLength) | ||||||||||||||||||||||
Insert an element.The element name and attributes are given in the supplied Element object. Handlers for this event typically attach an identifier to the userData property of the Element object, to identify the element when it is used again in subsequent tree mutations.
| ||||||||||||||||||||||
endTag (Element $element, $sourceStart, $sourceLength) | ||||||||||||||||||||||
A hint that an element was closed and was removed from the stack of open elements.It probably won't be mutated again.
| ||||||||||||||||||||||
doctype ( $name, $public, $system, $quirks, $sourceStart, $sourceLength) | ||||||||||||||||||||||
A valid DOCTYPE token was found.
| ||||||||||||||||||||||
comment ( $preposition, $refNode, $text, $sourceStart, $sourceLength) | ||||||||||||||||||||||
Insert a comment.
| ||||||||||||||||||||||
error ( $text, $pos) | ||||||||||||||||||||||
A parse error.
| ||||||||||||||||||||||
mergeAttributes (Element $element, Attributes $attrs, $sourceStart) | ||||||||||||||||||||||
Add attributes to an existing element.This is used to update the attributes of the <html> or <body> elements. The event receiver should add only those attributes which the original element does not already have. It should not overwrite existing attributes.
| ||||||||||||||||||||||
removeNode (Element $element, $sourceStart) | ||||||||||||||||||||||
Remove a node from the tree, and all its children.This is only done when a <frameset> element is found, which triggers removal of the partially-constructed body element.
| ||||||||||||||||||||||
reparentChildren (Element $element, Element $newParent, $sourceStart) | ||||||||||||||||||||||
Take all children of a given parent $element, and insert them as children of $newParent, removing them from their original parent in the process.Insert $newParent as now the only child of $element.
| ||||||||||||||||||||||
This is a debugging helper class which calls the supplied callback function each time there is a TreeHandler event, giving a descriptive message.
It then forwards the event through to the supplied handler.
Wikimedia\RemexHtml\TreeBuilder\TreeMutationTracer::__construct | ( | TreeHandler | $handler, |
callable | $callback, | ||
$verbosity = 0 ) |
Constructor.
TreeHandler | $handler | The next pipeline stage |
callable | $callback | The message output function |
int | $verbosity | Set to non-zero to call dump() on the handler before and after each event. |
Wikimedia\RemexHtml\TreeBuilder\TreeMutationTracer::characters | ( | $preposition, | |
$refNode, | |||
$text, | |||
$start, | |||
$length, | |||
$sourceStart, | |||
$sourceLength ) |
Insert characters.
int | $preposition | The placement of the new node with respect to $ref. May be TreeBuilder::
|
Element | null | $ref | Insert before/below this element, or null if $preposition is ROOT. |
string | $text | The text to insert is a substring of this string, with the start and length of the substring given by $start and $length. We do it this way to avoid unnecessary copying. |
int | $start | The start of the substring |
int | $length | The length of the substring |
int | $sourceStart | The input position. This is not necessarily accurate, particularly when the tokenizer is run without ignoreEntities, or in CDATA sections. |
int | $sourceLength | The length of the input which is consumed. The same caveats apply as for $sourceStart. |
Implements Wikimedia\RemexHtml\TreeBuilder\TreeHandler.
Wikimedia\RemexHtml\TreeBuilder\TreeMutationTracer::comment | ( | $preposition, | |
$refNode, | |||
$text, | |||
$sourceStart, | |||
$sourceLength ) |
Insert a comment.
int | $preposition | The placement of the new node with respect to $ref. May be TreeBuilder::
|
Element | null | $ref | Insert before/below this element, or null if $preposition is ROOT. |
string | $text | The text of the comment |
int | $sourceStart | The input position |
int | $sourceLength | The length of the input which is consumed |
Implements Wikimedia\RemexHtml\TreeBuilder\TreeHandler.
Wikimedia\RemexHtml\TreeBuilder\TreeMutationTracer::doctype | ( | $name, | |
$public, | |||
$system, | |||
$quirks, | |||
$sourceStart, | |||
$sourceLength ) |
A valid DOCTYPE token was found.
string | $name | The doctype name, usually "html" |
string | $public | The PUBLIC identifier |
string | $system | The SYSTEM identifier |
int | $quirks | The quirks mode implied from the doctype. One of:
|
int | $sourceStart | The input position |
int | $sourceLength | The length of the input which is consumed |
Implements Wikimedia\RemexHtml\TreeBuilder\TreeHandler.
Wikimedia\RemexHtml\TreeBuilder\TreeMutationTracer::endDocument | ( | $pos | ) |
Called when parsing stops.
int | $pos | The input string length, i.e. the past-the-end position. |
Implements Wikimedia\RemexHtml\TreeBuilder\TreeHandler.
Wikimedia\RemexHtml\TreeBuilder\TreeMutationTracer::endTag | ( | Element | $element, |
$sourceStart, | |||
$sourceLength ) |
A hint that an element was closed and was removed from the stack of open elements.It probably won't be mutated again.
Element | $element | The element being ended |
int | $sourceStart | The input position |
int | $sourceLength | The length of the input which is consumed |
Implements Wikimedia\RemexHtml\TreeBuilder\TreeHandler.
Wikimedia\RemexHtml\TreeBuilder\TreeMutationTracer::error | ( | $text, | |
$pos ) |
A parse error.
string | $text | An error message explaining in English what the author did wrong, and what the parser intends to do about the situation. |
int | $pos | The input position at which the error occurred |
Implements Wikimedia\RemexHtml\TreeBuilder\TreeHandler.
Wikimedia\RemexHtml\TreeBuilder\TreeMutationTracer::insertElement | ( | $preposition, | |
$refNode, | |||
Element | $element, | ||
$void, | |||
$sourceStart, | |||
$sourceLength ) |
Insert an element.The element name and attributes are given in the supplied Element object. Handlers for this event typically attach an identifier to the userData property of the Element object, to identify the element when it is used again in subsequent tree mutations.
int | $preposition | The placement of the new node with respect to $ref. May be TreeBuilder::
|
Element | null | $ref | Insert before/below this element, or null if $preposition is ROOT. |
Element | $element | An object containing information about the new element. The same object will be used for $parent and $refNode in other calls as appropriate. The handler can set $element->userData to attach a suitable DOM object to identify the mutation target in subsequent calls. |
bool | $void | True if this is a void element which cannot have any children appended to it. This is usually true if the element is closed by the same token that opened it. No endTag() event will be sent for such an element. This is only true if self-closing tags are acknowledged for this tag name, so it is a hint to the serializer that a self-closing tag is acceptable. |
int | $sourceStart | The input position |
int | $sourceLength | The length of the input which is consumed |
Implements Wikimedia\RemexHtml\TreeBuilder\TreeHandler.
Wikimedia\RemexHtml\TreeBuilder\TreeMutationTracer::mergeAttributes | ( | Element | $element, |
Attributes | $attrs, | ||
$sourceStart ) |
Add attributes to an existing element.This is used to update the attributes of the <html> or <body> elements. The event receiver should add only those attributes which the original element does not already have. It should not overwrite existing attributes.
Element | $element | The element to update |
Attributes | $attrs | The new attributes to add |
int | $sourceStart | The input position |
Implements Wikimedia\RemexHtml\TreeBuilder\TreeHandler.
Wikimedia\RemexHtml\TreeBuilder\TreeMutationTracer::removeNode | ( | Element | $element, |
$sourceStart ) |
Remove a node from the tree, and all its children.This is only done when a <frameset> element is found, which triggers removal of the partially-constructed body element.
Element | $element | The element to remove |
int | $sourceStart | The location in the source at which this action was triggered. |
Implements Wikimedia\RemexHtml\TreeBuilder\TreeHandler.
Wikimedia\RemexHtml\TreeBuilder\TreeMutationTracer::reparentChildren | ( | Element | $element, |
Element | $newParent, | ||
$sourceStart ) |
Take all children of a given parent $element, and insert them as children of $newParent, removing them from their original parent in the process.Insert $newParent as now the only child of $element.
Element | $element | The old parent element |
Element | $newParent | The new parent element |
int | $sourceStart | The location in the source at which this action was triggered. |
Implements Wikimedia\RemexHtml\TreeBuilder\TreeHandler.
Wikimedia\RemexHtml\TreeBuilder\TreeMutationTracer::startDocument | ( | $fns, | |
$fn ) |
Called when parsing starts.
string | null | $fragmentNamespace | The fragment namespace, or null to run in document mode. |
string | null | $fragmentName | The fragment tag name, or null to run in document mode. |
Implements Wikimedia\RemexHtml\TreeBuilder\TreeHandler.