Saturday, June 18, 2016

MathJax Whiplash

Technology is continuously evolving, and for the most part that's good. Every now and then, though, the evolution starts to look like a random mutation ... the kind that results in an apocalyptic virus, or mutants with superpowers, or something else that is much more appealing as a plot device in a movie or TV show than in real life.

Back in 2010 I switched math rendering in this blog to MathJax, and things went swimmingly ... for a while. Then rendering got glitchy in Firefox (I forget exactly when), and I ended up installing a trio of Firefox extensions (MathML-Fonts, MathML Font Settings, and Native MathML), which fixed things ... for a while.

Last December things got goofy again. Math formulas were causing excess vertical space to appear between lines. Google Chrome was unaffected; I only saw this in Firefox. (I never use Internet Exploder, Safari or Opera, and don't use Chromium very often, so I have no idea if any of them were affected.) As I noted in an otherwise unrelated post, the problem seemed to cure itself while I was busy searching for help, so I never knew what caused it or, for that matter, what cured it. No matter; rendering once again worked properly ... for a while.

A week or so ago, I noticed that the vertical spacing issue had returned. Today I finally took the time to go looking for help. The closest I came to a fix was finding information in a MathJax FAQ that the configuration I was using in the blog had been deprecated as of MathJax v2.6. In particular, I had been using a configuration that defaulted to native MathML where possible, given that Firefox supports MathML. One sentence in the FAQ caught my eye:
While MathJax’s NativeMML output processor works around various limitations of Firefox/Gecko and Safari/WebKit, the results using the NativeMML output processor may have spacing or other rendering problems that are outside of MathJax’s control.
So I changed the blog configuration to the option now "preferred" by MathJax ("CommonHTML"), but that did not help. Screwing around with the font choices provided by the MathML Font Settings extension, I found exactly one font that displayed correctly. (I forget now which it was, but it was not what I would call an obvious choice.)

I'm not sure what inspired me to try it, but I disabled all three extensions on my desktop machine ... and, lo and behold, the problem disappeared. Apparently some change either in MathJax (circa version 2.6?) or Firefox made the font overrides done by the extensions an enemy rather than an ally. I confirmed that disabling the extensions on my laptop also fixed the problem there.

So rendering of math in Firefox is once again working properly ... for a while. But I'm leaving those extensions installed, just in case.

No comments:

Post a Comment

Due to intermittent spamming, comments are being moderated. If this is your first time commenting on the blog, please read the Ground Rules for Comments. In particular, if you want to ask an operations research-related question not relevant to this post, consider asking it on Operations Research Stack Exchange.