Extension talk:Math

Jump to navigation Jump to search

About this board

Previous discussions were archived for 2011–2014 and 2015–2016 on 2016-10-20.

Math extension cannot connect to Restbase.

Tunglinwu (talkcontribs)

解析失敗 (MathML 使用 SVG 或 PNG 備用 (建議用於現代瀏覽器與輔助工具):從伺服器 "http://api.formulasearchengine.com/v1/" 收到無效的回應 ("Math extension cannot connect to Restbase.")。)

http://api.formulasearchengine.com/v1/ is error so many times.

Libattery (talkcontribs)
Libattery (talkcontribs) (talkcontribs) (talkcontribs)

This extension seems dead.

Plasma g (talkcontribs)

I was having the same problem, but by changing a line in LocalSettings.php to

$wgMathFullRestbaseURL= 'https://en.wikipedia.org/api/rest_';

and running "php update.php", the problem went away. So I think the above statement "This extension seems dead" is not the definitive word.

Ciencia Al Poder (talkcontribs)

Pointing $wgMathFullRestbaseURL to wikipedia doesn't seem to work since MediaWiki 1.30 (talkcontribs)

It works for me with MediaWiki 1.30 and LAMP on Ubuntu 18.04 machine

Ciencia Al Poder (talkcontribs)

I later discovered it doesn't work when you have RestBase installed and configured for Visual Editor. Otherwise it should work.

2A02:C7D:8A41:1E00:45F7:8FB3:DA76:93EE (talkcontribs)

Has anyone had this problem again recently because it's suddenly occurred on my wiki? I tried the alternate Restbase Urls but nothing has worked.

Anu8791 (talkcontribs)

We also observed following Math/LaTex rendering to PNG issue while upgraded from MediaWiki 1.30.0 to MediaWiki 1.31.1. But, it's not the issue in earlier version (1.30.0)

(Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle \sigma_1^\prime} and Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":):

Ciencia Al Poder (talkcontribs)

Looks like a problem with wikipedia servers...

Anu8791 (talkcontribs)

We were not using Mathoid Server as a service in earlier MediaWiki v1.30.0. hence the Math/LaTex rendering to PNG was just working fine with LaTex/DVI libs.

but, when we upgraded to this MediaWiki v 1.31.1, the above issue is occurred in the same server environment.

Hence, could you let know how we can bypass the Mathoid Server dependency in this LTS version(MediaWiki 1.31.1) and still we can make Math render working as it's working in MediaWiki 1.30.0 ?

Ciencia Al Poder (talkcontribs)

If you do not install mathoid (and RESTBase), you may use wikipedia's RESTBase, which is what it's using now by default. However, you must ensure PHP is able to connect to wikipedia, which is probably blocked by one of your firewalls or SELinux and that's the error message you're getting

Anu8791 (talkcontribs)

There is security restrictions to connect from our corporate network to the internet. so I unable to test wiki's Restbase

Hence, I have install for the 'methoid' webservice in our local RHEL7 server. I have opted for the dev-config available in the Mathoid package. Now the daemon is running with following pid. But, I see the listening server IP indicates

{"name":"mathoid","hostname":"domainname.com","pid":23788,"level":30,"levelPath":"info","msg":"Worker 23788 listening on","time":"2019-06-06T11:21:19.871Z","v":0}

Could you let know how can we get the appropriate IP that need to configure with below parameters for Math in LocalSettings.php ? I have already checked with 'domainname:port' is still not working for following configuration in LocalSettings.php

wfLoadExtension( 'Math' );

$wgDefaultUserOptions['math'] = 'mathml';

$wgMathMathMLUrl = 'https://domainname.com:10044/';

Ciencia Al Poder (talkcontribs)

I think you also need RESTBase, or at least this is how I have configured (what would be the purpose of RESTBase, after all?). Then $wgMathMathMLUrl points to RESTBase, and you enable the math endpoint in RESTBase to point to mathoid daemon.

Anu8791 (talkcontribs)

Actually RESTBase server implementation along with Mathoid server is required only when you are running such a Huge WIKI.

But for small enterprise wiki with limited memory to render math formulae, we need to install/setup/configure the Mathoid server for WIKI locally in the RHEL7 server followed with below steps.

** First Install Mathoid server pre-requisites packages dependency in RHEL7 server.

# yum update -y [required when need to update latest packages available in the server]

# yum install -y epel-release

# yum install -y gcc-c++ nodejs npm mocha librsvg2-devel pkgconfig git

# yum groupinstall -y 'Development Tools'

