mirror of
https://github.com/j0k3r/php-readability.git
synced 2026-09-26 22:16:12 +00:00
tidy: use tidy_repair_string instead of tidy_parse_string+tidy_clean_repair
A change released in tidy 5.6.0 breaks php-tidy when using tidy_parse_string+tidy_clean_repair and wrap=0, incorrectly wrapping every single word. Also it seems that $tidy->value should not be used to retrieve the repaired html as far as it is undocumented and for internal use. We replace the call with tidy_repair_string which directly returns the repaired string. Relates to https://github.com/htacg/tidy-html5/issues/673 Relates to https://bugs.php.net/bug.php?id=75947 Tests pass. Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
This commit is contained in:
+3
-3
@@ -274,10 +274,10 @@ class Readability implements LoggerAwareInterface
|
|||||||
if ($this->useTidy) {
|
if ($this->useTidy) {
|
||||||
$this->logger->debug('Tidying document');
|
$this->logger->debug('Tidying document');
|
||||||
|
|
||||||
$tidy = tidy_parse_string($this->html, $this->tidy_config, 'UTF8');
|
$tidy = tidy_repair_string($this->html, $this->tidy_config, 'UTF8');
|
||||||
if (tidy_clean_repair($tidy)) {
|
if (false !== $tidy && $this->html !== $tidy) {
|
||||||
$this->tidied = true;
|
$this->tidied = true;
|
||||||
$this->html = $tidy->value;
|
$this->html = $tidy;
|
||||||
$this->html = preg_replace('/[\r\n]+/is', "\n", $this->html);
|
$this->html = preg_replace('/[\r\n]+/is', "\n", $this->html);
|
||||||
}
|
}
|
||||||
unset($tidy);
|
unset($tidy);
|
||||||
|
|||||||
Reference in New Issue
Block a user