diff options
Diffstat (limited to 'articleenhancer')
-rw-r--r-- | articleenhancer/globalarticleenhancer.php | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/articleenhancer/globalarticleenhancer.php b/articleenhancer/globalarticleenhancer.php index 1b6713ef7..7411d0adc 100644 --- a/articleenhancer/globalarticleenhancer.php +++ b/articleenhancer/globalarticleenhancer.php @@ -24,7 +24,12 @@ class GlobalArticleEnhancer implements ArticleEnhancer { */ public function enhance(Item $item) { $dom = new \DOMDocument(); - @$dom->loadHTML($item->getBody()); + + // wrap it inside a div if there is none to prevent invalid wrapping + // inside <p> tags + $body = '<div>' . $item->getBody() . '</div>'; + + @$dom->loadHTML($body, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new \DOMXpath($dom); // remove youtube autoplay @@ -45,12 +50,6 @@ class GlobalArticleEnhancer implements ArticleEnhancer { } } - // remove <!DOCTYPE - $dom->removeChild($dom->firstChild); - - // remove <html><body></body></html> - $dom->replaceChild($dom->firstChild->firstChild->firstChild, $dom->firstChild); - // save all changes back to the item $item->setBody(trim($dom->saveHTML())); |