mirror of
https://github.com/j0k3r/php-readability.git
synced 2026-09-26 22:16:12 +00:00
Add missing HTML5 class
This commit is contained in:
+2
-1
@@ -26,7 +26,8 @@
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"ext-mbstring": "*",
|
||||
"psr/log": "^1.0"
|
||||
"psr/log": "^1.0",
|
||||
"electrolinux/php-html5lib": "^0.1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"satooshi/php-coveralls": "~0.6",
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@ namespace Readability;
|
||||
use Psr\Log\LoggerAwareInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\NullLogger;
|
||||
use HTML5Lib\Parser;
|
||||
|
||||
/**
|
||||
* Arc90's Readability ported to PHP for FiveFilters.org
|
||||
@@ -284,7 +285,7 @@ class Readability implements LoggerAwareInterface
|
||||
|
||||
$this->html = mb_convert_encoding($this->html, 'HTML-ENTITIES', 'UTF-8');
|
||||
|
||||
if (!($this->parser === 'html5lib' && ($this->dom = \HTML5_Parser::parse($this->html)))) {
|
||||
if (!($this->parser === 'html5lib' && ($this->dom = Parser::parse($this->html)))) {
|
||||
libxml_use_internal_errors(true);
|
||||
|
||||
$this->dom = new \DOMDocument();
|
||||
|
||||
@@ -33,6 +33,15 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertInstanceOf('DomDocument', $readability->dom);
|
||||
}
|
||||
|
||||
public function testConstructHtml5Parser()
|
||||
{
|
||||
$readability = $this->getReadability('<html/>', 'http://0.0.0.0', 'html5lib');
|
||||
|
||||
$this->assertEquals('http://0.0.0.0', $readability->url);
|
||||
$this->assertInstanceOf('DomDocument', $readability->dom);
|
||||
$this->assertEquals('<html/>', $readability->original_html);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires extension tidy
|
||||
*/
|
||||
@@ -326,13 +335,6 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertNotContains('This text is also an awesome text and you should know that', $readability->getContent()->innerHTML);
|
||||
}
|
||||
|
||||
// public function testConstructParser()
|
||||
// {
|
||||
// $readability = $this->getReadability('<html/>', 'http://0.0.0.0', 'html5lib');
|
||||
|
||||
// $this->assertEquals('http://0.0.0.0', $readability->url);
|
||||
// }
|
||||
|
||||
// dummy function to be used to the next test
|
||||
public function error2Exception($code, $string, $file, $line, $context)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user