jmnote / simplemathjax Goto Github PK
View Code? Open in Web Editor NEWMediaWiki Extension SimpleMathJax
Home Page: https://www.mediawiki.org/wiki/Extension:SimpleMathJax
License: MIT License
MediaWiki Extension SimpleMathJax
Home Page: https://www.mediawiki.org/wiki/Extension:SimpleMathJax
License: MIT License
The title is saying it all. The script isn't even getting loaded if mediawiki doesn't see a <math>
tag.
This was resolved as this:
$tex = str_replace('\lang', '\langle ', $tex); $tex = str_replace('\rang', '\rangle ', $tex);
inside renderMath() of SimpleMathJax_body.php. This ticket can be closed
Hello!
I've just installed SimpleMathJax and tested it by inserting: <math>E=mc^2</math>
On Chrome (OSX) it renders correctly.
However, on firefox (OSX) it displays the formula three times: pic
The second two renditions seem to be one font size smaller than the first.
Is there any way to fix this?
π
We recently upgrade from Mediawiki 1.37 to 1.38. SimpleMathJax
is causing an issue in ParserOutput
extension:
Deprecated: Use of ParserOutput::addModules with non-array argument was deprecated in MediaWiki 1.38.
[Called from SimpleMathJaxHooks::renderTex in /var/www/html/w/extensions/SimpleMathJax/SimpleMathJaxHooks.php
at line 34] in /var/www/html/w/includes/debug/MWDebug.php on line 377
This seems to fix it:
# git diff
diff --git a/SimpleMathJaxHooks.php b/SimpleMathJaxHooks.php
index 71cc9488..e794a508
--- a/SimpleMathJaxHooks.php
+++ b/SimpleMathJaxHooks.php
@@ -31,8 +31,8 @@ class SimpleMathJaxHooks {
}
private static function renderTex($tex, $parser) {
- $parser->getOutput()->addModules( 'ext.SimpleMathJax' );
- $parser->getOutput()->addModules( 'ext.SimpleMathJax.mobile' ); // For MobileFrontend
+ $parser->getOutput()->addModules( [ 'ext.SimpleMathJax' ] );
+ $parser->getOutput()->addModules( [ 'ext.SimpleMathJax.mobile' ] ); // For MobileFrontend
$attributes = [ "style" => "opacity:.5" ];
Hooks::run( "SimpleMathJaxAttributes", [ &$attributes, $tex ] );
$element = Html::Element( "span", $attributes, "[math]{$tex}[/math]" );
Here's the issue on our wiki:
Thanks for your extension, it's working perfect, but there are some problems in mobile version. I use Extension:MobileFrontend and math formulas are not displayed.
Is it possible to solve this problem?
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.
Suggest to add
T: "{\mathbb{T}}",
in resources/ext.SimpleMathJax.js to make it consistent with Wikipedia (it was checked on HandwIki)
I am using 0.8.2 on MW 1.36.1 with MobileFrontend 2.3.0 (f78273c) and MinervaNeue (20711d8) from May 28th 2021. On pages rendered with MinervaNeue the JS is not included at all and the expressions are not rendered.
Prior to this I used 0.7.4 with 1.35.2 which worked fine.
I encounter a console output:
PHP Deprecated: Registering handler for ParserFirstCallInit before MediaWiki bootstrap complete was deprecated in MediaWiki 1.35 [Called from SimpleMathJax::onRegistration in /MY_MW_PATH/extensions/SimpleMathJax/SimpleMathJax_body.php at line 6] in /srv/femiwiki.com/includes/debug/MWDebug.php on line 430
Thanks.
Hi,
SimpleMathJax is a great tool. We use it for the math encyclopedia called HandWiki, replacing the server-side math parsing with the client-side "SimpleMathJax". We see some pages where SimpleMathJax failed to parse equations. For example, this page imported from Wikipedia:
https://handwiki.org/wiki/Kalman_filter
has a few yellow boxes "Missing argument for \mathbf". Is it possible to fix this?
There are more problematic pages with equations like this that indicate that SimpleMathJax is 100% replacement for what is used by Wikipedia. But we are not sure how automatically catch such pages with SimpleMathJax parsing problems.
See https://www.mediawiki.org/wiki/Topic:V4gkf5eepqignt19 for details.
Suggesting to use that thread for further discussion.
I am trying to load a set of formulas on https://www.rieselprime.de/ziki/Math_rendering, which uses this package. It loads fine with the base browser configuration (Kubuntu 19.10, Firefox 78), but when loaded using Firefox's Native MathML add-on, it only displays TeX within [math]
tags. For example, the first row in the large table reads [math]\dot{a}, \ddot{a}, \acute{a}, \grave{a}[/math]
. The Math MediaWiki extension does not have this problem.
I've got SimpleMathJax running on an internal wiki, and typesetting an equation via
:<math>
\frac{\partial^2}{\partial t^2} \nabla \cdot \mathbf{E} = 4 \pi \frac{\partial}{\partial t} \nabla \cdot \mathbf{J}
</math>
sets the equation on the page in inline mode inline mode (you can tell by the relatively small derivative symbols). Is there a convenient way to set it in LaTeX's display style instead?
This is kind of unusual and it may be related to another component in our stack. My apologies in advance if that is the case.
The Crypto++ wiki uses SimpleMathJax for math markup on occasion. As an example, here is our Elliptic Curve Digital Signature Algorithm page:
Now here is the weird thing... IF I click the Page tab or the Read tab, then the math symbols go missing. IF I click the Reload button then the math symbols appear again. Below, the tabs are highlighted in blue, the missing symbols are highlighted in red, and the reload is highlighted in green.
When the math symbols fail to render it looks like the HTML is present:
Our stack includes a CentOS 7 Virtual Machine from GoDaddy. The MediaWiki information can be found at Special:Version, and it includes MW 1.30, PHP 7.1 and MySQL 5.5. I keep everything fully patched (the best I can).
The browser is configured to send Do Not Track with requests, and it does not accept third party cookies. This may happen on other platforms like Linux and other browsers like Chrome. I don't use browsers like IE or Chrome so I can't say for sure.
I'm not sure where to begin to troubleshoot the issue. If there is a mailing list to discuss issues, then please point it out. I don't like polluting issue trackers with opening discussions of problems.
Any help in learning the cause of the problem would be appreciated.
I think we ruled out the EFF's HTTPS Everywhere at Issue 14654, mathjax.org may need ruleset updated.
The process needs to be described thoroughly as it seems to be pretty involved. modules
does not contain any submodules referencing mathjax.
Thanks for your extension, it worked fine (I used SimpleMathjax 0.7.4), but some errors have appeared in MW 1.36:
Deprecated: Registering handler for ParserFirstCallInit before MediaWiki bootstrap complete was deprecated in MediaWiki 1.35 [Called from SimpleMathJax::onRegistration in ...\extensions\SimpleMathJax\SimpleMathJax_body.php at line 6] in ...\includes\debug\MWDebug.php on line 376
I tried to install new version 0.8.2, but there is a problem: new version of SimpleMathjax works only with mathjax 3. Mathjax 3 doesn't support some commands (for example the line break(\) is not work).
Is it possible to integrate support of Mathjax 2 in SimpleMathjax 0.8.2? Or may be make some changes in SimpleMathjax 0.7.4 for compatability with MW 1.36?
P.S. I found one issue with local version of Mathjax. I tried to set $wgSmjUseCDN = false;
in the LocalSettings.php, but MathJax still loaded from CDN. I changed string №128 in ext.SimpleMathJax.js and MathJax became loading from local copy.
I changed script.src = mw.config.get('wgSmjUseCdn')
toscript.src = mw.config.get('wgSmjUseCDN')
.
Error: "Unknown dependency: ext.SmjCDN.mobile"
jQuery 3
https://zetawiki.com/wiki/특수:버전:9
startUp https://zetawiki.com/w/load.php?debug=false&lang=ko&modules=startup&only=scripts&skin=zetaview:20
onload https://zetawiki.com/w/load.php?debug=false&lang=ko&modules=startup&only=scripts&skin=zetaview:21
제타위키나 리브레 위키 등 simplemathjax를 사용하는 위키에서 의존성 오류가 출력됩니다.
The Math extension provides integration with Visual Editor through a lot of JS code. Would it be possible to integrate SimpleMathJax the same way (potentially requiring coordinated development and turning all that code into another library?)
Alternatively, should there be updated documentation about how SimpleMathJax does/doesn't work in VisualEditor environments (including wikis that use VEForAll to put VisualEditor into forms)?
I am getting the following error message "Undefined control sequence" for the following:
\geqslant
\leqslant
\because
\varpropto
\therefore
\implies
\impliedby
I am not sure if this is something I am doing wrong?
I am currently using SimpleMathJax v. 0.73 on MediaWiki 1.31
I have successfully used these terms in the past with the 2015 versions on MediaWiki 1.28
Thanks a lot for your extension! It works great, but there is a problem with numeration of formulas.
I use Mediawiki 1.31.1. I tried to set a number of the formula and wrote this code:
\begin{equation} t^n-1\ge{n\cdot(t-1)}. \end{equation}
But number was absent. I have found the cause. The extension uses tags "math" for inlineMath. But there are no tags for displayMath. So I added additional tags (dmath) for displayed equations.
I added new variable (SmjDisplayMath) to extension.json:
"config": {
"SmjSize": 100,
"SmjUseCDN": true,
"SmjUseChem": true,
"SmjInlineMath": [],
"SmjDisplayMath": []
},
Then I changed SimpleMathJax_body.php. I wrote some code for new parameter SmjDisplayMath.
public static function setup( Parser $parser ) {
global $wgOut, $wgSmjUseCDN, $wgSmjSize, $wgSmjUseChem, $wgSmjInlineMath, $wgSmjDisplayMath;$wgOut->addModules( $wgSmjUseCDN ? 'ext.SmjCDN' : 'ext.SmjLocal' ); $wgOut->addJsConfigVars( 'wgSmjSize', $wgSmjSize ); $wgOut->addJsConfigVars( 'wgSmjUseChem', $wgSmjUseChem ); $wgSmjInlineMath[] = ["[math]","[/math]"]; $wgSmjDisplayMath[] = ["[dmath]","[/dmath]"]; $wgOut->addJsConfigVars( 'wgSmjInlineMath', $wgSmjInlineMath ); $wgOut->addJsConfigVars( 'wgSmjDisplayMath', $wgSmjDisplayMath ); $parser->setHook( 'math', __CLASS__ . '::renderMath' ); $parser->setHook( 'dmath', __CLASS__ . '::renderDMath' ); if( $wgSmjUseChem ) $parser->setHook( 'chem', __CLASS__ . '::renderChem' );
}
public static function renderDMath($tex, array $args, Parser $parser, PPFrame $frame ) {
$tex = str_replace('>', ';', $tex);
$tex = str_replace('<', '\lt ', $tex);
$tex = str_replace('>', '\gt ', $tex);
return self::renderDTex($tex, $parser);
}
private static function renderDTex($tex, $parser) {
return ["[dmath]${tex}[/dmath]", 'markerType'=>'nowiki'];
}
And in the file ext.SmjCDN.js I changed several lines:
tex2jax: { displayMath: mw.config.get('wgSmjDisplayMath'),
inlineMath: mw.config.get('wgSmjInlineMath') }
MathJax.Hub.Queue(function() {
$(".MathJax").parent().css('opacity',1);
$(".MathJax_Display").parent().css('opacity',1);
});
MathJax.Hub.Config({ TeX: { equationNumbers: {autoNumber: "AMS"} } });
This code worked correctly. But I am not a programmer, so my code is not optimal. I think my code is terrible from a programmer's point of view :) May be you can add new tag to the code of your extension? I think that new tag is useful for displaying math.
$wgSmjEnableMenu is missed since v0.8.0.
It would be just a mistake during migrating from modules/ext.SmjCDN.js to resources/ext.SimpleMathJax.js.
When using VisualEditor to render the page, the math block's rendering is changed to
This is fine, since VE provides the user with a dialog to edit the math if they click on the box.
After saving the page, whether the math is changed or not, the un-rendered grey box of TeX-formatted math remains.
SimpleMathJax should use whatever methods it can (I imagine there is a VE hook somewhere) to re-render the math after a page save.
https://www.mathjax.org/cdn-shutting-down/
Please update to alternative CDN providers, thanks !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.