Merge "Add attributes parameter to ShowSearchHitTitle"
[lhc/web/wiklou.git] / includes / tidy / TidyDriverBase.php
1 <?php
2
3 namespace MediaWiki\Tidy;
4
5 /**
6 * Base class for HTML cleanup utilities
7 */
8 abstract class TidyDriverBase {
9 protected $config;
10
11 function __construct( $config ) {
12 $this->config = $config;
13 }
14
15 /**
16 * Return true if validate() can be used
17 * @return bool
18 */
19 public function supportsValidate() {
20 return false;
21 }
22
23 /**
24 * Check HTML for errors, used if $wgValidateAllHtml = true.
25 *
26 * @param string $text
27 * @param string &$errorStr Return the error string
28 * @throws \MWException
29 * @return bool Whether the HTML is valid
30 */
31 public function validate( $text, &$errorStr ) {
32 throw new \MWException( static::class . ' does not support validate()' );
33 }
34
35 /**
36 * Clean up HTML
37 *
38 * @param string $text HTML document fragment to clean up
39 * @return string The corrected HTML output
40 */
41 abstract public function tidy( $text );
42 }