MediaWiki REL1_33
RemexDriver.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Tidy;
4
11
15 private $mungerTrace;
16 private $pwrap;
17
18 public function __construct( array $config ) {
19 $config += [
20 'treeMutationTrace' => false,
21 'serializerTrace' => false,
22 'mungerTrace' => false,
23 'pwrap' => true
24 ];
25 $this->treeMutationTrace = $config['treeMutationTrace'];
26 $this->serializerTrace = $config['serializerTrace'];
27 $this->mungerTrace = $config['mungerTrace'];
28 $this->pwrap = $config['pwrap'];
29 parent::__construct( $config );
30 }
31
32 public function tidy( $text ) {
33 $traceCallback = function ( $msg ) {
34 wfDebug( "RemexHtml: $msg" );
35 };
36
37 $formatter = new RemexCompatFormatter;
38 if ( $this->serializerTrace ) {
39 $serializer = new SerializerWithTracer( $formatter, null, $traceCallback );
40 } else {
41 $serializer = new Serializer( $formatter );
42 }
43 if ( $this->pwrap ) {
44 $munger = new RemexCompatMunger( $serializer, $this->mungerTrace );
45 } else {
46 $munger = $serializer;
47 }
48 if ( $this->treeMutationTrace ) {
49 $tracer = new TreeMutationTracer( $munger, $traceCallback );
50 } else {
51 $tracer = $munger;
52 }
53 $treeBuilder = new TreeBuilder( $tracer, [
54 'ignoreErrors' => true,
55 'ignoreNulls' => true,
56 ] );
57 $dispatcher = new Dispatcher( $treeBuilder );
58 $tokenizer = new Tokenizer( $dispatcher, $text, [
59 'ignoreErrors' => true,
60 'ignoreCharRefs' => true,
61 'ignoreNulls' => true,
62 'skipPreprocess' => true,
63 ] );
64
65 $tokenizer->execute( [
66 'fragmentNamespace' => \RemexHtml\HTMLData::NS_HTML,
67 'fragmentName' => 'body'
68 ] );
69 return $serializer->getResult();
70 }
71}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
tidy( $text)
Clean up HTML.
Base class for HTML cleanup utilities.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition hooks.txt:2004
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))