* @param string $text HTML input fragment. This should not contain a
* <body> or <html> tag.
* @return string Corrected HTML output
+ * @throws MWException
*/
public static function tidy( $text ) {
$driver = self::singleton();
* @param string $text
* @param string &$errorStr Return the error string
* @return bool Whether the HTML is valid
+ * @throws MWException
*/
public static function checkErrors( $text, &$errorStr = null ) {
$driver = self::singleton();
}
}
+ /**
+ * @return bool
+ */
public static function isEnabled() {
return self::singleton() !== false;
}
- protected static function singleton() {
+ /**
+ * @return bool|\MediaWiki\Tidy\TidyDriverBase
+ */
+ public static function singleton() {
global $wgUseTidy, $wgTidyInternal, $wgTidyConf, $wgDebugTidy, $wgTidyConfig,
$wgTidyBin, $wgTidyOpts;
* Create a new Tidy driver object from configuration.
* @see $wgTidyConfig
* @param array $config
- * @return TidyDriverBase
+ * @return bool|\MediaWiki\Tidy\TidyDriverBase
+ * @throws MWException
*/
public static function factory( array $config ) {
switch ( $config['driver'] ) {
case 'Html5Internal':
$instance = new MediaWiki\Tidy\Html5Internal( $config );
break;
+ case 'RemexHtml':
+ $instance = new MediaWiki\Tidy\RemexDriver( $config );
+ break;
case 'disabled':
return false;
default:
/**
* Set the driver to be used. This is for testing.
- * @param TidyDriverBase|false|null $instance
+ * @param MediaWiki\Tidy\TidyDriverBase|false|null $instance
*/
public static function setInstance( $instance ) {
self::$instance = $instance;