From 446f11bafc4f962324a9a802ab51e613d5a643d6 Mon Sep 17 00:00:00 2001 From: Wil Mahan Date: Sat, 25 Sep 2004 18:22:21 +0000 Subject: [PATCH] Move tidy call from Parser to OutputPage so that it happens after link placeholder replacement. --- includes/OutputPage.php | 10 ++++++++-- includes/Parser.php | 15 +++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index d240667070..2fb7fb8cb8 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -232,9 +232,12 @@ class OutputPage { * 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() ); @@ -245,13 +248,16 @@ class OutputPage { * 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 ) { diff --git a/includes/Parser.php b/includes/Parser.php index c7d27a67f9..ba9b1d9e8c 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -184,9 +184,6 @@ class Parser # 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; @@ -483,7 +480,8 @@ class Parser /** * interface with html tidy, used if $wgUseTidy = true * - * @access private + * @access public + * @static */ function tidy ( $text ) { global $wgTidyConf, $wgTidyBin, $wgTidyOpts; @@ -492,15 +490,16 @@ class Parser 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 = ' 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]); -- 2.20.1