Merge pull request #32 from j0k3r/html5

Add missing HTML5 class
pull/34/merge 1.1.9
Jérémy Benoist 9 years ago committed by GitHub
commit 6427dd7371
  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",

@ -2,6 +2,7 @@
namespace Readability;
use HTML5Lib\Parser;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
@ -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