** Second, Install Mathoid server in the desired server location.

# cd /var/data/wiki/

# git clone https://github.com/wikimedia/mathoid/

# chown -R apache:wikiadm mathoid

# cd mathoid

# chmod 775 server.js cli.js

** Third, Run the Mathoid server and test

# npm install

# npm test

** Fourth, Add below lines under LocalSettings.php to map mathoid server with mediawiki

$wgMathoidCli = ['/var/data/wiki/mathoid/cli.js', '-c', '/var/data/wiki/mathoid/config.yaml'];

# Below lines required to add in LocalSettings.php to Opt Mathoid server test-config as dependency

[Note. Ensure you already got installed below Math extension compatible with the MediaWiki version]

wfLoadExtension( 'Math' );

$wgMathValidModes[] = 'mathml';

$wgDefaultUserOptions['math'] = 'mathml';

$wgMathMathMLUrl = '';

** Fifth, Change below line is the api interface for MediaWiki in Mathoid server config.yaml

uri: https://Template:Domain/api.php

Restart HTTPD server : # systemctl restart httpd

You are all DONE !

The math formula should render to desired formats in .png ! (talkcontribs)

Any ideas? Same problem here. (talkcontribs)

Can anyone provide a simple php_curl request that Math could make to wiki's Restbase, in order to test whether this is a problem of the code or a problem of the web host?

Thank you!

This post was hidden by Anu8791 (history)
Reply to "Math extension cannot connect to Restbase."

How to use chinese letters within a formula?

S0ring (talkcontribs)

<math display="block"><mtext>&#x9E21;</mtext></math>

