Physikerwelt has uploaded a new change for review. https://gerrit.wikimedia.org/r/174706
Change subject: Improve Math test generation ...................................................................... Improve Math test generation * Use the wikitext parser and not regexp to extract math tags from the page. * Extract the attributes from the math tags as well In a follow up a pseudo attribute in the math tag could be introduced to provide a bug description. Change-Id: I0dec18d4e3f87e7b58b097b2a08c4897ceaf29ac --- M maintenance/MathGenerateTests.php 1 file changed, 6 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math refs/changes/06/174706/1 diff --git a/maintenance/MathGenerateTests.php b/maintenance/MathGenerateTests.php index e942601..9b50a83 100644 --- a/maintenance/MathGenerateTests.php +++ b/maintenance/MathGenerateTests.php @@ -36,8 +36,7 @@ } - private static function getMathTagsFromPage( $titleString ) - { + private static function getMathTagsFromPage( $titleString ) { global $wgEnableScaryTranscluding; $title = Title::newFromText( $titleString ); if ( $title->exists() ) { @@ -52,15 +51,12 @@ return 'Page does not exist'; } } - // TODO: find a better way to extract math elements from a page $wikiText = Sanitizer::removeHTMLcomments( $wikiText ); $wikiText = preg_replace( '#<nowiki>(.*)</nowiki>#', '', $wikiText ); - preg_match_all( "#<math>(.*?)</math>#s", $wikiText, $math ); - // TODO: Find a way to specify a key e.g '\nRenderTest:(.?)#<math>(.*?)</math>#s\n' - // leads to array('\1'->'\2') with \1 eg Bug 2345 and \2 the math content - return $math[1]; - + $math = array(); + Parser::extractTagsAndParams( array( 'math' ), $wikiText, $math ); + return $math; } public function execute() @@ -82,9 +78,9 @@ } $i = 0; foreach ( array_slice( $allEquations, $offset, $length, true ) as $input ) { - $output = MathRenderer::renderMath( $input, array(), MW_MATH_PNG ); + $output = MathRenderer::renderMath( $input[1], $input[1], MW_MATH_PNG ); $output = preg_replace( '#src="(.*?)/(([a-f]|\d)*).png"#', 'src="\2.png"', $output ); - $parserTests[] = array( (string)$input, $output ); + $parserTests[] = array( (string)$input[1], $output ); $i++; echo '.'; } -- To view, visit https://gerrit.wikimedia.org/r/174706 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0dec18d4e3f87e7b58b097b2a08c4897ceaf29ac 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