mirror of
https://github.com/j0k3r/php-readability.git
synced 2026-09-27 06:26:17 +00:00
Remove addPreFilter
Pre filters are used in the __construct so adding more pre filters once the object is instantiated is useless.
This commit is contained in:
@@ -56,7 +56,8 @@ class JSLikeHTMLElement extends \DOMElement
|
||||
$f = $this->ownerDocument->createDocumentFragment();
|
||||
|
||||
// appendXML() expects well-formed markup (XHTML)
|
||||
$result = @$f->appendXML($value); // @ to suppress PHP warnings
|
||||
// @ to suppress PHP warnings
|
||||
$result = @$f->appendXML($value);
|
||||
if ($result) {
|
||||
if ($f->hasChildNodes()) {
|
||||
$this->appendChild($f);
|
||||
@@ -75,6 +76,7 @@ class JSLikeHTMLElement extends \DOMElement
|
||||
|
||||
if ($result) {
|
||||
$import = $f->getElementsByTagName('htmlfragment')->item(0);
|
||||
|
||||
foreach ($import->childNodes as $child) {
|
||||
$importedNode = $this->ownerDocument->importNode($child, true);
|
||||
$this->appendChild($importedNode);
|
||||
@@ -102,6 +104,7 @@ class JSLikeHTMLElement extends \DOMElement
|
||||
{
|
||||
if ($name == 'innerHTML') {
|
||||
$inner = '';
|
||||
|
||||
foreach ($this->childNodes as $child) {
|
||||
$inner .= $this->ownerDocument->saveXML($child);
|
||||
}
|
||||
|
||||
+3
-16
@@ -250,17 +250,6 @@ class Readability
|
||||
return $this->articleContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add pre filter for raw input HTML processing.
|
||||
*
|
||||
* @param string RegExp for replace
|
||||
* @param string (optional) Replacer
|
||||
*/
|
||||
public function addPreFilter($filter, $replacer = '')
|
||||
{
|
||||
$this->pre_filters[$filter] = $replacer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add post filter for raw output HTML processing.
|
||||
*
|
||||
@@ -302,7 +291,7 @@ class Readability
|
||||
}
|
||||
}
|
||||
|
||||
if ($bodyElems->length > 0 && $this->body == null) {
|
||||
if ($bodyElems->length > 0 && $this->body === null) {
|
||||
$this->body = $bodyElems->item(0);
|
||||
}
|
||||
|
||||
@@ -385,12 +374,11 @@ class Readability
|
||||
*/
|
||||
protected function getArticleTitle()
|
||||
{
|
||||
$origTitle = '';
|
||||
|
||||
try {
|
||||
$curTitle = $origTitle = $this->getInnerText($this->dom->getElementsByTagName('title')->item(0));
|
||||
} catch (\Exception $e) {
|
||||
$curTitle = '';
|
||||
$origTitle = '';
|
||||
}
|
||||
|
||||
if (preg_match('/ [\|\-] /', $curTitle)) {
|
||||
@@ -431,7 +419,7 @@ class Readability
|
||||
* In some cases a body element can't be found (if the HTML is totally hosed for example)
|
||||
* so we create a new body node and append it to the document.
|
||||
*/
|
||||
if ($this->body == null) {
|
||||
if ($this->body === null) {
|
||||
$this->body = $this->dom->createElement('body');
|
||||
$this->dom->documentElement->appendChild($this->body);
|
||||
}
|
||||
@@ -571,7 +559,6 @@ class Readability
|
||||
$this->cleanConditionally($articleContent, 'form');
|
||||
$this->cleanConditionally($articleContent, 'table');
|
||||
$this->cleanConditionally($articleContent, 'ul');
|
||||
//if (!$this->lightClean)
|
||||
$this->cleanConditionally($articleContent, 'div');
|
||||
|
||||
// Remove extra paragraphs.
|
||||
|
||||
Reference in New Issue
Block a user