function 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.
Return value
bool
1 call to Tokenizer::processingInstruction()
- Tokenizer::consumeData in vendor/
masterminds/ html5/ src/ HTML5/ Parser/ Tokenizer.php - Consume a character and make a move. HTML5 8.2.4.1.
File
-
vendor/
masterminds/ html5/ src/ HTML5/ Parser/ Tokenizer.php, line 940
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 = $this->scanner
->whitespace();
// If not a PI, send to bogusComment.
if (0 == strlen($procName) || 0 == $white || false == $this->scanner
->current()) {
$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 (false === $tok) {
$this->parseError('Unexpected EOF in processing instruction.');
$this->events
->processingInstruction($procName, $data);
return true;
}
}
$this->scanner
->consume(2);
// Consume the closing tag
$this->events
->processingInstruction($procName, $data);
return true;
}