Removing double super/subscripts from student responses

As @Chrissy_Safranski pointed out to me, if a student presses ^ multiple times, the math input will happily stack multiple superscripts leading to an expressions that might look correct, but is invalid due to double superscripts. This is particularly hard to detect visually if exponentiating a expression with tall parentheses.

For example, in the first input \left(x^{8}+3\right)^{^{7}} with the double superscript might even be considered to look better than the second with a single superscript.

The correct way to fix it would be to prevent MathQuill (the technology for a math input) from allowing stacked superscript or subscripts. That is how WeBWorK and Desmos do it. However, I’m not familiar with the MathQuill code, so that would be a big lift for me now.

I have instead programmed a way to give students credit even if they stack superscripts or subscripts: I simply take the output of the MathQuill and remove repeated superscripts and subscripts before Doenet processes it. Now, students get the correct answer even if they stack exponents:

image

Does that seem like a reasonable compromise for now? Is anyone able to test it to see if it works OK? This change is not in the recently released version of DoenetML. To test it, you can go to the Settings of a Document and change the version to “0.7dev”. (Or, in PreTeXt, you can set version="dev".)