# AsciiMath Power issue, only letters f and g #431

Closed
opened this issue Apr 9, 2013 · 17 comments

Projects
None yet
5 participants

### frans-morville commented Apr 9, 2013

 Extremely happy with Mathjax!! Thanks! This looks very strange, see position of minus sign. 2^e-3 yields 2^e-3 2^f-3 yields 2^f-3 2^g-3 yields 2^g-3 2^h-3 yields 2^h-3
Contributor

### fred-wang commented Apr 9, 2013

 I can reproduce the bug with http://www1.chapman.edu/~jipsen/mathml/asciimathdemo.html so that's a bug in ASCIIMathML.
Member

### dpvc commented Apr 9, 2013

 As Fred points out, this is an AsciiMath issue more than a MathJax one, as that is how AsciiMath interprets those expressions. On the other hand, you can use something like 2^{f}-3 and 2^{g}-3 to get the results that you want.
Author

### frans-morville commented Apr 13, 2013

 Thanks for the workaround. I use Mathjax for exercises with large quantities of output from CAS programs, therefore it is a pity, that while 99% of formulas display as expected, there are a few exceptions. Yesterday I stumbled on an other exception, this time with the letter o. Try to display o+p o and + go together in a "plus-in-circle" sign. If there is no spaces in the formula, I think this should be avoided. Is AsciiMath still maintained and developed? On the Google group a correction has been suggested by David Lippman. https://groups.google.com/forum/?fromgroups=#!topic/asciimath/6MatvJUvaGY But there does not seem to be much activity. Frans Morville
Member

### dpvc commented Apr 13, 2013

 I'm not sure if Peter Jipsen has been updating AsciiMath or not. While we are not prepared to modify AsciiMath, it is table driven, and since MathJax exposes the symbol table, you can modify AsciiMath's behavior in that way. For example, you could remove the o+ operator entirely. here are a handful of others that might give you trouble, but I don't think there are too many. You cold probably also modify the f and g definitions to make them not act as functions (which is why the minus sign is in the wrong place in your original examples). Here's some code to remove the o+:   If you put this before the script that loads MathJax.js itself, that should remove the unwanted operator. (It turns out it is the 44-th entry in the symbols table.) An alternative would be to use a prefilter for the AsciiMath input jax, but the approach above seems easier.

### drlippman commented Jan 23, 2014

 Since Peter hasn't been updating AsciiMath, I've been updating the version with image fallback support. I'm going to be modifying that version to address this issue. If you want to mirror the change, the corresponding alteration would be on line 736 of the input jax, changing if (st=="^" || st=="_" || st=="/" || st=="|" || st==",") {  to if (st=="^" || st=="_" || st=="/" || st=="|" || st=="," || (symbol.input.length==1 && st!="(")) {  That should exclude f and g from getting the function treatment unless explicitly followed by parens.

Member

### pkra commented Jan 23, 2014

 Thanks, @drlippman ! I'm re-opening this.

### drlippman commented Feb 5, 2014

 Ack! Don't use that code I posted. It totally breaks handling of negative numbers. Let's do it right, and just address the real issue: if (st=="^" || st=="_" || st=="/" || st=="|" || st=="," || ((symbol.input=='f' || symbol.input=='g') && st!="(")) { 
Member

### dpvc commented Feb 12, 2014

 I think Lippman's if (st !== "(" && st !== "[") {  is better, but I'm not prepared to modify the AsciiMath code from what AsciiMath does at this level, especially when there are reasonable work-arounds. While we may not like it, this is what AsciiMath does, and MathJax's AsciiMath input should remain consistent with actual AsciiMath. This is why I closed the issue originally. Of course, you can modify the input table, similarly to how I described for o+, but this time you could remove the definitions of f and g as functions in order to overcome this problem. Or you could use a pre-filter to replace ^f and ^g by ^{f} and ^{g} (though you might want to be more careful about what follows the f or g).

Member

### pkra commented Feb 12, 2014

 I suppose if asciimath was modified upstream, we would pull in the changes though.
Member

### dpvc commented Feb 12, 2014

 Yes, we could do that.

### drlippman commented Feb 13, 2014

 I don't love this fix (even though I suggested it last year) if (st !== "(" && st !== "[") { Mainly because while I personally think everyone should use parens when they write functions, not everyone does in the math world, and it is nice for sinx/cosx to be interpreted as (sin x)/(cos x). Using that fix, it gets interpreted as sin (x/cos) x, which is pretty ugly. Out of curiosity, what is considered upstream for AsciiMath?
Member

### pkra commented Feb 13, 2014

 Out of curiosity, what is considered upstream for AsciiMath? Good question. I guess it would help if somebody (you? Peter Jipsen?) would put the original script up on a VCS. I think we'd be happy to create a repository as part of the MathJax organization, i.e., at https://github.com/mathjax/

Closed

Closed

Member

### pkra commented Aug 23, 2014

 Has this been fixed upstream?

### drlippman commented Aug 23, 2014

 Yes, this was fixed in commit dcfd1399
Author

### frans-morville commented Aug 23, 2014

 Do I understand it correctly, that my original issue with f and g has been fixed, and after an update in the near future 2^g-3 will be rendered in the same way as 2^h-3 ? Thank you for all that work! As a math teacher in secondary school in Denmark I see a need somewhat broader than this original problem. Students are used to CAS in calculators and computer programs such as Geogebra, TI Nspire, Maple etc. and they may be used to spreadsheets such as Excel. Simple formulas using letters, numbers, parentheses, + - * / ^ and < > operators can be entered in pretty much the same way in these tools. The syntax is a bit different from the notation of Asciimath: Names of variables or functions can consist of several letters. If you copy cos(A)=adjacent/hypotenuse in the CAS part of Geogebra, Maple or a TI program/calculator the right side will be rendered nicely as you would expect: a horisontal line between adjacent and hypotenuse. Functions need parantheses, cosx or cos x will not be understood. It would be very nice, if teachers and students could easily communicate using such an additional "dialect" of MathJax/AsciiMath, where students can enter formulas, as they are used to do in Geogebra, Excel etc. This syntax used in the CAS programs is probably simpler than the one in AsciiMath. The f and g problem would not arise. When it comes to integrals, sums and limits things differ a bit from one program to the other. In some of the CAS programs (Geogebra, TI ) they can be entered as Integral( x^2 , x) Integral( x^2 , x, 0, 1) Sum(n^2, n, 1, 10) Limit( sin(x)/x, x, 0) Yours Frans Morville
Member

### pkra commented Aug 23, 2014

 Do I understand it correctly, that my original issue with f and g has been fixed, and after an update in the near future 2^g-3 will be rendered in the same way as 2^h-3 ? That's how I understand @drlippman It would be very nice, if teachers and students could easily communicate using such an additional "dialect" of MathJax/AsciiMath, where students can enter formulas, as they are used to do in Geogebra, Excel etc. That is possible but not planned from our end. I suspect the problem lies in specifying the grammar. @christianp's LissaJS has a similar syntax and can generate TeX code (as well as evaluate expressions) so that might be a good starting point. We (the MathJax team) would be happy to support any such effort for a new input but we are not planning on doing this ourselves anytime soon. I would suggest to post to the MathJax User Group and the MathJax Dev Group to see if others are interested in joining forces.

Closed