function DOMTreeBuilder::text
Overrides EventHandler::text
File
-
vendor/
masterminds/ html5/ src/ HTML5/ Parser/ DOMTreeBuilder.php, line 567
Class
- DOMTreeBuilder
- Create an HTML5 DOM tree from events.
Namespace
Masterminds\HTML5\ParserCode
public function text($data) {
// XXX: Hmmm.... should we really be this strict?
if ($this->insertMode < static::IM_IN_HEAD) {
// Per '8.2.5.4.3 The "before head" insertion mode' the characters
// " \t\n\r\f" should be ignored but no mention of a parse error. This is
// practical as most documents contain these characters. Other text is not
// expected here so recording a parse error is necessary.
$dataTmp = trim($data, " \t\n\r\f");
if (!empty($dataTmp)) {
// fprintf(STDOUT, "Unexpected insert mode: %d", $this->insertMode);
$this->parseError('Unexpected text. Ignoring: ' . $dataTmp);
}
return;
}
// fprintf(STDOUT, "Appending text %s.", $data);
$node = $this->doc
->createTextNode($data);
$this->current
->appendChild($node);
}