summaryrefslogtreecommitdiff
path: root/includes/tidy/TidyDriverBase.php
blob: 1d994aa1bd0f26f6b9b5aa6a4549bb6b562d7a10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

namespace MediaWiki\Tidy;

/**
 * Base class for HTML cleanup utilities
 */
abstract class TidyDriverBase {
	protected $config;

	function __construct( $config ) {
		$this->config = $config;
	}

	/**
	 * Return true if validate() can be used
	 */
	public function supportsValidate() {
		return false;
	}

	/**
	 * Check HTML for errors, used if $wgValidateAllHtml = true.
	 *
	 * @param string $text
	 * @param string &$errorStr Return the error string
	 * @return bool Whether the HTML is valid
	 */
	public function validate( $text, &$errorStr ) {
		throw new MWException( get_class( $this ) . " does not support validate()" );
	}

	/**
	 * Clean up HTML
	 *
	 * @param string HTML document fragment to clean up
	 * @param string The corrected HTML output
	 */
	public abstract function tidy( $text );
}