Chemistry formulae ignore significant spaces, opposite to LateX source
Open, Needs TriagePublic

Description

When using the <chem> tag to write a formula like "CO2 + C -> 2 CO" , the plus sign ends up as superscript to CO2, as if it was a charge (reported on it.wp). It's the first formula you see when you open the editor to add one.

And also: 2.5 should give 2 * 5, and it works. But 2 . 5, with spaces, should give 2.5, and it doesn't, so there is no way to add decimal fractions.

Elitre created this task.Mar 6 2017, 6:40 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 6 2017, 6:40 PM

And what's wrong?

Dvorapa added a subscriber: Dvorapa.Mar 6 2017, 8:25 PM
Elitre added a comment.Mar 7 2017, 3:07 PM

That the plus sign on the line has a meaning, while the plus sign displayed as superscript means something else?

Of course. The question is why do you expect something else than superscript? This is the way how it works. If you need it different, use "{CO2} + C -> 2 CO".

@IKhitron If there is a space between CO2 and +, I would expect + not being a superscript. If there isn't a space between CO2 and +, I would expect + to be a superscript.

I see. What's the result in LateX? It must be the same.

Elitre added a comment.Mar 7 2017, 3:47 PM

I guess I'm expecting something different because of the spaces (I'm writing it CO2 + , not CO2+).
I would have never thought about using parentheses. If anyone else actually writing and understanding formulas would naturally know that, please decline this task.

Again, we need to compare to LateX. If it's the same - it's their problem, not our. If it isn't - there is computation bug here.

Dvorapa added a comment.EditedMar 7 2017, 4:09 PM

I agree with @IKhitron, but I can't help, I used to use LateX a long time ago.

If it behaves the same way like LateX, the predefined formula is what should be fixed. If it doesn't behave like LateX, the problem is in a computation as @IKhitron pointed out

Dvorapa added a comment.EditedMar 7 2017, 4:19 PM

But I think it is a wrong behavior, because if I write CO2+, it changes to "CO²+". I believe these two are just switched in the computation. The last predefined formula is broken too, in the opposite way.

IKhitron added a comment.EditedMar 7 2017, 4:27 PM

Well, checked in LateX \ce. There is a bug, indeed. Something ignores spaces in the parsing. It can be also in other example:
2.5 should give 2 * 5, and it works. But 2 . 5, with spaces, should give 2.5, and it doesn't, so there is no way to add decimal fractions.

IKhitron renamed this task from Formula doesn't look right to Chemistry formulae ignore significant spaces, opposite to LateX source.Mar 7 2017, 4:29 PM
IKhitron edited projects, added Math; removed VisualEditor.
IKhitron updated the task description. (Show Details)
IKhitron added a project: Mathoid.
Elitre added a comment.Mar 7 2017, 6:21 PM

(Is LateX the only relevant comparison, BTW?)

Math markup goes inside <math>...</math>. Chemistry markup goes inside <math chem>...</math> or <chem>...</chem>. All these tags use TeX.
The TeX code has to be put literally: MediaWiki templates, predefined templates, and parameters cannot be used within math tags: pairs of double braces are ignored and "#" gives an error message. However, math tags work in the then and else part of #if, etc

Got some feedback from fr.wp.