diff options
author | FiveFilters.org <[email protected]> | 2021-08-25 10:42:41 +0200 |
---|---|---|
committer | FiveFilters.org <[email protected]> | 2021-08-25 10:42:41 +0200 |
commit | 84a56221c3cf31977903de971a028f9b3135e13e (patch) | |
tree | b005d5991bb35c5e8eb6ec8c66b4b55014b32645 | |
parent | 341476455a51710d38bbad85fec584c466cf7143 (diff) |
Code readability fixes
https://github.com/mozilla/readability/commit/fc78270a308e815429113517a61428e4e56076a8
-rw-r--r-- | src/Nodes/NodeTrait.php | 4 | ||||
-rw-r--r-- | src/Readability.php | 12 | ||||
-rw-r--r-- | test/test-pages/nytimes-1/expected-images.json | 2 | ||||
-rw-r--r-- | test/test-pages/nytimes-1/expected-metadata.json | 4 | ||||
-rw-r--r-- | test/test-pages/nytimes-2/expected-images.json | 4 | ||||
-rw-r--r-- | test/test-pages/nytimes-2/expected-metadata.json | 8 | ||||
-rw-r--r-- | test/test-pages/nytimes-3/expected-images.json | 2 | ||||
-rw-r--r-- | test/test-pages/nytimes-3/expected-metadata.json | 2 |
8 files changed, 16 insertions, 22 deletions
diff --git a/src/Nodes/NodeTrait.php b/src/Nodes/NodeTrait.php index 371a3a5..f304552 100644 --- a/src/Nodes/NodeTrait.php +++ b/src/Nodes/NodeTrait.php @@ -38,7 +38,6 @@ trait NodeTrait * @var array */ private $divToPElements = [ - 'a', 'blockquote', 'dl', 'div', @@ -47,8 +46,7 @@ trait NodeTrait 'p', 'pre', 'table', - 'ul', - 'select', + 'ul' ]; /** diff --git a/src/Readability.php b/src/Readability.php index 5a7363d..eacb5cc 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -456,19 +456,15 @@ class Readability /* @var DOMNode $meta */ $elementName = $meta->getAttribute('name'); $elementProperty = $meta->getAttribute('property'); - $content = $meta->getAttribute('content'); + $content = $meta->getAttribute('content'); $matches = null; $name = null; if ($elementProperty) { if (preg_match($propertyPattern, $elementProperty, $matches)) { - for ($i = count($matches) - 1; $i >= 0; $i--) { - // Convert to lowercase, and remove any whitespace - // so we can match below. - $name = preg_replace('/\s/', '', mb_strtolower($matches[$i])); - // multiple authors - $values[$name] = trim($content); - } + $name = preg_replace('/\s/', '', mb_strtolower($matches[0])); + // multiple authors + $values[$name] = trim($content); } } diff --git a/test/test-pages/nytimes-1/expected-images.json b/test/test-pages/nytimes-1/expected-images.json index c89c43c..077eb60 100644 --- a/test/test-pages/nytimes-1/expected-images.json +++ b/test/test-pages/nytimes-1/expected-images.json @@ -1,4 +1,4 @@ [ - "https:\/\/static01.nyt.com\/images\/2017\/01\/14\/world\/13SUDAN-1\/13SUDAN-1-videoSixteenByNineJumbo1600.jpg", + "https:\/\/static01.nyt.com\/images\/2017\/01\/14\/world\/13SUDAN-1\/13SUDAN-1-facebookJumbo.jpg", "https:\/\/static01.nyt.com\/images\/2017\/01\/14\/world\/13SUDAN-1\/13SUDAN-1-master768.jpg" ]
\ No newline at end of file diff --git a/test/test-pages/nytimes-1/expected-metadata.json b/test/test-pages/nytimes-1/expected-metadata.json index 36da838..724e18a 100644 --- a/test/test-pages/nytimes-1/expected-metadata.json +++ b/test/test-pages/nytimes-1/expected-metadata.json @@ -2,7 +2,7 @@ "Author": "Jeffrey Gettleman", "Direction": null, "Excerpt": "For the first time since the 1990s, the country will be able to trade extensively with the United States.", - "Image": "https:\/\/static01.nyt.com\/images\/2017\/01\/14\/world\/13SUDAN-1\/13SUDAN-1-videoSixteenByNineJumbo1600.jpg", + "Image": "https:\/\/static01.nyt.com\/images\/2017\/01\/14\/world\/13SUDAN-1\/13SUDAN-1-facebookJumbo.jpg", "Title": "United States to Lift Sudan Sanctions", "SiteName": null -} +}
\ No newline at end of file diff --git a/test/test-pages/nytimes-2/expected-images.json b/test/test-pages/nytimes-2/expected-images.json index e4b49d0..1afbadf 100644 --- a/test/test-pages/nytimes-2/expected-images.json +++ b/test/test-pages/nytimes-2/expected-images.json @@ -1,4 +1,4 @@ [ - "https:\/\/static01.nyt.com\/images\/2016\/07\/30\/business\/db-dealprof\/db-dealprof-videoSixteenByNineJumbo1600.jpg", - "https:\/\/static01.nyt.com\/images\/2016\/07\/30\/business\/db-dealprof\/db-dealprof-master315.jpg" + "https:\/\/static01.nyt.com\/images\/2016\/07\/30\/business\/db-dealprof\/db-dealprof-facebookJumbo.jpg", + "https:\/\/static01.nyt.com\/images\/2016\/07\/30\/business\/db-dealprof\/db-dealprof-master315.jpg" ]
\ No newline at end of file diff --git a/test/test-pages/nytimes-2/expected-metadata.json b/test/test-pages/nytimes-2/expected-metadata.json index 7fbcf29..21af4ee 100644 --- a/test/test-pages/nytimes-2/expected-metadata.json +++ b/test/test-pages/nytimes-2/expected-metadata.json @@ -1,8 +1,8 @@ { "Author": "Steven Davidoff Solomon", "Direction": null, - "Excerpt": "The internet giant’s decision to sell its business is plagued with challenges that reveal how unusual deal structures can affect shareholders.", - "Image": "https:\/\/static01.nyt.com\/images\/2016\/07\/30\/business\/db-dealprof\/db-dealprof-videoSixteenByNineJumbo1600.jpg", - "Title": "Yahoo’s Sale to Verizon Leaves Shareholders With Little Say", + "Excerpt": "The internet giant\u2019s decision to sell its business is plagued with challenges that reveal how unusual deal structures can affect shareholders.", + "Image": "https:\/\/static01.nyt.com\/images\/2016\/07\/30\/business\/db-dealprof\/db-dealprof-facebookJumbo.jpg", + "Title": "Yahoo\u2019s Sale to Verizon Leaves Shareholders With Little Say", "SiteName": null -} +}
\ No newline at end of file diff --git a/test/test-pages/nytimes-3/expected-images.json b/test/test-pages/nytimes-3/expected-images.json index 3868276..93da552 100644 --- a/test/test-pages/nytimes-3/expected-images.json +++ b/test/test-pages/nytimes-3/expected-images.json @@ -1,5 +1,5 @@ [ - "https:\/\/static01.nyt.com\/images\/2019\/02\/21\/nyregion\/21winterutilities1\/00winterutilities1-videoSixteenByNineJumbo1600.jpg", + "https:\/\/static01.nyt.com\/images\/2019\/02\/21\/nyregion\/21winterutilities1\/00winterutilities1-facebookJumbo.jpg", "https:\/\/static01.nyt.com\/images\/2019\/02\/21\/nyregion\/21winterutilities1\/merlin_150498339_cf9085e5-9756-4169-a5a5-5b516316a3fa-articleLarge.jpg?quality=75&auto=webp&disable=upscale", "https:\/\/static01.nyt.com\/images\/2018\/02\/20\/multimedia\/author-corey-kilgannon\/author-corey-kilgannon-thumbLarge.jpg", "https:\/\/static01.nyt.com\/images\/2019\/02\/21\/nyregion\/21winterutilitiesOAK15\/merlin_56025490_f9412a36-eeb9-4a10-a41e-f324eb7a3248-articleLarge.jpg?quality=75&auto=webp&disable=upscale", diff --git a/test/test-pages/nytimes-3/expected-metadata.json b/test/test-pages/nytimes-3/expected-metadata.json index 6b5f0b3..3d9b539 100644 --- a/test/test-pages/nytimes-3/expected-metadata.json +++ b/test/test-pages/nytimes-3/expected-metadata.json @@ -2,7 +2,7 @@ "Author": "By Corey Kilgannon", "Direction": null, "Excerpt": "New York\u2019s aging below-street infrastructure is tough to maintain, and the corrosive rock salt and \u201cfreeze-thaw\u201d cycles of winter make it even worse.", - "Image": "https:\/\/static01.nyt.com\/images\/2019\/02\/21\/nyregion\/21winterutilities1\/00winterutilities1-videoSixteenByNineJumbo1600.jpg", + "Image": "https:\/\/static01.nyt.com\/images\/2019\/02\/21\/nyregion\/21winterutilities1\/00winterutilities1-facebookJumbo.jpg", "Title": "Manhole Fires and Burst Pipes: How Winter Wreaks Havoc on What\u2019s Underneath N.Y.C.", "SiteName": null }
\ No newline at end of file |