mirror of
https://github.com/j0k3r/php-readability.git
synced 2026-09-27 06:26:17 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a0f3337a6 | ||
|
|
2dce2879bf | ||
|
|
49ce4233fa | ||
|
|
26c881d864 | ||
|
|
db69fe59a2 | ||
|
|
a78f01f656 | ||
|
|
db4508003b | ||
|
|
15b12ea2d6 | ||
|
|
694f0308fe | ||
|
|
bbe9021fe7 | ||
|
|
9dee4a240d | ||
|
|
eef6d6d456 | ||
|
|
30a577c617 | ||
|
|
70b393a2a3 | ||
|
|
9ab6d0d9e8 | ||
|
|
8712db510e | ||
|
|
422c74f29c | ||
|
|
3a7350a8a7 |
@@ -1,20 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return Symfony\CS\Config\Config::create()
|
return PhpCsFixer\Config::create()
|
||||||
->setUsingCache(true)
|
->setUsingCache(true)
|
||||||
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
|
->setRiskyAllowed(true)
|
||||||
// use default SYMFONY_LEVEL and extra fixers:
|
->setRules([
|
||||||
->fixers(array(
|
'@Symfony' => true,
|
||||||
'concat_with_spaces',
|
'@Symfony:risky' => true,
|
||||||
'ordered_use',
|
'array_syntax' => ['syntax' => 'short'],
|
||||||
'phpdoc_order',
|
'combine_consecutive_unsets' => true,
|
||||||
'strict',
|
'heredoc_to_nowdoc' => true,
|
||||||
'strict_param',
|
'no_extra_consecutive_blank_lines' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'],
|
||||||
'long_array_syntax',
|
'no_unreachable_default_argument_value' => true,
|
||||||
))
|
'no_useless_else' => true,
|
||||||
->finder(
|
'no_useless_return' => true,
|
||||||
Symfony\CS\Finder\DefaultFinder::create()
|
'ordered_class_elements' => true,
|
||||||
|
'ordered_imports' => true,
|
||||||
|
'php_unit_strict' => false,
|
||||||
|
'phpdoc_order' => true,
|
||||||
|
// 'psr4' => true,
|
||||||
|
'strict_comparison' => true,
|
||||||
|
'strict_param' => true,
|
||||||
|
'concat_space' => ['spacing' => 'one'],
|
||||||
|
])
|
||||||
|
->setFinder(
|
||||||
|
PhpCsFixer\Finder::create()
|
||||||
|
->exclude(['vendor'])
|
||||||
->in(__DIR__)
|
->in(__DIR__)
|
||||||
->exclude(array('vendor'))
|
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|||||||
+4
-25
@@ -1,35 +1,20 @@
|
|||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 5.5
|
|
||||||
- 5.6
|
- 5.6
|
||||||
- 7.0
|
- 7.0
|
||||||
- 7.1
|
- 7.1
|
||||||
- 7.2
|
- 7.2
|
||||||
|
- 7.3
|
||||||
- nightly
|
- nightly
|
||||||
- hhvm
|
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- php: 5.3.3
|
- php: 7.2
|
||||||
dist: precise
|
|
||||||
sudo: required
|
|
||||||
- php: 5.3
|
|
||||||
dist: precise
|
|
||||||
sudo: required
|
|
||||||
- php: 5.4
|
|
||||||
dist: precise
|
|
||||||
sudo: required
|
|
||||||
- php: 7.0
|
|
||||||
env: CS_FIXER=run
|
env: CS_FIXER=run
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- php: 7.2
|
|
||||||
- php: nightly
|
- php: nightly
|
||||||
- php: hhvm
|
|
||||||
|
|
||||||
# faster builds on new travis setup not using sudo
|
|
||||||
sudo: false
|
|
||||||
|
|
||||||
# cache vendor dirs
|
# cache vendor dirs
|
||||||
cache:
|
cache:
|
||||||
@@ -39,18 +24,12 @@ cache:
|
|||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi;
|
- if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi;
|
||||||
# disable TLS for composer because openssl is disabled for PHP 5.3.3 on travis
|
|
||||||
# see: https://blog.travis-ci.com/upcoming_ubuntu_11_10_migration/
|
|
||||||
- if [[ $TRAVIS_PHP_VERSION = 5.3.3 ]]; then composer config -g -- disable-tls true; fi;
|
|
||||||
- if [[ $TRAVIS_PHP_VERSION = 5.3.3 ]]; then composer config -g -- secure-http false; fi;
|
|
||||||
# no version compatible with PHP > 7.1
|
|
||||||
- if [[ $TRAVIS_PHP_VERSION = 7.2.* ]]; then composer remove friendsofphp/php-cs-fixer; fi;
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- composer self-update
|
- composer self-update
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- composer install --prefer-dist --no-interaction
|
- composer install -o --prefer-dist --no-interaction
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- mkdir -p build/logs
|
- mkdir -p build/logs
|
||||||
@@ -58,4 +37,4 @@ script:
|
|||||||
- if [ "$CS_FIXER" = "run" ]; then php vendor/bin/php-cs-fixer fix --verbose --dry-run ; fi;
|
- if [ "$CS_FIXER" = "run" ]; then php vendor/bin/php-cs-fixer fix --verbose --dry-run ; fi;
|
||||||
|
|
||||||
after_script:
|
after_script:
|
||||||
- php vendor/bin/coveralls -v
|
- php vendor/bin/php-coveralls -v -x build/logs/clover.xml
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
[](https://travis-ci.org/j0k3r/php-readability)
|
[](https://travis-ci.org/j0k3r/php-readability)
|
||||||
[](https://coveralls.io/github/j0k3r/php-readability/?branch=master)
|
[](https://coveralls.io/github/j0k3r/php-readability/?branch=master)
|
||||||
|
[](https://packagist.org/packages/j0k3r/php-readability)
|
||||||
|
[](https://packagist.org/packages/j0k3r/php-readability)
|
||||||
|
|
||||||
This is an extract of the Readability class from this [full-text-rss](https://github.com/Dither/full-text-rss) fork. It can be defined as a better version of the original [php-readability](https://bitbucket.org/fivefilters/php-readability/overview).
|
This is an extract of the Readability class from this [full-text-rss](https://github.com/Dither/full-text-rss) fork. It can be defined as a better version of the original [php-readability](https://bitbucket.org/fivefilters/php-readability/overview).
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -24,16 +24,16 @@
|
|||||||
"role": "Developer (original JS version)"
|
"role": "Developer (original JS version)"
|
||||||
}],
|
}],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.3",
|
"php": ">=5.6.0",
|
||||||
"ext-mbstring": "*",
|
"ext-mbstring": "*",
|
||||||
"psr/log": "^1.0",
|
"psr/log": "^1.0",
|
||||||
"electrolinux/php-html5lib": "^0.1.0"
|
"electrolinux/php-html5lib": "^0.1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"satooshi/php-coveralls": "~0.6",
|
"php-coveralls/php-coveralls": "^2.1",
|
||||||
"friendsofphp/php-cs-fixer": "<2",
|
"friendsofphp/php-cs-fixer": "^2.14",
|
||||||
"monolog/monolog": "^1.13",
|
"monolog/monolog": "^1.24",
|
||||||
"symfony/phpunit-bridge": "^3.2"
|
"symfony/phpunit-bridge": "^4.2.3"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-tidy": "Used to clean up given HTML and to avoid problems with bad HTML structure."
|
"ext-tidy": "Used to clean up given HTML and to avoid problems with bad HTML structure."
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class JSLikeHTMLElement extends \DOMElement
|
|||||||
*/
|
*/
|
||||||
public function __set($name, $value)
|
public function __set($name, $value)
|
||||||
{
|
{
|
||||||
if ($name !== 'innerHTML') {
|
if ('innerHTML' !== $name) {
|
||||||
$trace = debug_backtrace();
|
$trace = debug_backtrace();
|
||||||
trigger_error('Undefined property via __set(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE);
|
trigger_error('Undefined property via __set(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE);
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ class JSLikeHTMLElement extends \DOMElement
|
|||||||
*/
|
*/
|
||||||
public function __get($name)
|
public function __get($name)
|
||||||
{
|
{
|
||||||
if ($name === 'innerHTML') {
|
if ('innerHTML' === $name) {
|
||||||
$inner = '';
|
$inner = '';
|
||||||
|
|
||||||
foreach ($this->childNodes as $child) {
|
foreach ($this->childNodes as $child) {
|
||||||
@@ -121,8 +121,6 @@ class JSLikeHTMLElement extends \DOMElement
|
|||||||
|
|
||||||
$trace = debug_backtrace();
|
$trace = debug_backtrace();
|
||||||
trigger_error('Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE);
|
trigger_error('Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString()
|
public function __toString()
|
||||||
|
|||||||
+681
-681
File diff suppressed because it is too large
Load Diff
+14
-14
@@ -6,22 +6,11 @@ use Monolog\Handler\TestHandler;
|
|||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
use Readability\Readability;
|
use Readability\Readability;
|
||||||
|
|
||||||
class ReadabilityTest extends \PHPUnit_Framework_TestCase
|
class ReadabilityTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
public $logHandler;
|
public $logHandler;
|
||||||
public $logger;
|
public $logger;
|
||||||
|
|
||||||
private function getReadability($html, $url = null, $parser = 'libxml', $useTidy = true)
|
|
||||||
{
|
|
||||||
$readability = new Readability($html, $url, $parser, $useTidy);
|
|
||||||
|
|
||||||
$this->logHandler = new TestHandler();
|
|
||||||
$this->logger = new Logger('test', array($this->logHandler));
|
|
||||||
$readability->setLogger($this->logger);
|
|
||||||
|
|
||||||
return $readability;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires extension tidy
|
* @requires extension tidy
|
||||||
*/
|
*/
|
||||||
@@ -345,7 +334,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
error_reporting(E_ALL | E_STRICT);
|
error_reporting(E_ALL | E_STRICT);
|
||||||
ini_set('display_errors', true);
|
ini_set('display_errors', true);
|
||||||
set_error_handler(array($this, 'error2Exception'), E_ALL | E_STRICT);
|
set_error_handler([$this, 'error2Exception'], E_ALL | E_STRICT);
|
||||||
|
|
||||||
$data = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
$data = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="ru-RU" prefix="og: http://ogp.me/ns#">
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="ru-RU" prefix="og: http://ogp.me/ns#">
|
||||||
@@ -445,7 +434,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testPostFilters()
|
public function testPostFilters()
|
||||||
{
|
{
|
||||||
$readability = $this->getReadability('<div>' . str_repeat('<p>This <b>is</b> the awesome content :)</p>', 10) . '</div>', 'http://0.0.0.0');
|
$readability = $this->getReadability('<div>' . str_repeat('<p>This <strong>is</strong> the awesome content :)</p>', 10) . '</div>', 'http://0.0.0.0');
|
||||||
$readability->addPostFilter('!<strong[^>]*>(.*?)</strong>!is', '');
|
$readability->addPostFilter('!<strong[^>]*>(.*?)</strong>!is', '');
|
||||||
|
|
||||||
$res = $readability->init();
|
$res = $readability->init();
|
||||||
@@ -493,4 +482,15 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertContains('<sup id="fnref1:fnfeed_2"><a href="#fn:fnfeed_2" class="footnote-ref">2</a></sup>', $readability->getContent()->innerHTML);
|
$this->assertContains('<sup id="fnref1:fnfeed_2"><a href="#fn:fnfeed_2" class="footnote-ref">2</a></sup>', $readability->getContent()->innerHTML);
|
||||||
$this->assertContains('<a href="#fnref1:fnfeed_2" rev="footnote"', $readability->getContent()->innerHTML);
|
$this->assertContains('<a href="#fnref1:fnfeed_2" rev="footnote"', $readability->getContent()->innerHTML);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getReadability($html, $url = null, $parser = 'libxml', $useTidy = true)
|
||||||
|
{
|
||||||
|
$readability = new Readability($html, $url, $parser, $useTidy);
|
||||||
|
|
||||||
|
$this->logHandler = new TestHandler();
|
||||||
|
$this->logger = new Logger('test', [$this->logHandler]);
|
||||||
|
$readability->setLogger($this->logger);
|
||||||
|
|
||||||
|
return $readability;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user