You are here

protected function Tokenizer::endTag 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::endTag()

Consume an end tag. 8.2.4.9

3 calls to Tokenizer::endTag()
Tokenizer::rawText in vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php
Read text in RAW mode.
Tokenizer::rcdata in vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php
Read text in RCDATA mode.
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 319

Class

Tokenizer
The HTML5 tokenizer.

Namespace

Masterminds\HTML5\Parser

Code

protected function endTag() {
  if ($this->scanner
    ->current() != '/') {
    return false;
  }
  $tok = $this->scanner
    ->next();

  // a-zA-Z -> tagname
  // > -> parse error
  // EOF -> parse error
  // -> parse error
  if (!ctype_alpha($tok)) {
    $this
      ->parseError("Expected tag name, got '%s'", $tok);
    if ($tok == "\0" || $tok === false) {
      return false;
    }
    return $this
      ->bogusComment('</');
  }
  $name = strtolower($this->scanner
    ->charsUntil("\n\f \t>"));

  // Trash whitespace.
  $this->scanner
    ->whitespace();
  if ($this->scanner
    ->current() != '>') {
    $this
      ->parseError("Expected >, got '%s'", $this->scanner
      ->current());

    // We just trash stuff until we get to the next tag close.
    $this->scanner
      ->charsUntil('>');
  }
  $this->events
    ->endTag($name);
  $this->scanner
    ->next();
  return true;
}