From ef57e870f9cfd1bec25028abd2c1e9dcb6a99126 Mon Sep 17 00:00:00 2001 From: Andres Rey Date: Sat, 1 Sep 2018 23:56:09 +0100 Subject: Avoid nesting paragraphs --- src/Readability.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/Readability.php') diff --git a/src/Readability.php b/src/Readability.php index e0c9abf..323cdc2 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -842,6 +842,14 @@ class Readability $p->appendChild($next); $next = $sibling; } + + while ($p->lastChild && preg_match(NodeUtility::$regexps['whitespace'], $p->lastChild->textContent)) { + $p->parentNode->removeChild($p->lastChild); + } + + if ($p->parentNode->tagName === "p") { + NodeUtility::setNodeTag($p->parentNode, 'div'); + } } } -- cgit v1.2.3