3 namespace MediaWiki\Tidy
;
5 class RaggettInternalPHP
extends RaggettBase
{
7 * Use the HTML tidy extension to use the tidy library in-process,
8 * saving the overhead of spawning a new process.
10 * @param string $text HTML to check
11 * @param bool $stderr Whether to read result from error status instead of output
12 * @param int &$retval Exit code (-1 on internal error)
15 protected function cleanWrapped( $text, $stderr = false, &$retval = null ) {
16 if ( !class_exists( 'tidy' ) ) {
17 wfWarn( "Unable to load internal tidy class." );
24 $tidy->parseString( $text, $this->config
['tidyConfigFile'], 'utf8' );
27 $retval = $tidy->getStatus();
28 return $tidy->errorBuffer
;
32 $retval = $tidy->getStatus();
34 // 2 is magic number for fatal error
35 // http://www.php.net/manual/en/function.tidy-get-status.php
38 $cleansource = tidy_get_output( $tidy );
39 if ( !empty( $this->config
['debugComment'] ) && $retval > 0 ) {
40 $cleansource .= "<!--\nTidy reports:\n" .
41 str_replace( '-->', '-->', $tidy->errorBuffer
) .
49 public function supportsValidate() {