[MediaWiki-commits] [Gerrit] Add asciimath support - change (mediawiki...Math)
Physikerwelt has uploaded a new change for review. https://gerrit.wikimedia.org/r/132491 Change subject: Add asciimath support .. Add asciimath support * introduces a new type called ascii that allows for the ascimath input format * adds option asciimath to Specialpage MathShowImage Change-Id: Icae4c68b42a589e438a0ddac3b3c0071678c0801 --- M MathMathML.php M MathRenderer.php M SpecialMathShowImage.php 3 files changed, 12 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math refs/changes/91/132491/1 diff --git a/MathMathML.php b/MathMathML.php index f2301eb..8e06303 100644 --- a/MathMathML.php +++ b/MathMathML.php @@ -40,6 +40,8 @@ if( $params['type'] == 'pmml' ){ $this-inputType = 'pmml'; $this-setMathml( 'math' . $tex . '/math' ); + }elseif( $params['type'] == 'ascii' ) { + $this-inputType = 'ascii'; } } } @@ -193,6 +195,8 @@ } if ( $this-inputType == 'pmml' || $this-getMode() == MW_MATH_LATEXML $this-getMathml() ) { $out = 'type=mmlq=' . rawurlencode( $this-getMathml() ); + } elseif( $this-inputType == 'ascii' ){ + $out = 'type=asciimathq=' . rawurlencode( $tex ); } else { $out = 'type=texq=' . rawurlencode( $tex ); } diff --git a/MathRenderer.php b/MathRenderer.php index 9508662..3e9ae9d 100644 --- a/MathRenderer.php +++ b/MathRenderer.php @@ -138,7 +138,7 @@ // Support of MathML input (experimental) // Currently support for mode MW_MATH_MATHML only if ( isset( $params['type'] ) ) { - if( $params['type'] == 'pmml' ){ + if( in_array( $params['type'], array( 'pmml', 'ascii' ) ) ) { $mode = MW_MATH_MATHML; } } diff --git a/SpecialMathShowImage.php b/SpecialMathShowImage.php index 8b44197..0f2f4af 100644 --- a/SpecialMathShowImage.php +++ b/SpecialMathShowImage.php @@ -43,12 +43,13 @@ $request = $this-getRequest(); $hash = $request-getText( 'hash', '' ); $tex = $request-getText( 'tex', ''); + $asciimath = $request-getText( 'asciimath', ''); $this-mode = $request-getInt( 'mode', MW_MATH_MATHML ); - if ( $hash === '' $tex === '') { + if ( $hash === '' $tex === '' $asciimath === '' ) { $this-setHeaders( false ); echo $this-printSvgError( 'No Inputhash specified' ); } else { - if ( $tex === ''){ + if ( $tex === '' $asciimath === ''){ switch ( $this-mode ){ case MW_MATH_PNG: $this-renderer = MathTexvc::newFromMd5( $hash ); @@ -70,9 +71,12 @@ } $success = $this-renderer-render(); } - } else { + } elseif ( $asciimath === '' ) { $this-renderer = MathRenderer::getRenderer( $tex , array(), $this-mode); $success = $this-renderer-render(); + } else { + $this-renderer = MathRenderer::getRenderer( $asciimath , array( 'type' = 'ascii' ), $this-mode); + $success = $this-renderer-render(); } if ( $success ) { if ( $this-mode == MW_MATH_PNG ) { -- To view, visit https://gerrit.wikimedia.org/r/132491 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icae4c68b42a589e438a0ddac3b3c0071678c0801 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Math Gerrit-Branch: dev Gerrit-Owner: Physikerwelt w...@physikerwelt.de ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add asciimath support - change (mediawiki...Math)
jenkins-bot has submitted this change and it was merged. Change subject: Add asciimath support .. Add asciimath support * introduces a new type called ascii that allows for the ascimath input format * adds option asciimath to Specialpage MathShowImage Change-Id: Icae4c68b42a589e438a0ddac3b3c0071678c0801 --- M MathMathML.php M MathRenderer.php M SpecialMathShowImage.php 3 files changed, 12 insertions(+), 4 deletions(-) Approvals: Physikerwelt: Looks good to me, approved jenkins-bot: Verified diff --git a/MathMathML.php b/MathMathML.php index f2301eb..8e06303 100644 --- a/MathMathML.php +++ b/MathMathML.php @@ -40,6 +40,8 @@ if( $params['type'] == 'pmml' ){ $this-inputType = 'pmml'; $this-setMathml( 'math' . $tex . '/math' ); + }elseif( $params['type'] == 'ascii' ) { + $this-inputType = 'ascii'; } } } @@ -193,6 +195,8 @@ } if ( $this-inputType == 'pmml' || $this-getMode() == MW_MATH_LATEXML $this-getMathml() ) { $out = 'type=mmlq=' . rawurlencode( $this-getMathml() ); + } elseif( $this-inputType == 'ascii' ){ + $out = 'type=asciimathq=' . rawurlencode( $tex ); } else { $out = 'type=texq=' . rawurlencode( $tex ); } diff --git a/MathRenderer.php b/MathRenderer.php index 9508662..3e9ae9d 100644 --- a/MathRenderer.php +++ b/MathRenderer.php @@ -138,7 +138,7 @@ // Support of MathML input (experimental) // Currently support for mode MW_MATH_MATHML only if ( isset( $params['type'] ) ) { - if( $params['type'] == 'pmml' ){ + if( in_array( $params['type'], array( 'pmml', 'ascii' ) ) ) { $mode = MW_MATH_MATHML; } } diff --git a/SpecialMathShowImage.php b/SpecialMathShowImage.php index 8b44197..0f2f4af 100644 --- a/SpecialMathShowImage.php +++ b/SpecialMathShowImage.php @@ -43,12 +43,13 @@ $request = $this-getRequest(); $hash = $request-getText( 'hash', '' ); $tex = $request-getText( 'tex', ''); + $asciimath = $request-getText( 'asciimath', ''); $this-mode = $request-getInt( 'mode', MW_MATH_MATHML ); - if ( $hash === '' $tex === '') { + if ( $hash === '' $tex === '' $asciimath === '' ) { $this-setHeaders( false ); echo $this-printSvgError( 'No Inputhash specified' ); } else { - if ( $tex === ''){ + if ( $tex === '' $asciimath === ''){ switch ( $this-mode ){ case MW_MATH_PNG: $this-renderer = MathTexvc::newFromMd5( $hash ); @@ -70,9 +71,12 @@ } $success = $this-renderer-render(); } - } else { + } elseif ( $asciimath === '' ) { $this-renderer = MathRenderer::getRenderer( $tex , array(), $this-mode); $success = $this-renderer-render(); + } else { + $this-renderer = MathRenderer::getRenderer( $asciimath , array( 'type' = 'ascii' ), $this-mode); + $success = $this-renderer-render(); } if ( $success ) { if ( $this-mode == MW_MATH_PNG ) { -- To view, visit https://gerrit.wikimedia.org/r/132491 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Icae4c68b42a589e438a0ddac3b3c0071678c0801 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Math Gerrit-Branch: dev Gerrit-Owner: Physikerwelt w...@physikerwelt.de Gerrit-Reviewer: Physikerwelt w...@physikerwelt.de Gerrit-Reviewer: Salix alba r...@singsurf.org Gerrit-Reviewer: TheDJ hartman.w...@gmail.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits