Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DOMTreeBuilder.php

function DOMTreeBuilder::text

Overrides EventHandler::text

File

vendor/masterminds/html5/src/HTML5/Parser/DOMTreeBuilder.php, line 567

Class

DOMTreeBuilder
Create an HTML5 DOM tree from events.

Namespace

Masterminds\HTML5\Parser

Code

public function text($data) {
    // XXX: Hmmm.... should we really be this strict?
    if ($this->insertMode < static::IM_IN_HEAD) {
        // Per '8.2.5.4.3 The "before head" insertion mode' the characters
        // " \t\n\r\f" should be ignored but no mention of a parse error. This is
        // practical as most documents contain these characters. Other text is not
        // expected here so recording a parse error is necessary.
        $dataTmp = trim($data, " \t\n\r\f");
        if (!empty($dataTmp)) {
            // fprintf(STDOUT, "Unexpected insert mode: %d", $this->insertMode);
            $this->parseError('Unexpected text. Ignoring: ' . $dataTmp);
        }
        return;
    }
    // fprintf(STDOUT, "Appending text %s.", $data);
    $node = $this->doc
        ->createTextNode($data);
    $this->current
        ->appendChild($node);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal