mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-08 02:31:35 +02:00
Namespace all templates Move difflib and BBCodeParser2 to thirdparty Remove deprecated API marked for removal in 4.0
33 lines
620 B
PHP
33 lines
620 B
PHP
<?php
|
|
|
|
namespace SilverStripe\View\Parsers;
|
|
|
|
use tidy;
|
|
|
|
/**
|
|
* Cleans HTML using the Tidy package
|
|
* http://php.net/manual/en/book.tidy.php
|
|
*/
|
|
class TidyHTMLCleaner extends HTMLCleaner
|
|
{
|
|
|
|
protected $defaultConfig = array(
|
|
'clean' => true,
|
|
'output-xhtml' => true,
|
|
'show-body-only' => true,
|
|
'wrap' => 0,
|
|
'doctype' => 'omit',
|
|
'input-encoding' => 'utf8',
|
|
'output-encoding' => 'utf8'
|
|
);
|
|
|
|
public function cleanHTML($content)
|
|
{
|
|
$tidy = new tidy();
|
|
$output = $tidy->repairString($content, $this->config);
|
|
|
|
// Clean leading/trailing whitespace
|
|
return preg_replace('/(^\s+)|(\s+$)/', '', $output);
|
|
}
|
|
}
|