From 4cf8462110367504191d2d151b8c21ed016571e0 Mon Sep 17 00:00:00 2001 From: "Moritz Schubotz (physikerwelt)" Date: Sat, 27 Jan 2024 22:57:12 +0100 Subject: [PATCH] Human-readable errors on Special:MathStatus Errors were thrown for custom tests on Special:MathStatus which was disturbing. * Use human-readable error messages instead * Note that the source rendering mode has no check method. Bug: T355389 Change-Id: Id1cacf47dd5441758b7ad8dba3434a01b655a673 --- src/Widget/MathTestInputForm.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Widget/MathTestInputForm.php b/src/Widget/MathTestInputForm.php index 8c8dea9a0..0d21c92b8 100644 --- a/src/Widget/MathTestInputForm.php +++ b/src/Widget/MathTestInputForm.php @@ -2,6 +2,7 @@ namespace MediaWiki\Extension\Math\Widget; +use MediaWiki\Extension\Math\MathConfig; use MediaWiki\Extension\Math\Render\RendererFactory; use MediaWiki\Extension\Math\SpecialMathStatus; use OOUIHTMLForm; @@ -74,8 +75,13 @@ class MathTestInputForm extends OOUIHTMLForm { $options['display'] = $formData['display']; } $renderer = $this->rendererFactory->getRenderer( $formData['tex'], $options, $mode ); - $renderer->render(); - $out->addHTML( $renderer->getHtmlOutput() ); + if ( ( $mode === MathConfig::MODE_SOURCE || $renderer->checkTeX() ) + && $renderer->render() ) { + $html = $renderer->getHtmlOutput(); + } else { + $html = $renderer->getLastError(); + } + $out->addHTML( $html ); $out->addWikiMsgArray( 'math-test-end', [ $modeName ] ); }