Browse Source

Moving the clean up code to a central place.

pull/1242/head
Michael Vogel 7 years ago
parent
commit
04106ff6f5
2 changed files with 6 additions and 5 deletions
  1. +0
    -5
      include/Scrape.php
  2. +6
    -0
      library/HTML5/Parser.php

+ 0
- 5
include/Scrape.php View File

@ -263,11 +263,6 @@ function scrape_feed($url) {
}
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);


+ 6
- 0
library/HTML5/Parser.php View File

@ -17,6 +17,12 @@ class HTML5_Parser
* @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();


Loading…
Cancel
Save