5
\$\begingroup\$

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

How the live is displayed in the preview.

An unclosed math-mode delimiter swallows some backslashes

Related: The MathJax newline \\ is broken in tag wikis

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

How the live is displayed in the preview.

\$\endgroup\$
5
  • \$\begingroup\$ It might be useful to indicate what you think should happen in these cases. It's not clear to me. \$\endgroup\$ – Edward Mar 22 at 21:13
  • \$\begingroup\$ @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. \$\endgroup\$ – Peilonrayz Mar 22 at 21:29
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Edward Mar 22 at 21:33
  • \$\begingroup\$ 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. :) \$\endgroup\$ – Catija Mar 26 at 18:35
  • \$\begingroup\$ @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). \$\endgroup\$ – Peilonrayz Mar 26 at 19:20
0
\$\begingroup\$

Although we don't have the new "Live/Preview" editor on math.SE, I have seen the the Live part of the first bug many times when entering a post. I have believed this to be a problem with the browser. Usually, if I wait for a few seconds, the MathJax renders fine in the Live window. If I copy the post (so that I keep all my changes after the last draft save) and refresh my page until the Live window renders immediately, I can paste the copied version of my post back into the Code window and all continues as it should.

I've not noticed the second bug, but when my MathJax is not rendering properly, I look for where the problem is in my code and correct it. Perhaps this bug exists for me, but I've corrected my code too quickly to notice that it is this bug.

\$\endgroup\$
2
  • \$\begingroup\$ My main concern is eagerly evaluating MathJax breaking users code without MathJax being intentionally used - related meta. I have in the past seen high rep users just straight up blame the bug on the low rep user. Who posted code and didn't intentionally use MathJax. We don't need even more ways for such unpleasantries to occur. And as I think you've described; if you're intentionally using MathJax you can probably fix the issues. Making the bug mostly a trivial issue for most other MathJax enabled sites. \$\endgroup\$ – Peilonrayz Mar 26 at 20:13
  • \$\begingroup\$ Okay. Since "a MathJax heavy post " was mentioned, I did not realize that the concern was related to unintentional MathJax use. I haven't looked, but I wonder if an option to turn MathJax off/on (per post) for sites that do/don't generally use MathJax has been suggested or investigated. \$\endgroup\$ – robjohn Mar 26 at 20:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .