4
$\begingroup$

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. Macro \div becomes Hi

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: \dontescape renders on preview After submission: \dontescape renders after submission After refresh: \dontescape does not render after refresh

$\endgroup$
2
  • 1
    $\begingroup$ Sometimes strange TeX things happen when they depend on the order things are processed. The order answers are shown in is changed by the system sometimes, which may change whether macros appear to the Mathjax engine before their definition. $\endgroup$ Aug 14 at 12:11
  • $\begingroup$ @GeraldEdgar, that definitely used to be the case, but each post is now in its own group, so that definitions from one post cannot leak into another. Indeed, this is the case upon refresh: definitions from one post, even from the question which always comes first, do not have any effect on answers that appear later. However, it does not happen immediately after submitting an edit (as can be checked reliably by the kind of fiddling I describe in my update). (Also, the originally reported bug was happening even before the re-definition—though unreliably.) $\endgroup$
    – LSpice
    Aug 14 at 13:36

0

You must log in to answer this question.

Browse other questions tagged .