5 use RemexHtml\Serializer\Serializer;
6 use RemexHtml\Tokenizer\Tokenizer;
7 use RemexHtml\TreeBuilder\Dispatcher;
8 use RemexHtml\TreeBuilder\TreeBuilder;
9 use RemexHtml\TreeBuilder\TreeMutationTracer;
17 'treeMutationTrace' =>
false,
20 $this->trace =
$config[
'treeMutationTrace'];
21 $this->pwrap =
$config[
'pwrap'];
25 public function tidy( $text ) {
27 $serializer =
new Serializer( $formatter );
31 $munger = $serializer;
34 $tracer =
new TreeMutationTracer( $munger,
function ( $msg ) {
40 $treeBuilder =
new TreeBuilder( $tracer, [
41 'ignoreErrors' =>
true,
42 'ignoreNulls' =>
true,
44 $dispatcher =
new Dispatcher( $treeBuilder );
45 $tokenizer =
new Tokenizer( $dispatcher, $text, [
46 'ignoreErrors' =>
true,
47 'ignoreCharRefs' =>
true,
48 'ignoreNulls' =>
true,
49 'skipPreprocess' =>
true,
51 $tokenizer->execute( [
52 'fragmentNamespace' => \RemexHtml\HTMLData::NS_HTML,
53 'fragmentName' =>
'body'
55 return $serializer->getResult();