Exemple #1
0
 /**
  * Parses an HTML fragment.
  * @param $text HTML text to parse
  * @param $context String name of context element to pretend parsing is in.
  * @param $builder Custom builder implementation
  * @return Parsed HTML as DOMDocument
  */
 public static function parseFragment($text, $context = null, $builder = null, $allowedTags = null, $bbcode = array(), $user_name = "")
 {
     $tokenizer = new HTML5_Tokenizer($text, $builder);
     $tokenizer->allowed_tags = $allowedTags;
     $tokenizer->tree->bbcode = $tokenizer->bbcode = $bbcode;
     $tokenizer->userName = $user_name;
     $bucket = "parserModify";
     include "lib/pluginloader.php";
     $tokenizer->parseFragment($context);
     return $tokenizer->save();
 }
 public function invoke($test)
 {
     // this is totally the wrong interface to use, but
     // for now we need testing
     $tokenizer = new HTML5_Tokenizer($test['data']);
     $GLOBALS['TIME'] -= get_microtime();
     if (isset($test['document-fragment'])) {
         $tokenizer->parseFragment($test['document-fragment']);
     } else {
         $tokenizer->parse();
     }
     $GLOBALS['TIME'] += get_microtime();
     $this->assertIdentical($test['document'], HTML5_TestData::strDom($tokenizer->save()), $test);
 }
 /**
  * Parses an HTML fragment.
  * @param $text HTML text to parse
  * @param $context String name of context element to pretend parsing is in.
  * @param $builder Custom builder implementation
  * @return Parsed HTML as DOMDocument
  */
 public static function parseFragment($text, $context = null, $builder = null)
 {
     $tokenizer = new HTML5_Tokenizer($text, $builder);
     $tokenizer->parseFragment($context);
     return $tokenizer->save();
 }