Manual talk:$wgTidyInternal

From mediawiki.org
Jump to navigation Jump to search

The current code for handling internal Tidy only works for PHP4.x (True in Mediawiki 1.11 and earlier - it has been fixed in 1.12). If you are trying to use it, you must fix Parser.php:

In Parser.php, around line 770, you'll find a function called "function internalTidy( $text )". Remove the version in the code and replace it with the following version. This has been modified to use PHP5 versions of various functions.

	/**
	 * Use the HTML tidy PECL extension to use the tidy library in-process,
	 * saving the overhead of spawning a new process. 
	 *
	 * 'pear install tidy' should be able to compile the extension module.
	 *
	 * @private
	 * @static
	 */
	function internalTidy( $text ) {
	global $wgTidyConf;
	$fname = 'Parser::internalTidy';
	wfProfileIn( $fname );

        $tidy = tidy_parse_string( $text, $wgTidyConf, 'utf8' );
        tidy_clean_repair($tidy);
        if( tidy_get_status($tidy) == 2 ) {
            // 2 is magic number for fatal error
            // http://www.php.net/manual/en/function.tidy-get-status.php
            $cleansource = null;
        } else {
            $cleansource = tidy_get_output($tidy);
        }
        wfProfileOut( $fname );
        return $cleansource; 
      }

Michael Daly 16:10, 19 June 2007 (UTC)