mathjax / MathJax-website

The MathJax website
https://www.mathjax.org
22 stars 21 forks source link

demo leaving raw input in output (for a particular input) #97

Closed pkra closed 3 years ago

pkra commented 3 years ago

This might be a MathJax issue but I thought I'd start here.

Pasting $$\mathop{\mathrm{Re}\nolimits (z) \ge 1$$ into the input at mathjax.org#demo just leaves the raw TeX in the preview. No error on the console. Adding the missing brace renders correctly, adding it in the wrong position gives an error.

dpvc commented 3 years ago

MathJax's approach to processing the math in a page is to first locate the mathematics, and then later to process it via its input jax. That means Mathjax must find matching delimiters without processing the TeX itself, and that differs from how TeX works, which processes the input as it looks for the the closing delimiter. Because you can do things like $x_i = 0 \text{ for $i < 10$}$, MathJax does brace balancing while looking for the closing delimiter, so only closes the math if there is no unclosed open brace. That means that, in your example, MathJax finds no closing delimiter, and so no math is identified, and nothing is processed by TeX to produce an unbalanced brace warning. So this is "expected behavior" in that sense.

In actual TeX, you would probably get a message at the next paragraph break that the open math delimiter is not closed. That is harder to do in an HTML environment, where breaks are a little harder to identify. MathJax doesn't produce such messages, as <span>$</span> is one of the ways to isolate the start delimiter so that it produces a literal dollar sign, for example, so we could not want to produce an error message for that.

Also, MathJax messages are inserted into the page (and repack the errant math), but if there is no close delimiter, it is not clear what the error message should replace. For now, the indication that there is a problem with the math is that it is not processed.

It would be possible to use different rules for display versus in-line math delimiters, but I'm not sure that that inconsistency would be a good idea.

pkra commented 3 years ago

Thanks for the explanation. I hadn't thought about the detection part of the processing.