MediaWiki  1.23.2
MWTidy Class Reference

Class to interact with HTML tidy. More...

Static Public Member Functions

static checkErrors ( $text, &$errorStr=null)
 Check HTML for errors, used if $wgValidateAllHtml = true. More...
 
static tidy ( $text)
 Interface with html tidy, used if $wgUseTidy = true. More...
 

Static Private Member Functions

static execExternalTidy ( $text, $stderr=false, &$retval=null)
 Spawn an external HTML tidy process and get corrected markup back from it. More...
 
static execInternalTidy ( $text, $stderr=false, &$retval=null)
 Use the HTML tidy extension to use the tidy library in-process, saving the overhead of spawning a new process. More...
 

Detailed Description

Class to interact with HTML tidy.

Either the external tidy program or the in-process tidy extension will be used depending on availability. Override the default $wgTidyInternal setting to disable the internal if it's not working.

Definition at line 117 of file Tidy.php.

Member Function Documentation

◆ checkErrors()

static MWTidy::checkErrors (   $text,
$errorStr = null 
)
static

Check HTML for errors, used if $wgValidateAllHtml = true.

Parameters
$textString
&$errorStrString: return the error string
Returns
Boolean: whether the HTML is valid
Examples
/src/tests/phpunit/MediaWikiTestCase.php.

Definition at line 159 of file Tidy.php.

References $retval, execExternalTidy(), execInternalTidy(), and global.

Referenced by MediaWikiTestCase\assertValidHtmlDocument(), and wfHtmlValidationHandler().

◆ execExternalTidy()

static MWTidy::execExternalTidy (   $text,
  $stderr = false,
$retval = null 
)
staticprivate

Spawn an external HTML tidy process and get corrected markup back from it.

Also called in OutputHandler.php for full page validation

Parameters
string$textHTML to check
$stderrBoolean: Whether to read result from STDERR rather than STDOUT
&$retvalint Exit code (-1 on internal error)
Returns
mixed String or null

Definition at line 181 of file Tidy.php.

References $retval, array(), global, wfGetNull(), wfProfileIn(), wfProfileOut(), and wfWarn().

Referenced by checkErrors(), and tidy().

◆ execInternalTidy()

static MWTidy::execInternalTidy (   $text,
  $stderr = false,
$retval = null 
)
staticprivate

Use the HTML tidy extension to use the tidy library in-process, saving the overhead of spawning a new process.

Parameters
string$textHTML to check
$stderrBoolean: Whether to read result from error status instead of output
&$retvalint Exit code (-1 on internal error)
Returns
mixed String or null

Definition at line 248 of file Tidy.php.

References $retval, global, tidy(), wfProfileIn(), wfProfileOut(), and wfWarn().

Referenced by checkErrors(), and tidy().

◆ tidy()

static MWTidy::tidy (   $text)
static

Interface with html tidy, used if $wgUseTidy = true.

If tidy isn't able to correct the markup, the original will be returned in all its glory with a warning comment appended.

Parameters
string$texthideous HTML input
Returns
String: corrected HTML output

Definition at line 126 of file Tidy.php.

References execExternalTidy(), execInternalTidy(), MWTidyWrapper\getWrapped(), global, and wfDebug().

Referenced by execInternalTidy(), SpecialExpandTemplates\execute(), TidyTest\setUp(), and TidyTest\testTidyWrapping().


The documentation for this class was generated from the following file: