Page MenuHomePhabricator

MathJax error when using backslash as spacing "\ " in front of semicolon, colon or exclamation mark (";", ":", "!")
Closed, ResolvedPublic

Description

I noticed a bug in MediaWiki's MathJax implementation:

When using "\ " to produce some spacing at the end of a formula this only works in front of e.g. dots or commas, but not in front of colons, semicolons or exclamation marks (those were the cases I tested)

Examples (working):
<math>x\ .</math>
<math>x\ ,</math>

Examples (NOT working):
<math>x\ :</math>
<math>x\ ;</math>
<math>x\ !</math>

I tested these TeX commands in LaTeX as well as the online demo of MathJax and it works in both of them, so it seems to be a problem in MediaWiki's implementation of MathJax (or only solved recently in MathJax itself, so the fix didn't make it yet into MediaWiki's code, English Wikipedia is using version 1.22wmf5 (43f93b2) at the time of this writing).


Version: master
Severity: normal

Details

Reference
bz49210

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:52 AM
bzimport added a project: Math.
bzimport set Reference to bz49210.
bzimport added a subscriber: Unknown Object (MLST).

Maybe I should mention that a red backslash is shown in the not working cases instead of producing whitespace.

So the "working" cases seem to produce a space while the "non-working" cases produces a no-break space &#160;. That can be fixed easily by adding a .replace(/\u00A0/g," ") in ConvertMath of wiki2jax, or making the PHP output a space or by fixing bug 35479 and removing the wiki2jax processor.

See also upstream issue https://github.com/mathjax/MathJax/issues/377

@Physikerwelt have you tried what Fred Wang suggested above? (Or do you need a volunteer to code it so that you can land it?)

This is a bad interaction between the math extension (or perhaps MediaWiki more generally, I don't know) and MathJax "bug" 377.

MediaWiki converts <math>x\ :</math> to <math>x\&nbsp; :</math>. While MathJax tolerates &nbsp; in TeX source code, it interprets "\&nbsp;" a TeX command -- invisible hilarity ensues...

You could argue that if MathJax considers &nbsp; a space, then it should tolerate \&nbsp; as well. I'll raise this on our issue tracker (I've reopened the bug).

Peter.

There will be a fix for this in the next MathJax version, see https://github.com/mathjax/MathJax/issues/377

physik wrote:

I'll provide a guide how to cherry pick patches from MathJax to Wikipedia.

Well, it was basically a MathJax bug, but that seems fixed, too (so the bug is really resolved).