Skip to content

Commit c54b69b

Browse files
committed
Initial version using PHP 8.4's HTML5 parser
1 parent 71ab250 commit c54b69b

27 files changed

+221
-271
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"ext-xml": "*",
3333
"ext-mbstring": "*",
3434
"psr/log": "^1.0 || ^2.0 || ^3.0",
35-
"masterminds/html5": "^2.0",
3635
"league/uri": "^7.0"
3736
},
3837
"require-dev": {

src/Configuration.php

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class Configuration
2020
protected bool $cleanConditionally = true;
2121
protected bool $weightClasses = true;
2222
protected bool $fixRelativeURLs = false;
23-
protected bool $substituteEntities = false;
2423
protected bool $normalizeEntities = false;
2524
protected bool $summonCthulhu = false;
2625
protected string $originalURL = 'http://fakehost';
@@ -206,24 +205,6 @@ public function setFixRelativeURLs(bool $fixRelativeURLs): Configuration
206205
return $this;
207206
}
208207

209-
/**
210-
* Get substitute entities.
211-
*/
212-
public function getSubstituteEntities(): bool
213-
{
214-
return $this->substituteEntities;
215-
}
216-
217-
/**
218-
* Set substitute entities.
219-
*/
220-
public function setSubstituteEntities(bool $substituteEntities): Configuration
221-
{
222-
$this->substituteEntities = $substituteEntities;
223-
224-
return $this;
225-
}
226-
227208
/**
228209
* Get normalize entities.
229210
*/
@@ -273,7 +254,11 @@ public function getParser(): string
273254
*/
274255
public function setParser(string $parser): Configuration
275256
{
276-
$this->parser = $parser;
257+
if ($parser !== 'html5') {
258+
throw new \InvalidArgumentException('This version of Readability.php only supports the HTML5 parser introduced in PHP 8.4');
259+
} else {
260+
$this->parser = $parser;
261+
}
277262

278263
return $this;
279264
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use fivefilters\Readability\Nodes\NodeTrait;
66

7-
class DOMAttr extends \DOMAttr
7+
class Attr extends \DOM\Attr
88
{
99
use NodeTrait;
1010
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use fivefilters\Readability\Nodes\NodeTrait;
66

7-
class DOMNotation extends \DOMNotation
7+
class CdataSection extends \DOM\CdataSection
88
{
99
use NodeTrait;
1010
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use fivefilters\Readability\Nodes\NodeTrait;
66

7-
class DOMCdataSection extends \DOMCdataSection
7+
class CharacterData extends \DOM\CharacterData
88
{
99
use NodeTrait;
1010
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use fivefilters\Readability\Nodes\NodeTrait;
66

7-
class DOMEntity extends \DOMEntity
7+
class Comment extends \DOM\Comment
88
{
99
use NodeTrait;
1010
}

src/Nodes/DOM/DOMDocument.php

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/Nodes/DOM/DOMDocumentFragment.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/Nodes/DOM/DOMDocumentType.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/Nodes/DOM/DOMEntityReference.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)