Add missing HTML5 class

pull/32/head
Jeremy Benoist 9 years ago
parent 5ac82f3c87
commit 05089bbd03
No known key found for this signature in database
GPG Key ID: BCA73962457ACC3C
  1. 3
      composer.json
  2. 3
      src/Readability.php
  3. 16
      tests/ReadabilityTest.php

@ -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",

@ -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)
{

Loading…
Cancel
Save