* Convert wikitext to HTML and add it to the buffer
*/
function addWikiText( $text, $linestart = true ) {
- global $wgParser, $wgTitle;
+ global $wgParser, $wgTitle, $wgUseTidy;
$parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions, $linestart );
+ if ($wgUseTidy) {
+ $text = Parser::tidy($text);
+ }
$this->mLanguageLinks += $parserOutput->getLanguageLinks();
$this->mCategoryLinks += $parserOutput->getCategoryLinks();
$this->addHTML( $parserOutput->getText() );
* Saves the text into the parser cache if possible
*/
function addPrimaryWikiText( $text, $cacheArticle ) {
- global $wgParser, $wgParserCache, $wgUser, $wgTitle;
+ global $wgParser, $wgParserCache, $wgUser, $wgTitle, $wgUseTidy;
$parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions, true );
# Replace link holders
$text = $parserOutput->getText();
$this->replaceLinkHolders( $text );
+ if ($wgUseTidy) {
+ $text = Parser::tidy($text);
+ }
$parserOutput->setText( $text );
if ( $cacheArticle ) {
# only once and last
$text = $this->doBlockLevels( $text, $linestart );
$text = $this->unstripNoWiki( $text, $this->mStripState );
- if($wgUseTidy) {
- $text = $this->tidy($text);
- }
$this->mOutput->setText( $text );
wfProfileOut( $fname );
return $this->mOutput;
/**
* interface with html tidy, used if $wgUseTidy = true
*
- * @access private
+ * @access public
+ * @static
*/
function tidy ( $text ) {
global $wgTidyConf, $wgTidyBin, $wgTidyOpts;
wfProfileIn( $fname );
$cleansource = '';
+ $opts = '';
switch(strtoupper($wgOutputEncoding)) {
case 'ISO-8859-1':
- $wgTidyOpts .= ($wgInputEncoding == $wgOutputEncoding)? ' -latin1':' -raw';
+ $opts .= ($wgInputEncoding == $wgOutputEncoding)? ' -latin1':' -raw';
break;
case 'UTF-8':
- $wgTidyOpts .= ($wgInputEncoding == $wgOutputEncoding)? ' -utf8':' -raw';
+ $opts .= ($wgInputEncoding == $wgOutputEncoding)? ' -utf8':' -raw';
break;
default:
- $wgTidyOpts .= ' -raw';
+ $opts .= ' -raw';
}
$wrappedtext = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'.
1 => array('pipe', 'w'),
2 => array('file', '/dev/null', 'a')
);
- $process = proc_open("$wgTidyBin -config $wgTidyConf $wgTidyOpts", $descriptorspec, $pipes);
+ $process = proc_open("$wgTidyBin -config $wgTidyConf $wgTidyOpts$opts", $descriptorspec, $pipes);
if (is_resource($process)) {
fwrite($pipes[0], $wrappedtext);
fclose($pipes[0]);