/**
  * Utility function for parsing a fragment of HTML5.
  */
 protected function parseFragment($string)
 {
     $treeBuilder = new DOMTreeBuilder(true);
     $input = new StringInputStream($string);
     $scanner = new Scanner($input);
     $parser = new Tokenizer($scanner, $treeBuilder);
     $parser->parse();
     $this->errors = $treeBuilder->getErrors();
     return $treeBuilder->fragment();
 }
Beispiel #2
0
 /**
  * Parse an input stream where the stream is a fragment.
  *
  * Lower-level loading function. This requires an input stream instead
  * of a string, file, or resource.
  */
 public function parseFragment(\Masterminds\Html5\Parser\InputStream $input, array $options = array())
 {
     $events = new DOMTreeBuilder(true, array_merge($this->getOptions(), $options));
     $scanner = new Scanner($input);
     $parser = new Tokenizer($scanner, $events);
     $parser->parse();
     $this->errors = $events->getErrors();
     return $events->fragment();
 }
Beispiel #3
0
 /**
  * Parse an input stream where the stream is a fragment.
  *
  * Lower-level loading function. This requires an input stream instead
  * of a string, file, or resource.
  */
 public function parseFragment(\Masterminds\HTML5\Parser\InputStream $input)
 {
     $events = new DOMTreeBuilder(true, $this->options);
     $scanner = new Scanner($input);
     $parser = new Tokenizer($scanner, $events);
     $parser->parse();
     $this->errors = $events->getErrors();
     return $events->fragment();
 }