From 2771512dbeba455572f5935fe0a3b80720dae9af Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Fri, 30 Nov 2007 12:26:12 +0000 Subject: [PATCH] * $wgDebugTidy feature * Fixed a bug in extractSections() -- inappropriate expansion of double-brace constructs causing a fatal error under some circumstances (reported by Nikerabbit, thanks) --- includes/DefaultSettings.php | 6 ++++++ includes/Parser.php | 15 +++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 9c8c726b98..56ae28bec2 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1884,6 +1884,12 @@ $wgTidyConf = $IP.'/includes/tidy.conf'; $wgTidyOpts = ''; $wgTidyInternal = extension_loaded( 'tidy' ); +/** + * Put tidy warnings in HTML comments + * Only works for internal tidy. + */ +$wgDebugTidy = false; + /** See list of skins and their symbolic names in languages/Language.php */ $wgDefaultSkin = 'monobook'; diff --git a/includes/Parser.php b/includes/Parser.php index e314facccf..3374faa257 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -685,7 +685,7 @@ class Parser * @static */ function internalTidy( $text ) { - global $wgTidyConf, $IP; + global $wgTidyConf, $IP, $wgDebugTidy; $fname = 'Parser::internalTidy'; wfProfileIn( $fname ); @@ -699,6 +699,12 @@ class Parser } else { $cleansource = tidy_get_output( $tidy ); } + if ( $wgDebugTidy && $tidy->getStatus() > 0 ) { + $cleansource .= "', '-->', $tidy->errorBuffer ) . + "\n-->"; + } + wfProfileOut( $fname ); return $cleansource; } @@ -4956,7 +4962,7 @@ class Parser $curIndex++; } if ( $mode == 'replace' ) { - $outText .= $frame->expand( $node ); + $outText .= $frame->expand( $node, 0, PPFrame::RECOVER_ORIG ); } $node = $node->nextSibling; } @@ -4984,7 +4990,7 @@ class Parser } } if ( $mode == 'get' ) { - $outText .= $frame->expand( $node ); + $outText .= $frame->expand( $node, 0, PPFrame::RECOVER_ORIG ); } $node = $node->nextSibling; } while ( $node ); @@ -4996,7 +5002,7 @@ class Parser // stripped by the editor, so we need both newlines to restore the paragraph gap $outText .= $newText . "\n\n"; while ( $node ) { - $outText .= $frame->expand( $node ); + $outText .= $frame->expand( $node, 0, PPFrame::RECOVER_ORIG ); $node = $node->nextSibling; } } @@ -5218,6 +5224,7 @@ class PPFrame { const NO_ARGS = 1; const NO_TEMPLATES = 2; + const RECOVER_ORIG = 3; /** * Construct a new preprocessor frame. -- 2.20.1