2015-08-31 04:42:55 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace MediaWiki\Tidy;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Base class for HTML cleanup utilities
|
|
|
|
|
*/
|
|
|
|
|
abstract class TidyDriverBase {
|
|
|
|
|
protected $config;
|
|
|
|
|
|
2019-11-30 23:03:59 +00:00
|
|
|
public function __construct( $config ) {
|
2015-08-31 04:42:55 +00:00
|
|
|
$this->config = $config;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return true if validate() can be used
|
2017-09-09 20:47:04 +00:00
|
|
|
* @return bool
|
2021-02-18 17:10:16 +00:00
|
|
|
* @deprecated since 1.36, always returns false
|
2015-08-31 04:42:55 +00:00
|
|
|
*/
|
|
|
|
|
public function supportsValidate() {
|
2021-02-18 17:10:16 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.36' );
|
2015-08-31 04:42:55 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Clean up HTML
|
|
|
|
|
*
|
2015-12-09 17:20:41 +00:00
|
|
|
* @param string $text HTML document fragment to clean up
|
2021-02-18 16:51:12 +00:00
|
|
|
* @param ?callable $textProcessor A callback to run on the contents of
|
|
|
|
|
* text nodes (not elements or attribute values). This can be used to
|
|
|
|
|
* apply text modifications like french spacing or smart quotes, without
|
|
|
|
|
* affecting element or attribute markup.
|
2015-12-09 17:20:41 +00:00
|
|
|
* @return string The corrected HTML output
|
2015-08-31 04:42:55 +00:00
|
|
|
*/
|
2021-02-18 16:51:12 +00:00
|
|
|
abstract public function tidy( $text, ?callable $textProcessor = null );
|
2015-08-31 04:42:55 +00:00
|
|
|
}
|