You are here

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

Read text in RCDATA mode.

1 call to Tokenizer::rcdata()
Tokenizer::characterData in vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php
Parse anything that looks like character data.

File

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

Class

Tokenizer
The HTML5 tokenizer.

Namespace

Masterminds\HTML5\Parser

Code

protected function rcdata() {
  if (is_null($this->untilTag)) {
    return $this
      ->text();
  }
  $sequence = '</' . $this->untilTag;
  $txt = '';
  $tok = $this->scanner
    ->current();
  $caseSensitive = !Elements::isHtml5Element($this->untilTag);
  while ($tok !== false && !($tok == '<' && $this
    ->sequenceMatches($sequence, $caseSensitive))) {
    if ($tok == '&') {
      $txt .= $this
        ->decodeCharacterReference();
      $tok = $this->scanner
        ->current();
    }
    else {
      $txt .= $tok;
      $tok = $this->scanner
        ->next();
    }
  }
  $len = strlen($sequence);
  $this->scanner
    ->consume($len);
  $len += strlen($this->scanner
    ->whitespace());
  if ($this->scanner
    ->current() !== '>') {
    $this
      ->parseError("Unclosed RCDATA end tag");
  }
  $this->scanner
    ->unconsume($len);
  $this->events
    ->text($txt);
  $this
    ->setTextMode(0);
  return $this
    ->endTag();
}