Physikerwelt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/256940

Change subject: Use Restbase rendering in MathML mode
......................................................................

Use Restbase rendering in MathML mode

Change-Id: Ief1b6345c17db41f92684e00233d57240e97599f
---
M MathMathML.php
1 file changed, 22 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math 
refs/changes/40/256940/1

diff --git a/MathMathML.php b/MathMathML.php
index 4766242..ba8eb69 100644
--- a/MathMathML.php
+++ b/MathMathML.php
@@ -20,6 +20,7 @@
        /** @var boolean if false MathML output is not validated */
        private $XMLValidation = true;
        protected $inputType = 'tex';
+       private $svgPath = false;
 
        /**
         * @param string $inputType
@@ -85,6 +86,23 @@
         * @see MathRenderer::render()
        */
        public function render( $forceReRendering = false ) {
+               if ( $this->inputType == 'tex' ) {
+                       $tex = $this->getTex();
+                       $displaystyle = false;
+                       if ( $this->getMathStyle() == 'inlineDisplaystyle' ) {
+                               // default preserve the (broken) layout as it 
was
+                               $tex = '{\\displaystyle ' . $tex . '}';
+                       } elseif ( $this->getMathStyle() !== 'inline' ) {
+                               $displaystyle = true;
+                       }
+                       $rbi = new MathRestbaseInterface( $tex, $displaystyle );
+                       $rbi->checkTeX();
+                       $this->mathml = $rbi->getMathML();
+                       $this->rbi = $rbi;
+                       $this->svg = $rbi->getSvg();
+                       $this->svgPath = $rbi->getFullSvgUrl();
+                       return $rbi->getSuccess();
+               }
                if ( $forceReRendering ) {
                        $this->setPurge( true );
                }
@@ -218,14 +236,7 @@
                } elseif ( $this->inputType == 'ascii' ) {
                        $out = 'type=asciimath&q=' . rawurlencode( $input );
                } else {
-                       if ( $this->getMathStyle() == 'inlineDisplaystyle' ) {
-                               // default preserve the (broken) layout as it 
was
-                               $out = 'type=inline-TeX&q=' . rawurlencode( 
'{\\displaystyle ' . $input . '}' );
-                       } elseif ( $this->getMathStyle() == 'inline' ) {
-                               $out = 'type=inline-TeX&q=' . rawurlencode( 
$input );
-                       } else {
-                               $out = 'type=tex&q=' . rawurlencode( $input );
-                       }
+                       throw new MWException( 'Internal error: Restbase should 
be used for tex rendering' );
                }
                LoggerFactory::getInstance( 'Math' )->debug( 'Get post data: ' 
. $out );
                return $out;
@@ -322,6 +333,9 @@
         * @return type
         */
        private function getFallbackImageUrl( $noRender = false ) {
+               if ( $this->svgPath ) {
+                       return $this->svgPath;
+               }
                return SpecialPage::getTitleFor( 'MathShowImage' 
)->getLocalURL( array(
                                'hash' => $this->getMd5(),
                                'mode' => $this->getMode(),

-- 
To view, visit https://gerrit.wikimedia.org/r/256940
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ief1b6345c17db41f92684e00233d57240e97599f
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

Reply via email to