32 public function tidy( $text ) {
33 $traceCallback =
function ( $msg ) {
38 if ( $this->serializerTrace ) {
39 $serializer =
new SerializerWithTracer( $formatter,
null, $traceCallback );
41 $serializer =
new Serializer( $formatter );
46 $munger = $serializer;
48 if ( $this->treeMutationTrace ) {
49 $tracer =
new TreeMutationTracer( $munger, $traceCallback );
53 $treeBuilder =
new TreeBuilder( $tracer, [
54 'ignoreErrors' =>
true,
55 'ignoreNulls' =>
true,
57 $dispatcher =
new Dispatcher( $treeBuilder );
58 $tokenizer =
new Tokenizer( $dispatcher, $text, [
59 'ignoreErrors' =>
true,
60 'ignoreCharRefs' =>
true,
61 'ignoreNulls' =>
true,
62 'skipPreprocess' =>
true,
65 $tokenizer->execute( [
66 'fragmentNamespace' => \RemexHtml\HTMLData::NS_HTML,
67 'fragmentName' =>
'body'
69 return $serializer->getResult();