diff options
author | Andres Rey <[email protected]> | 2017-11-07 19:36:13 +0000 |
---|---|---|
committer | Andres Rey <[email protected]> | 2017-11-07 19:36:13 +0000 |
commit | a4202a5cd791212bb649e42c9396bc6a52ff3178 (patch) | |
tree | 509a43341ba8352ac5c49fb4432deca4b6a2532a | |
parent | c247dc2e631ce135a0334a6af9b1956235a3cc2d (diff) |
Update logic to remove nodes when cleaning conditionally
-rw-r--r-- | src/HTMLParser.php | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/HTMLParser.php b/src/HTMLParser.php index bf999f2..a6d5625 100644 --- a/src/HTMLParser.php +++ b/src/HTMLParser.php @@ -1259,11 +1259,10 @@ class HTMLParser $contentLength = mb_strlen($node->getTextContent(true)); $haveToRemove = - // Make an exception for elements with no p's and exactly 1 img. - ($img > $p && $node->hasAncestorTag($node, 'figure')) || + ($img > 1 && $p / $img < 0.5 && !$node->hasAncestorTag($node, 'figure')) || (!$isList && $li > $p) || ($input > floor($p / 3)) || - (!$isList && $contentLength < 25 && ($img === 0 || $img > 2)) || + (!$isList && $contentLength < 25 && ($img === 0 || $img > 2) && !$node->hasAncestorTag($node, 'figure')) || (!$isList && $weight < 25 && $linkDensity > 0.2) || ($weight >= 25 && $linkDensity > 0.5) || (($embedCount === 1 && $contentLength < 75) || $embedCount > 1); |