You are here

protected function Tokenizer::comment in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php \Masterminds\HTML5\Parser\Tokenizer::comment()

Read a comment.

Expects the first tok to be inside of the comment.

1 call to Tokenizer::comment()
Tokenizer::markupDeclaration in vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php
Look for markup.

File

vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php, line 608

Class

Tokenizer
The HTML5 tokenizer.

Namespace

Masterminds\HTML5\Parser

Code

protected function comment() {
  $tok = $this->scanner
    ->current();
  $comment = '';

  // <!-->. Emit an empty comment because 8.2.4.46 says to.
  if ($tok == '>') {

    // Parse error. Emit the comment token.
    $this
      ->parseError("Expected comment data, got '>'");
    $this->events
      ->comment('');
    $this->scanner
      ->next();
    return true;
  }

  // Replace NULL with the replacement char.
  if ($tok == "\0") {
    $tok = UTF8Utils::FFFD;
  }
  while (!$this
    ->isCommentEnd()) {
    $comment .= $tok;
    $tok = $this->scanner
      ->next();
  }
  $this->events
    ->comment($comment);
  $this->scanner
    ->next();
  return true;
}