mitodl / mitx-grading-library

The MITx Grading Library, a python grading library for edX
https://edge.edx.org/courses/course-v1:MITx+grading-library+examples/
BSD 3-Clause "New" or "Revised" License
14 stars 9 forks source link

AsciiMath and conj #163

Closed jolyonb closed 5 years ago

jolyonb commented 5 years ago

When in the process of typing a formula, conj and conj( return math processing errors from asciimath. We should probably figure out what's going on here and just render as conj and conj( respectively.

ChristopherChudzicki commented 5 years ago

OK, so I looked into this a bit tonight.

The edX version of AsciiMath seems to show "Math Processing Error" when symbols that AsciiMath classifies as mover and mtext are wrapped in nonbreaking blocks. For example:

You can test this in a <textline math='1' /> field. It has nothing to do with our library. Note that the AsciiMath website has no trouble displaying {:overline:}. I'm not sure if they do some extra processing, or if this is a bug that was fixed.

This issue comes up because preProcessEqn wraps function calls and symbol names in non-breaking blocks. For example:

 // Display fine:
 preProcessEqn('conj(z)') // {:conj({:z:}):}
 preProcessEqn('conj()') // {:conj():}
 // Math Processing Error
 preProcessEqn('conj') // {:conj:}
 preProcessEqn('conj(') // {:conj:}(

Incidentally, that means only problems using our preprocessor suffer this issue. Some problems in our demo course only use the extra symbols, and they work fine.

A Fix: I'm not sure of a good way to fix this issue. I'll submit a PR (#164 ) with a hacky method, and you can decide whether to merge it.

jolyonb commented 5 years ago

Resolved well-enough by #164. The issue seems to be in the MathJax implementation of AsciiMath, and I don't want to go there. The hack avoids the issue for conj, which is the only mover symbol that we define. If it becomes an issue later on, we can revisit this, but I suspect it won't.