or tag. * @return string Corrected HTML output * @throws MWException */ public static function tidy( $text ) { $driver = self::singleton(); if ( !$driver ) { throw new MWException( __METHOD__ . ': tidy is disabled, caller should have checked MWTidy::isEnabled()' ); } return $driver->tidy( $text ); } /** * @return bool */ public static function isEnabled() { return self::singleton() !== false; } /** * @return bool|\MediaWiki\Tidy\TidyDriverBase */ public static function singleton() { global $wgTidyConfig; if ( self::$instance === null ) { self::$instance = self::factory( $wgTidyConfig ); } return self::$instance; } /** * Create a new Tidy driver object from configuration. * @see $wgTidyConfig * @param array|null $config Optional since 1.33 * @return bool|\MediaWiki\Tidy\TidyDriverBase * @throws MWException */ public static function factory( array $config = null ) { return new MediaWiki\Tidy\RemexDriver( $config ?? [] ); } /** * Set the driver to be used. This is for testing. * @param MediaWiki\Tidy\TidyDriverBase|false|null $instance * @deprecated Since 1.33 */ public static function setInstance( $instance ) { wfDeprecated( __METHOD__, '1.33' ); self::$instance = $instance; } /** * Destroy the current singleton instance */ public static function destroySingleton() { self::$instance = null; } }