}
try {
- // Cleanup invalid HTML
- $doc = new DOMDocument();
- @$doc->loadHTML($s);
- $s = $doc->saveHTML();
-
$dom = HTML5_Parser::parse($s);
} catch (DOMException $e) {
logger('scrape_feed: parse error: ' . $e);
* @return Parsed HTML as DOMDocument
*/
static public function parse($text, $builder = null) {
+
+ // Cleanup invalid HTML
+ $doc = new DOMDocument();
+ @$doc->loadHTML($text);
+ $text = $doc->saveHTML();
+
$tokenizer = new HTML5_Tokenizer($text, $builder);
$tokenizer->parse();
return $tokenizer->save();