Skip to content

Commit f808c1b

Browse files
authored
Merge pull request #50 from j0k3r/fix/non-well-formed-numeric-value
Fix “A non well formed numeric value encountered”
2 parents de1b1d9 + bb65caf commit f808c1b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Readability.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Readability implements LoggerAwareInterface
6161
// constants
6262
const SCORE_CHARS_IN_PARAGRAPH = 100;
6363
const SCORE_WORDS_IN_PARAGRAPH = 20;
64-
const GRANDPARENT_SCORE_DIVISOR = 2.2;
64+
const GRANDPARENT_SCORE_DIVISOR = 2;
6565
const MIN_PARAGRAPH_LENGTH = 20;
6666
const MIN_COMMAS_IN_PARAGRAPH = 6;
6767
const MIN_ARTICLE_LENGTH = 200;
@@ -1115,7 +1115,7 @@ protected function grabArticle(\DOMElement $page = null)
11151115
// Add the score to the parent. The grandparent gets half.
11161116
$parentNode->getAttributeNode('readability')->value += $contentScore;
11171117
if ($grandParentNode) {
1118-
$grandParentNode->getAttributeNode('readability')->value += $contentScore / self::GRANDPARENT_SCORE_DIVISOR;
1118+
$grandParentNode->getAttributeNode('readability')->value += round($contentScore / self::GRANDPARENT_SCORE_DIVISOR);
11191119
}
11201120
}
11211121

tests/ReadabilityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function testWithAside()
193193
$this->assertEmpty($readability->getTitle()->getInnerHtml());
194194
$this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
195195
$this->assertNotContains('<aside>', $readability->getContent()->getInnerHtml());
196-
$this->assertContains('<footer readability="4"/>', $readability->getContent()->getInnerHtml());
196+
$this->assertContains('<footer readability="5"/>', $readability->getContent()->getInnerHtml());
197197
}
198198

199199
public function testWithClasses()

0 commit comments

Comments
 (0)