Physikerwelt has uploaded a new change for review. https://gerrit.wikimedia.org/r/153965
Change subject: Protect MathML from Tidy ...................................................................... Protect MathML from Tidy MediaWiki installations that use the setting $wgUseTidy = true; are unable to to output MathML since the well defined MathML elements are filtered out by Tidy. This was reported as http://sourceforge.net/p/tidy/patches/84/ . This change hides the MathML elements from Tidy. Bug 66516 Change-Id: I826c93fab32fb5012f609b22c378ea8a2590d6a7 --- M Math.hooks.php M Math.php 2 files changed, 23 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math refs/changes/65/153965/1 diff --git a/Math.hooks.php b/Math.hooks.php index 65819a1..c1b419f 100644 --- a/Math.hooks.php +++ b/Math.hooks.php @@ -92,7 +92,7 @@ * @return array */ static function mathTagHook( $content, $attributes, $parser ) { - global $wgUseMathJax, $wgMathDisableTexFilter; + global $wgUseMathJax, $wgMathDisableTexFilter, $wgUseTidy; if ( trim( $content ) === '' ) { // bug 8372 return ''; @@ -138,12 +138,31 @@ // Writes cache if rendering was successful $renderer->writeCache(); + // Hide math output from Tidy + if ( $wgUseTidy ) { + $renderedMath = '<!--untidy' .$renderedMath . 'untidy-->'; + } wfProfileOut( __METHOD__ ); - - return array( $renderedMath, "markerType" => 'nowiki' ); + return array( $renderedMath , "markerType" => 'nowiki' ); } /** + * Hook that restores the Math output that was hidden from Tidy + * + * @param $parser Parser link to the Parser object + * @param $text string the page text + * @return bool + */ + static function onParserAfterTidy( &$parser, &$text ){ + global $wgUseTidy; + if ( $wgUseTidy ){ + wfProfileIn( __METHOD__ ); + $text = preg_replace( '/(<!--untidy)(.*?)(untidy-->)/s','$2' ,$text ); + wfProfileOut( __METHOD__ ); + } + return true; + } + /** * Add the new math rendering options to Special:Preferences. * * @param $user Object: current User object diff --git a/Math.php b/Math.php index d5d295e..4a2d0bd 100644 --- a/Math.php +++ b/Math.php @@ -210,6 +210,7 @@ $wgHooks['UnitTestsList'][] = 'MathHooks::onRegisterUnitTests'; $wgHooks['PageRenderingHash'][] = 'MathHooks::onPageRenderingHash'; $wgHooks['EditPageBeforeEditToolbar'][] = 'MathHooks::onEditPageBeforeEditToolbar'; +$wgHooks['ParserAfterTidy'][] = 'MathHooks::onParserAfterTidy'; $dir = __DIR__ . '/'; $wgAutoloadClasses['MathHooks'] = $dir . 'Math.hooks.php'; -- To view, visit https://gerrit.wikimedia.org/r/153965 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I826c93fab32fb5012f609b22c378ea8a2590d6a7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Math Gerrit-Branch: master Gerrit-Owner: Physikerwelt <w...@physikerwelt.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits