In the course of a discussion involving using MathJax to re-define macros, I couldn't recall if MathJax obeys a \newcommand
for an already-defined macro, and so made a draft post whose body was $\newcommand\div{Hi}$$\div$
. This produced $Hi$, even though the default expansion of \div
is $\div$. This, of course, is presumably by design, and is not the substance of my bug report.
What I noticed that was strange was that on some, but not every, refresh, the occurrences of \div
in the comments, which were written long before my draft post, and which even precede my draft post on the page, changed from $\div$ to $Hi$. This seems like it should be impossible, after the change in scoping that meant that macro definitions in one post shouldn't affect another.
I also cannot reliably reproduce this; it doesn't happen on every refresh, and further changing my draft post to other re-definitions doesn't seem to affect the uses of \div
in the comments, which always render as either $\div$ or $Hi$. I suspect that the specific details of what's happening have to do with subtleties in the caching behaviour of my browser (Safari Version 15.2 (17612.3.6.1.6)), and, probably, with the different treatment parsing and MathJax treatment comments receive; but surely, whatever the browser is doing, one post still shouldn't be affecting macro definitions in other comments?
EDIT: I can reliably reproduce a related bug (?): after submitting an edit to the main post, a macro definition in the body of a post allows the macro to be used in posts, but only until refresh. This behaviour goes away on refresh, so it has no lasting effects, but it seems like it might cause user confusion, when an answer previews just fine, and displays just fine immediately after submission, but behaves badly on refresh.
I introduced the macro \dontescape
in the post body of the Formatting Sandbox at revision 4. I then edited @EmilJeřábek's answer. The relevant revisions are the second and third
(although, if you look there, you'll see \shouldntescape
instead of \dontescape
in the revision history; I tried this twice, first with \shouldntescape
and then, since it stopped working after refresh, with \dontescape
, but rolled back the second within the 5-minute window, so that it showed up as simply undoing the previous edit). During preview:
After submission:
After refresh: