HtmlParser.php in Feeds extensible parsers 8
File
src/Feeds/Parser/HtmlParser.php
View source
<?php
namespace Drupal\feeds_ex\Feeds\Parser;
use DOMNode;
use Drupal\feeds\FeedInterface;
use Drupal\feeds\Result\FetcherResultInterface;
class HtmlParser extends XmlParser {
protected $useSaveHTML;
protected $encoderClass = '\\Drupal\\feeds_ex\\Encoder\\HtmlEncoder';
protected function prepareDocument(FeedInterface $feed, FetcherResultInterface $fetcher_result) {
$raw = $this
->prepareRaw($fetcher_result);
if ($this->configuration['use_tidy'] && extension_loaded('tidy')) {
$raw = tidy_repair_string($raw, $this
->getTidyConfig(), 'utf8');
}
return $this->utility
->createHtmlDocument($raw);
}
protected function getRaw(DOMNode $node) {
return $node->ownerDocument
->saveHTML($node);
}
protected function getTidyConfig() {
return [
'merge-divs' => FALSE,
'merge-spans' => FALSE,
'join-styles' => FALSE,
'drop-empty-paras' => FALSE,
'wrap' => 0,
'tidy-mark' => FALSE,
'escape-cdata' => TRUE,
];
}
}