3 namespace MediaWiki\Tidy
;
8 * @deprecated since 1.32, use RemexDriver
10 abstract class RaggettBase
extends TidyDriverBase
{
12 * Generic interface for wrapping and unwrapping HTML for Dave Raggett's tidy.
14 * @param string $text Hideous HTML input
15 * @return string Corrected HTML output
17 public function tidy( $text ) {
18 $wrapper = new RaggettWrapper
;
19 $wrappedtext = $wrapper->getWrapped( $text );
22 $correctedtext = $this->cleanWrapped( $wrappedtext, false, $retVal );
25 wfDebug( "Possible tidy configuration error!\n" );
26 return $text . "\n<!-- Tidy was unable to run -->\n";
27 } elseif ( is_null( $correctedtext ) ) {
28 wfDebug( "Tidy error detected!\n" );
29 return $text . "\n<!-- Tidy found serious XHTML errors -->\n";
32 $correctedtext = $wrapper->postprocess( $correctedtext ); // restore any hidden tokens
34 return $correctedtext;
37 public function validate( $text, &$errorStr ) {
39 $errorStr = $this->cleanWrapped( $text, true, $retval );
40 return ( $retval < 0 && $errorStr == '' ) ||
$retval == 0;
44 * Perform a clean/repair operation
45 * @param string $text HTML to check
46 * @param bool $stderr Whether to read result from STDERR rather than STDOUT
47 * @param int|null &$retval Exit code (-1 on internal error)
51 abstract protected function cleanWrapped( $text, $stderr = false, &$retval = null );