Allow \middle to work when a style or color is open. (mathjax/MathJax#2663) #673
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current implementation for
\middle
only works when there are no open style or color changes, and so it fails withfor example. This PR introduces a
MiddleItem
stack item that acts as a close item, so it will close any pending and style items. TheLeftItem
looks for aMiddleItem
and processes it (by adding the neededmo
) without closing itself so that it will remain open until the followingRightItem
occurs.In addition, the
\middle
and\right
delimiters now save the color that they should be in, since\left(\color{red}x\right)
colors the right brace red in actual LaTeX (and similarly for\middle
), and apply those properly (they didn't before).Finally, I made the
LeftRight
constructor take the actual delimiter (and color) as an argument so that you don't have to set it after it is created.Resolves issue mathjax/MathJax#2663.