Showing only posts with topic "mathml" [.rss for this topic]. See all posts.

On the hell that is MathML

It’s been 12 years since the first MathML spec was released, and math on the web is still largely unsupported and incredibly complicated to get right. If that isn’t a spec failure, I don’t know what is.

Personally, after a year of doing my best to do MathML the “right” way, I’ve given up trying to be correct. I’m now using MathJax to render math, a solution that is, while absolutely horrible, far less horrible than before. In particular, people can actually see math.

But William! you might say, all you need to do for math on the web is to generate MathML. Firefox has supported MathML for years and years! And that’s true, BUT:

  1. Random browsers simply don’t support MathML (e.g. Chrome, Safari).
  2. The browsers that do support it (e.g. Firefox) support it only in strict compliance mode.

And strict compliance mode is an absolute hell for everyone involved. You must produce valid XHTML and sending your content as text/xml instead of text/html. Any kind of non-conforming XML produces a horrible cryptic red error message instead of displaying the page. You will begin to live in fear of screwing things up whenever you make a chance to your layout, and god help you if you have any kind of UGC or templating or any kind of non-trivial content generation.

MathJax smooths that away. You can embed MathML or even LaTeX math markup directly into a text/html document, and it will do the magic to turn it into math in the browser. If the browser has native MathML support, then great, it will use that. If the browser has web font support, then great, you get pretty fonts. And if not, the degradation is graceful. And you get the nice error-robust rendering that makes HTML nice.

I’m still using Ritex to translate LaTeX math into MathML, because I like the syntax and because I didn’t feel like going back and translating all the math. I’ve changed Whisper to emit text/html as the content type. So now I should have the best of all possible worlds.

Let’s try it:

If you see math above, I have succeeded. If not, I have failed.

No MathML in webkit

So apparently WebKit has no real MathML support. Empirically, it seems like you get some stuff like greek symbols, but things like sums and whatnot don’t appear. Oh well. Mac users, switch to Firefox, or ignore the math posts.

Old comments are in

I’ve finally pulled in all the old comments from the Blogspot blog. A painful process of semi-automated Atom to YAML+Textile conversion, and the resulting comments are not threaded, but they’re at least here now.

As a side note, I’m really liking having my posts stored in a git repo. I can write them locally, tweak them and see how things look, and push when they’re finally ready to be published.

As another side note, MathML is a being a shitshow as usual. Firefox 3.1 (but not 3.0?) apparently craps out at embedded style sheets in XML (craps out as in, refuses to display the blog and displays a big red error instead), or some shit. So I’ve removed some stylesheet line from the master template and now everything seems to work in both Firefoxes. But that line is critical according to Putting mathematics on the Web with MathML so god only knows what I’ve broken in the process.

The big problem with all this MathML stuff is that the XML wonks apparently managed to trick everyone into violating Postel’s law and failing hard when the browser doesn’t like something about the XML it sees. So the moment anything is slightly out of whack, no one can see your blog. Maybe that’s why no one in the world uses MathML except for me?

That brings to mind an old Mark Pilgrim post about XML and Postel’s Law which is a good read, and includes this memorable quote:

Various people have tried to mandate this principle out of existence, some going so far as to claim that Postel’s Law should not apply to XML, because (apparently) the three letters “X”, “M”, and “L” are a magical combination that signal a glorious revolution that somehow overturns the fundamental principles of interoperability.

Good stuff. Too bad that was five fucking years ago and I’m still dealing with this shit.

maff test

It really seems like this should display some kind of equation:

I can’t make it work despite all my xhtml’ing. Blogger fail. [Fixed in Whisper. —ed.]