# MathJax is really eager to be applied to posts

When writing a MathJax heavy post I noticed a couple of bugs. For reference, here is an example of how the MathJax should look:

$$a_{i+1} = \begin{cases} \frac{a_i}{2} & \text{if a_i \% 2 = 0 (even)} \\ 3a_i + 1 & \text{if a_i \% 2 = 1 (odd)} \end{cases}$$

# Begin and end work outside of math mode

Code

a_{i+1} = \begin{cases}
\frac{a_i}{2}  & \text{if $a_i \% 2 = 0$ (even)} \\
3a_i + 1 & \text{if $a_i \% 2 = 1$ (odd)}
\end{cases}


Live

a_{i+1} = $$\begin{cases} \frac{a_i}{2} & \text{if a_i \% 2 = 0 (even)} \\ 3a_i + 1 & \text{if a_i \% 2 = 1 (odd)} \end{cases}$$

Preview # An unclosed math-mode delimiter swallows some backslashes

Code

$$a_{i+1} = \begin{cases} \frac{a_i}{2} & \text{if a_i \% 2 = 0 (even)} \\ 3a_i + 1 & \text{if a_i \% 2 = 1 (odd)} \end{cases}  Live$$ a_{i+1} = \begin{cases} \frac{a_i}{2} & \text{if $a_i % 2 = 0$ (even)} \ 3a_i + 1 & \text{if $a_i % 2 = 1$ (odd)} \end{cases}

Preview • It might be useful to indicate what you think should happen in these cases. It's not clear to me. – Edward Mar 22 at 21:13
• @Edward Personally I don't think MathJax should be eagerly evaluating. We've had posts break because of MathJax before, adding a single $$ to your post shouldn't mangle the backslashes in your question. If SE disagrees, I'd want the output to at least be correct (first example) and not be striping backslashes. Since the related bug has regressed to the point where MathJax seems to not work at all in the tag wiki. I really only care the bugs are fixed, not how. – Peilonrayz Mar 22 at 21:29 • I'm not disagreeing, just not understanding. Typical bug report forms ask both "what did happen" (which you have documented) and "what should happen" which I'm not yet able to infer. – Edward Mar 22 at 21:33 • Why are your previews in dark mode? Are you using a script to change this? I do get the same results without the $$ when I paste this code but, with them, it works as expected - is it the fact that the MJ is rendering at all without the  that is part of the issue? I think @Edward makes some good points - Having a "what you think should happen instead" might make this easier to understand for me - This also occurs on some other MJ-enabled sites, such as Mathematics, so It'd be good to know what the common concern is and how it should be addressed. :) – Catija Mar 26 at 18:35
• @Catija "Why are your previews in dark mode?" Because my preferred browser has a dark mode addon and white previews hurt my eyes when writing up. I do check on a browser with no scripts but keep activity in such an environment to the minimum. "what you think should happen instead" I don't know how better to explain myself than in my first comment. The two solutions I talked about are; ① don't eagerly evaluate the MathJax outside of where I properly tell the software where MathJax is ② render things correctly (see the blockquote example at the top of the question). – Peilonrayz Mar 26 at 19:20