Skip to content

Conversation

jared-hughes
Copy link

Mathquill had separate SubscriptCommand and SuperscriptCommand node classes, which were subclasses of SupSub.

Before this PR, it was possible to create a SuperscriptCommand that only contained a subscript with the following steps:

  1. Create a superscript like x^2
  2. Add a subscript, x_1^2
  3. Remove the superscript, x_1.

(The reverse is possible as well; you could make x^2 be a SubscriptCommand by switching superscript and subscript in the steps).

This caused an issue when you typed ) after the resulting x_1 because it duplicated the subscript to the superscript, giving x_1^1. (presumably in finalizeTree). A simple fix for that would be to do change the prototype to a SubscriptCommand, but instead this PR removes the SuperscriptCommand and SubscriptCommand classes in favor of using the supsub property on the SupSub class.

While merging the SuperscriptCommand and SubscriptCommand methods into SupSub, I found and fixed a couple more problems:

  1. Mathspeak previously had an undefined show up for a SupSub with both a superscript and a subscript. E.g. for x_1^y it said "x" Subscript, 1 , Baseline "y" undefined. Now, it says "x" Subscript, 1 , Baseline Superscript, "y" , Baseline.
  2. Mathspeak previously omitted the subscript for a SupSub with both a subscript and positive integer superscript. E.g. for x_1^2 it could say "x" squared, forgetting the subscript.
    • This problem only occurred when the SupSub was a SuperscriptCommand, i.e. you typed the superscript first before the subscript.

@jared-hughes jared-hughes merged commit c419aec into main Jul 28, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants