jmnote / SimpleMathJax

MediaWiki Extension SimpleMathJax
https://www.mediawiki.org/wiki/Extension:SimpleMathJax
MIT License
30 stars 23 forks source link

compatibility with wikipedia #25

Closed chekanov closed 4 years ago

chekanov commented 4 years ago

Hello,

I've move to the new version of SimpleMathJax (from Oct 18, 2020). It works. As for the previous version, there are some compatibility issues for parsing words-like \N, \R \Mu etc. which are very common in wikipedia. Here is an example https://handwiki.org/wiki/Closure%20operator (red capital N is not parsed)

One solution is to add the following lines:

           $tex = str_replace('\Mu', '\mu', $tex);
            $tex = str_replace('\Q ', '\mathbb{Q} ', $tex);
            $tex = str_replace('\Z ', '\mathbb{Z} ', $tex);
            $tex = str_replace('\0 ', '\mathbb{0} ', $tex);
            $tex = str_replace('\A ', '\mathbb{A} ', $tex);
            $tex = str_replace('\R ', '\mathbb{R} ', $tex);
            $tex = str_replace('\C ', '\mathbb{C} ', $tex);
            $tex = str_replace('\S ', '\mathbb{S} ', $tex);
            $tex = str_replace('\R ', '\mathbb{R} ', $tex);
            $tex = str_replace('\Beta', '\mathbf{B}', $tex);

to renderMath() function, but it is not very elegant since it requires space after the tag (without it, it will corrupt other latex keys). Unfortunately, spaces after \A \C are not common in Wikipedia. It would be useful to add some method to parse such symbols.

jmnote commented 4 years ago

mediawiki-texvc https://docs.mathjax.org/en/v2.7-latest/tex.html#n

The begingroup and mediawiki-texvc TeX extensions haven’t been ported to version 3 yet, but should be in the future.

https://codepen.io/pkra/pen/xGBKYX

jmnote commented 4 years ago

resolved!

https://github.com/jmnote/SimpleMathJax/commit/f4a37981a5a5bcb197d32c02d269d5596e9f9e7c

chekanov commented 4 years ago

Thanks. I'm using your latest version 0.8.0 where this was implemented in ext.SimpleMathJax.js - this work.

jmnote commented 4 years ago

Good! Thanks!