From 31cd0d611a3957956de54a96bffc9156a8f9a916 Mon Sep 17 00:00:00 2001 From: physikerwelt Date: Wed, 23 Mar 2016 17:11:05 -0400 Subject: [PATCH] Insert MathML content after tidy * BeforeTidy caused problems when math tags were used within links. Bug: T130508 Change-Id: Icb9b88a7552d14231f96cbfd2b3cf3fa7e29276d --- Math.hooks.php | 2 +- extension.json | 4 ++-- tests/MathMathMLTest.php | 9 +++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Math.hooks.php b/Math.hooks.php index 57f75bf..2fc6b5f 100644 --- a/Math.hooks.php +++ b/Math.hooks.php @@ -373,7 +373,7 @@ class MathHooks { * @param $text * @return bool */ - public static function onParserBeforeTidy( &$parser, &$text ) { + public static function onParserAfterTidy( &$parser, &$text ) { $rbis = array(); foreach ( self::$tags as $key => $tag ){ /** @var MathRenderer $renderer */ diff --git a/extension.json b/extension.json index 9db5772..75d1cdc 100644 --- a/extension.json +++ b/extension.json @@ -69,8 +69,8 @@ "WikibaseRepoDataTypes": [ "MathWikidataHook::onWikibaseRepoDataTypes" ], - "ParserBeforeTidy":[ - "MathHooks::onParserBeforeTidy" + "ParserAfterTidy":[ + "MathHooks::onParserAfterTidy" ] }, "config": { diff --git a/tests/MathMathMLTest.php b/tests/MathMathMLTest.php index ba730b8..3283da5 100644 --- a/tests/MathMathMLTest.php +++ b/tests/MathMathMLTest.php @@ -111,6 +111,15 @@ class MathMathMLTest extends MediaWikiTestCase { 'test if math expression is invalid mathml sample' ); } + public function testintegrationTestWithLinks() { + $p = new Parser(); + $po = new ParserOptions(); + $t = new Title( "test" ); + $res = $p->parse( '[[test|a+b]]', $t, $po )->getText(); + $this->assertContains( '', $res ); + $this->assertContains( '.png', $res ); + } + } /**