<math><mtext>{&#x9E21;} &#x9E21; "Chinese letters"</mtext></math>

These attempts failed with:

Failed to parse (syntax error): {\displaystyle <mtext>&#x9E21;</mtext>}

Failed to parse (syntax error): <mtext>{&#x9E21;} &#x9E21; "Chinese letters"</mtext>

Is there any other way to add chinese letters within a formula?

Debenben (talkcontribs)

You can write , however depending your device the appearance might be broken or not as good as normal text.

S0ring (talkcontribs)

Thanks for the suggestion, I am looking for an elegant solution, but yours won't work either:


Failed to parse (lexing error): 鸡

Debenben (talkcontribs)

You have to write it inside \text or \mbox like <math>\text{鸡}</math>: . If you want to help making it look better, you could test the inline svg proposal here phab:T195861 and share your experience or push for alternative rendering solutions.

S0ring (talkcontribs)

Thanks again! It works in MathML render mode, but fails in PNG images render mode... (just toggle in Preferences -> Math) with the error:

Failed to parse (PNG conversion failed; check for correct installation of latex and dvipng (or dvips + gs + convert)): \text{鸡}

All packages are installed, the diagnostics passed (Manual:$wgUseTeX#Diagnostics) and other formulas correctly shown.

S0ring (talkcontribs)

This kind of Unicode rendering issue was reported before in bug 798 some Latin letters are still not supported, including those that include multiple diacritics (as well as letters from other languages i.e. chinese).

For ex. this is working:


and this not working:


One workaround is to switch the rendering mode from PNG to MathML:

<math forcemathmode="mathml">\text{²³°´µ}</math>

Is this a known problem?

Debenben (talkcontribs)

There are a lot of rendering issues with the current setup, but you must be referring to texvc, which is not used in mediawiki anymore and I have not seen anybody offering to maintain it.

If you are using mediawiki on your own wiki, you can just use Mathjax and the problems are gone, Mathml unfortunately only works with firefox.

S0ring (talkcontribs)
Debenben (talkcontribs)

I am not familiar with the MathJax extension. You can use the SimpleMathJax extension or no extension at all. The SimpleMathJax extension is only a few lines of javascript. You could add something like https://de.wikipedia.org/wiki/Benutzer:Debenben/MathJax.js to the page MediaWiki:Common.js in your wiki if you want $ $ and other LaTeX delimiters like math.stackexchange or scholarpedia use, otherwise just customize it according to the MathJax documentation http://docs.mathjax.org/en/latest/

S0ring (talkcontribs)

After I saved your script to my Common.js it had no effect, no rendering occured. With the SimpleMathJax extension enabled and the HTML text from https://codepen.io/pkra/pen/pgOyaw (1) everything looks fine, except the first two formulas:

$$ f(u_1) = f(u_0) + hf'(u_0)+{h^2\over 2!}f(u_0) + \cdots + {h^{n+1}\over (n+1)!}f^{(n+1)}(u_0) + o(h^{n+1}). $$

$$ f(u) = f'(u) = f(u) = \cdots = f^{(n)}(u) = 0;\quad f^{(n+1)}(u) \ne 0. $$

(1) Note. I had to add $wgSmjInlineMath = [ ["$","$"] ]; to LocalSettings.php, as well as to remove from the HTML text the whitespaces before any $$.

Reply to "How to use chinese letters within a formula?"

Math extension return a fatal exception of type "Wikimedia\Rdbms\DBQueryError

Gdwikimeca (talkcontribs)


I have install the math extension (on mediawiki 1.31) but when i try to add a <math> balise in a page, i have this screen :

MediaWiki internal error.

Original exception: [W-I969TjGCIAAAU3aBUAAAAe] 2018-11-19 04:37:00: Fatal exception of type "Wikimedia\Rdbms\DBQueryError"

Exception caught inside exception handler.

Set $wgShowExceptionDetails = true; and $wgShowDBErrorBacktrace = true; at the bottom of LocalSettings.php to show detailed debugging information.

When i try to add $wgShowExceptionDetails = true; and $wgShowDBErrorBacktrace = true; at the bottom of LocalSettings.php, i have a blank page at the same place.

What can i do ?

URL of my wiki : www.wikimeca.org/wikimeca_1_31/

S0ring (talkcontribs)
Reply to "Math extension return a fatal exception of type "Wikimedia\Rdbms\DBQueryError"

What additional Software has to be installed

2A02:2028:C1C0:7B00:4028:FF6A:FAE5:F1C8 (talkcontribs)

I want to install a mediawiki (version >1.29 ) on a Linux system. Now, I'm not sure what kind of addition software I must install on my system; I'have really problems to understand the text on this page. Here are some questions I have:

do I have to install Texvc?

What is the relation between mathoid and Texvc?

What kind of software is already in the standard package und kind of additional services of the systems are used (which had to be installed by administrator before) the activation of the math extension?

Further I'm interested to install a mediawiki with a math-Extension (the same that is used by Wikipedia) in Synology NAS as Docker-Container. Are there already binaries of MediaWiki available which include the Math-Extension?

Nbrouard (talkcontribs)

I gave up with Texvc and mathoid. Instead our server are using Extension:SimpleMathJax . Simple and very efficient, but not from the Wikimedia Foundation. Nothing else to be installed but the extension.

Reply to "What additional Software has to be installed" (talkcontribs)

esta extension a linstalarse muestra error en la base de datos exception de tipo grave MWexception y no se puede configurar asi que arreglenla o archiven la extension

Reply to "failed"

https://wikimedia.org/api/rest_v1/ returning code 0 and not 200

Nyet (talkcontribs)

Using mediawiki 1.31 and Math extension REL_31

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":)

If i change it to allow code 0:

diff --git a/MathRestbaseInterface.php b/MathRestbaseInterface.php
 index 2dc5d45..5355177 100644
 --- a/MathRestbaseInterface.php
 +++ b/MathRestbaseInterface.php
 @@ -364,7 +364,7 @@ class MathRestbaseInterface {
         public function evaluateRestbaseCheckResponse( $response ) {
                 $json = json_decode( $response['body'] );
 -               if ( $response['code'] === 200 ) {
 +               if ( $response['code'] === 200 || $response['code'] === 0) {
                         $headers = $response['headers'];
                         $this->hash = $headers['x-resource-location'];
                         $this->success = $json->success;

I get

Failed to parse (Conversion error. Server ("https://wikimedia.org/api/rest_") reported: "Cannot get mml. Server problem.")

Is the RESTBase server down?

Jdforrester (WMF) (talkcontribs)

Is the RESTBase server down?

No, but maybe the Mathoid service is? (talkcontribs)

My Math extension have been failing with the same error since a few days. (talkcontribs)

I've had this problem too. After some debugging, it appears that PHP's curl was refusing the SSL certificate of https://wikimedia.org/api/rest_ . I downloaded a cacert.pem file and pointed edited the php.ini to point to under under variable curl.cainfo and openssl.cafile. This fixed my problem.


curl.cainfo = "C:\PHP7\cacert.pem"



J Ra Rose (talkcontribs)

Since today I have the same issue. Where did you download the cacert.pem file?

2001:B68:16:80:921B:EFF:FE13:C9A2 (talkcontribs)

We have the same issue as OP. Adding certificates to php.ini did not help.

2001:B68:16:80:921B:EFF:FE13:C9A2 (talkcontribs)

Our problems started after a system update. The issue is probably caused by changes in other packages.

2001:B68:16:80:921B:EFF:FE13:C9A2 (talkcontribs)
Reply to "https://wikimedia.org/api/rest_v1/ returning code 0 and not 200"
Fokebox (talkcontribs)

Hi everyone. I use Math extension and besically everything is fine. But I have found out small bug when I see formulas at IPad Safari browser - it doesn't display cyrillic symbols when I put them throgh \text{киррилица}

Physikerwelt (talkcontribs)

Lets test here:

Physikerwelt (talkcontribs)

Do you have installed the native MathMl extension? Otherwise you will get a [svg image](https://wikimedia.org/api/rest_v1/media/math/render/svg/e80f165a0d58c6514c476f7e46ac8c9e8a544e3d) with inline text

 1 <svg xmlns:xlink="http://www.w3.org/1999/xlink" width="12.75ex" height="3.343ex" style="vertical-align: -1.171ex;" viewBox="0 -934.9 5489.6 1439.2" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" aria-labelledby="MathJax-SVG-1-Title">
 2 <title id="MathJax-SVG-1-Title">{\displaystyle {\text{киррилица}}}</title>
 3 <defs aria-hidden="true"></defs>
 4 <g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)" aria-hidden="true">
 5 <text font-family="monospace" stroke="none" transform="scale(71.759) matrix(1 0 0 -1 0 0)">к</text>
 6 <g transform="translate(609,0)">
 7 <text font-family="monospace" stroke="none" transform="scale(71.759) matrix(1 0 0 -1 0 0)">и</text>
 8 </g>
 9 <g transform="translate(1219,0)">
10 <text font-family="monospace" stroke="none" transform="scale(71.759) matrix(1 0 0 -1 0 0)">р</text>
11 </g>
12 <g transform="translate(1829,0)">
13 <text font-family="monospace" stroke="none" transform="scale(71.759) matrix(1 0 0 -1 0 0)">р</text>
14 </g>
15 <g transform="translate(2439,0)">
16 <text font-family="monospace" stroke="none" transform="scale(71.759) matrix(1 0 0 -1 0 0)">и</text>
17 </g>
18 <g transform="translate(3049,0)">
19 <text font-family="monospace" stroke="none" transform="scale(71.759) matrix(1 0 0 -1 0 0)">л</text>
20 </g>
21 <g transform="translate(3659,0)">
22 <text font-family="monospace" stroke="none" transform="scale(71.759) matrix(1 0 0 -1 0 0)">и</text>
23 </g>
24 <g transform="translate(4269,0)">
25 <text font-family="monospace" stroke="none" transform="scale(71.759) matrix(1 0 0 -1 0 0)">ц</text>
26 </g>
27 <g transform="translate(4879,0)">
28 <text font-family="monospace" stroke="none" transform="scale(71.759) matrix(1 0 0 -1 0 0)">а</text>
29 </g>
30 </g>
31 </svg>

It depends on the fonts installed on your iPad what you actually see? @Pkra What do you think: Should we try to convert all text elements to paths or leave that to the browser?

Fokebox (talkcontribs)

<chem>m_\text{теор}(CH3COOC2H5) = n(CH3COOC2H5)\cdot M(CH3COOC2H5) = 0,5\text{моль} \cdot 88 \text{г/моль} = 44 \text{г}</chem>


So there isn’t russian text included to the formula on ipad ... on desktop it is fine!

Reply to "Bug at Math extension"
Prh47bridge (talkcontribs)

Proceeding with this very slowly as time allows!

When Mathoid is running I try to test it using:

curl -d 'q=E=mc^2' localhost:10044

as per the manual. Instead of the expected result I get:

{"status":500,"type":"internal_error","title":"TypeError","detail":"Cannot read property 'semantic' of undefined","method":"POST","uri":"/","success":false,"log":"Cannot read property 'semantic' of undefined","error":""}

My log shows:

{"name":"mathoid","hostname":"ns3299566.ip-5-135-154.eu","pid":1442,"level":50,"message":"500: internal_error","stack":"TypeError: Cannot read property 'semantic' of undefined\n    at srePostProcessor (/usr/lib/node_modules/mathoid/lib/math.js:118:16)\n    at BBPromise.then.then (/usr/lib/node_modules/mathoid/lib/math.js:299:20)\n    at tryCatcher (/usr/lib/node_modules/mathoid/node_modules/bluebird/js/release/util.js:16:23)\n    at Promise._settlePromiseFromHandler (/usr/lib/node_modules/mathoid/node_modules/bluebird/js/release/promise.js:512:31)\n    at Promise._settlePromise (/usr/lib/node_modules/mathoid/node_modules/bluebird/js/release/promise.js:569:18)\n    at Promise._settlePromise0 (/usr/lib/node_modules/mathoid/node_modules/bluebird/js/release/promise.js:614:10)\n    at Promise._settlePromises (/usr/lib/node_modules/mathoid/node_modules/bluebird/js/release/promise.js:693:18)\n    at Async._drainQueue (/usr/lib/node_modules/mathoid/node_modules/bluebird/js/release/async.js:133:16)\n    at Async._drainQueues (/usr/lib/node_modules/mathoid/node_modules/bluebird/js/release/async.js:143:10)\n    at Immediate.Async.drainQueues (/usr/lib/node_modules/mathoid/node_modules/bluebird/js/release/async.js:17:14)\n    at runCallback (timers.js:789:20)\n    at tryOnImmediate (timers.js:751:5)\n    at processImmediate [as _immediateCallback] (timers.js:722:5)","status":500,"type":"internal_error","detail":"Cannot read property 'semantic' of undefined","levelPath":"error/500","request_id":"06e8ae51-0c1c-11e8-a75a-adde2b46ba51","request":{"url":"/","headers":{"user-agent":"curl/7.47.0","content-length":"8","content-type":"application/x-www-form-urlencoded","x-request-id":"06e8ae51-0c1c-11e8-a75a-adde2b46ba51"},"method":"POST","params":{"0":"/"},"query":{},"remoteAddress":"","remotePort":53513},"msg":"500: internal_error","time":"2018-02-07T15:31:55.216Z","v":0}

As previously, nodejs version is 8.9.4.

Any ideas?

Reply to "Mathoid failing"
Prh47bridge (talkcontribs)

I'm currently getting the following error:

{"name":"mathoid","hostname":"ns3299566.ip-5-135-154.eu","pid":23337,"level":60,"err":{"message":"Cannot read property 'displayMessages' of undefined","name":"TypeError","stack":"TypeError: Cannot read property 'displayMessages' of undefined\n    at Object.exports.config (/usr/lib/node_modules/mathoid/node_modules/mathoid-mathjax-node/lib/main.js:864:14)\n    at initApp (/usr/lib/node_modules/mathoid/app.js:149:11)\n    at module.exports (/usr/lib/node_modules/mathoid/app.js:254:12)\n    at _requireModule.then (/usr/lib/node_modules/mathoid/node_modules/service-runner/lib/worker.js:165:80)\n    at tryCatcher (/usr/lib/node_modules/mathoid/node_modules/bluebird/js/release/util.js:16:23)\n    at Promise._settlePromiseFromHandler (/usr/lib/node_modules/mathoid/node_modules/bluebird/js/release/promise.js:512:31)\n    at Promise._settlePromise (/usr/lib/node_modules/mathoid/node_modules/bluebird/js/release/promise.js:569:18)\n    at Promise._settlePromiseCtx (/usr/lib/node_modules/mathoid/node_modules/bluebird/js/release/promise.js:606:10)\n    at Async._drainQueue (/usr/lib/node_modules/mathoid/node_modules/bluebird/js/release/async.js:138:12)\n    at Async._drainQueues (/usr/lib/node_modules/mathoid/node_modules/bluebird/js/release/async.js:143:10)\n    at Immediate.Async.drainQueues (/usr/lib/node_modules/mathoid/node_modules/bluebird/js/release/async.js:17:14)\n    at runCallback (timers.js:789:20)\n    at tryOnImmediate (timers.js:751:5)\n    at processImmediate [as _immediateCallback] (timers.js:722:5)","levelPath":"fatal/service-runner/worker"},"msg":"Cannot read property 'displayMessages' of undefined","time":"2018-01-16T10:44:55.156Z","v":0}

Nodejs version is 8.9.4

Any ideas? (talkcontribs)

I added the following to my config, under mathoid conf section. It seems that the default mj_config is not populated for some reason.


extensions: "TeX/color,TeX/mediawiki-texvc,TeX/mhchem"

Prh47bridge (talkcontribs)

That worked. Thanks. Now to figure out how to set it up as a service and whatever else I need to do to get it running properly!

Reply to "Trying to get Mathoid to run"
Kaganer (talkcontribs)

These is needed?

Reply to "Extension:Math/newFeatures and listed subpages"