protected function Tokenizer::processingInstruction in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php \Masterminds\HTML5\Parser\Tokenizer::processingInstruction()
Handle a processing instruction.
XML processing instructions are supposed to be ignored in HTML5, treated as "bogus comments". However, since we're not a user agent, we allow them. We consume until ?> and then issue a EventListener::processingInstruction() event.
1 call to Tokenizer::processingInstruction()
- Tokenizer::tagOpen in vendor/
masterminds/ html5/ src/ HTML5/ Parser/ Tokenizer.php - Emit a tagStart event on encountering a tag.
File
- vendor/
masterminds/ html5/ src/ HTML5/ Parser/ Tokenizer.php, line 849
Class
- Tokenizer
- The HTML5 tokenizer.
Namespace
Masterminds\HTML5\ParserCode
protected function processingInstruction() {
if ($this->scanner
->current() != '?') {
return false;
}
$tok = $this->scanner
->next();
$procName = $this->scanner
->getAsciiAlpha();
$white = strlen($this->scanner
->whitespace());
// If not a PI, send to bogusComment.
if (strlen($procName) == 0 || $white == 0 || $this->scanner
->current() == false) {
$this
->parseError("Expected processing instruction name, got {$tok}");
$this
->bogusComment('<?' . $tok . $procName);
return true;
}
$data = '';
// As long as it's not the case that the next two chars are ? and >.
while (!($this->scanner
->current() == '?' && $this->scanner
->peek() == '>')) {
$data .= $this->scanner
->current();
$tok = $this->scanner
->next();
if ($tok === false) {
$this
->parseError("Unexpected EOF in processing instruction.");
$this->events
->processingInstruction($procName, $data);
return true;
}
}
$this->scanner
->next();
// >
$this->scanner
->next();
// Next token.
$this->events
->processingInstruction($procName, $data);
return true;
}