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

Breadcrumb

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

function HTML5::parse

Parse an input string.

Parameters

string $input:

array $options:

Return value

\DOMDocument

2 calls to HTML5::parse()
HTML5::load in vendor/masterminds/html5/src/HTML5.php
Load and parse an HTML file.
HTML5::loadHTML in vendor/masterminds/html5/src/HTML5.php
Parse a HTML Document from a string.

File

vendor/masterminds/html5/src/HTML5.php, line 153

Class

HTML5
This class offers convenience methods for parsing and serializing HTML5. It is roughly designed to mirror the \DOMDocument native class.

Namespace

Masterminds

Code

public function parse($input, array $options = array()) {
    $this->errors = array();
    $options = array_merge($this->defaultOptions, $options);
    $events = new DOMTreeBuilder(false, $options);
    $scanner = new Scanner($input, !empty($options['encoding']) ? $options['encoding'] : 'UTF-8');
    $parser = new Tokenizer($scanner, $events, !empty($options['xmlNamespaces']) ? Tokenizer::CONFORMANT_XML : Tokenizer::CONFORMANT_HTML);
    $parser->parse();
    $this->errors = $events->getErrors();
    return $events->document();
}

API Navigation

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