summaryrefslogtreecommitdiff
path: root/src/Readability.php
diff options
context:
space:
mode:
authorAndres Rey <[email protected]>2018-09-01 23:56:09 +0100
committerAndres Rey <[email protected]>2018-09-01 23:56:09 +0100
commitef57e870f9cfd1bec25028abd2c1e9dcb6a99126 (patch)
tree16be83f7fd0add560106ecb57368f772849fb786 /src/Readability.php
parentd8471fc68e363ac884591cf9ab9e334773f97cae (diff)
Avoid nesting paragraphs
Diffstat (limited to 'src/Readability.php')
-rw-r--r--src/Readability.php8
1 files changed, 8 insertions, 0 deletions
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');
+ }
}
}