Skip to the Main Content

Note:These pages make extensive use of the latest XHTML and CSS Standards. They ought to look great in any standards-compliant modern browser. Unfortunately, they will probably look horrible in older browsers, like Netscape 4.x and IE 4.x. Moreover, many posts use MathML, which is, currently only supported in Mozilla. My best suggestion (and you will thank me when surfing an ever-increasing number of sites on the web which have been crafted to use the new standards) is to upgrade to the latest version of your browser. If that's not possible, consider moving to the Standards-compliant and open-source Mozilla browser.

November 4, 2009

MathML in Webkit

There was a discussion about displaying math on the web, over at Terry Tao’s blog. It was a little disheartening to learn where most peoples’ heads are at, in that regard. Many seems to be excited at the mere prospect of creating a web service that would turn TeX equations into pictures. Such services are not exactly thin on the ground, I retorted, but hardly satisfactory, either. Fortunately, an actual blind user showed up to explain at least one reason why that wasn’t the answer.

Still, being told, “You should use MathML.” is like being told, “Eat your vegetables.” and is just about as likely to be heeded.

One objection is the lack of browser support, which – these days – means that neither Opera, nor Webkit browsers (Safari, Chrome, …) support MathML. The latter, however, seems to be changing. There’s a plan and, more importantly, there’s actually been code checked into trunk.

Of course, it’s far too early to expect anything usable, but if Alex wants to prioritize, here’s a table of MathML elements and attributes used by itex2MML. Things that aren’t yet supported by his patches are marked in bold.

Presentational MathML Elements used in itex2MML
ElementAttributes
mathdisplay
mimathvariant
mn
momaxsize minsize lspace rspace stretchy
mrowxmlns:xlink xlink:type xlink:href
mover
munder
munderover
msub
msup
msubsup
mactionactiontype( = toggle, statusline, tooltip)
mphantom
mpaddedwidth lspace
mspaceheight depth width
merror
mtext
mstylescriptlevel mathcolor mathbackground displaystyle mathvariant
mmultiscripts
mprescripts
none
mfraclinethickness
msqrt
mroot
mtablerowalign columnalign align rowspacing columnspacing equalrows equalcolumns rowlines columnlines frame
mtrrowalign columnalign
mtdrowalign columnalign rowspan columnspan
semantics
annotation-xmlencoding

Other bits of the conversation were a little more heartening. MathML-in-text/html support is in Firefox nightlies, though disabled by default. I don’t imagine it will be turned on before Firefox 3.7 at the earliest. Judging by the number of Firefox 3.0 users, it’ll be some years yet, before we can count on using MathML-in-text/html. And I did learn about the very-cool-sounding MathJax project.

Anyway, here’s a modest contribution to what the discussion could have been about: things you can do with math on the web, that you couldn’t do in print. Hover your mouse over the right-hand side of A=2π 0 xe t 2dtClick to hide. erf(x)The Error Function: click for the definition. A=\toggle{ \statusline{Click to hide.}{ \tfrac{2}{\sqrt{\pi}}\int_0^x e^{-t^2} d t}}{ \statusline{The Error Function: click for the definition.}{ \mathop{erf}(x)} }

Unfortunately, due to a year-old Mozilla bug, the perhaps more-useful A=erf(x)The Error Function: click to go to Wikipedia. A= \statusline{The Error Function: click to go to Wikipedia.}{ \href{http://en.wikipedia.org/wiki/Error_function}{ \mathop{erf}(x)} } doesn’t currently work.

These are created with itex’s \statusline{}{}, \toggle{}{} and \href{}{} commands.

Update (11/6/2009):

Since Frank Hecker was confused, here’s the same equation, redone using itex’s new \tooltip{}{} command: A=2π 0 xe t 2dtClick to hide. erf(x)The Error Function: click for the definition. A=\toggle{ \tooltip{Click to hide.}{ \tfrac{2}{\sqrt{\pi}}\int_0^x e^{-t^2} d t}}{ \tooltip{The Error Function: click for the definition.}{ \mathop{erf}(x)} } Specifically, the itex code is
A=\toggle{
    \tooltip{Click to hide.}{
   \tfrac{2}{\sqrt{\pi}}\int_0^x e^{-t^2} d t}  }{
    \tooltip{The Error Function: click for the definition.}{
   \mathop{erf}(x)}
  }
Posted by distler at November 4, 2009 11:23 AM

TrackBack URL for this Entry:   http://golem.ph.utexas.edu/cgi-bin/MT-3.0/dxy-tb.fcgi/2105

11 Comments & 0 Trackbacks

Re: MathML in Webkit

That is great news about MathML in Webkit. Lack of MathML support is pretty much the only thing stopping me from switching over to Chrome wholesale. Thanks also for the summary of the discussion on Tao’s blog, which I didn’t follow to the end. In particular the MathJax project seems very interesting.

In my opinion, to encourage adoption of MathML we need to make it absolutely brain-dead simple for anyone to implement MathML in any web-based system and on any common server setup, including cheapo shared hosting. Current solutions fall somewhat short of that, although they are great if you put the effort into setting them up. The situation is somewhat similar to the hell of Javascript coding before the advent of libraries like JQuery et. al., which made all the browser implementation headaches disappear overnight. It looks like MathJax might do the same for MathML.

Posted by: Matt Leifer on November 4, 2009 2:22 PM | Permalink | Reply to this

Re: MathML in Webkit

Authoring MathML is hard, today, because you need to serve the resulting pages as application/xhtml+xml. The exigencies of doing that are rather severe. You can do it on this blogging system, you can do it in Instiki, but don’t even bother trying it in WordPress or MediaWiki.

When HTML5 browsers become commonplace, and you can serve MathML-in-text/html, then you could just drop in my itex2MML plugin for MovableType (or even an updated version of my long-defunct WordPress plugin) and be good to go.

MathJax sounds cool. Native MathML support in WebKit will be much cooler. But there will always be people who either

  1. can’t install a MathML-capable browser (or IE plugin) or
  2. can’t install the requisite (STIX) fonts.

It’s nice to think that there will be a solution (MathJax) for them.

Posted by: Jacques Distler on November 4, 2009 6:47 PM | Permalink | PGP Sig | Reply to this

Re: MathML in Webkit

Ah, MathJax looks very good, and it’s good to know that someone is implementing MathML in WebKit.

By the way, I have long been using (~10 years) a Javascript code to convert simple TeX commands to Unicode symbols and <sup>, <sub>. It’s not an ideal solution but works fairly well, and is used in my spires.app.

It didn’t work on browsers on English Windows machines in the past, because they didn’t come with Unicode fonts in the standard configuration. But apparently things have changed in better ways these days.

Posted by: YT on November 4, 2009 5:59 PM | Permalink | Reply to this

Re: MathML in Webkit

In your first example, hovering my mouse over the right hand element does nothing, however clicking on the element replaces erf(x) with the integral. (This is with Firefox 3.5 on OS X.) Did you mis-state this, or is this a Firefox issue?

Also, in the second example what was the intended “perhaps more-useful” behavior?

Finally, getting off Firefox for a moment it’s good to see MathML activity on the Webkit front.

Posted by: Frank Hecker on November 5, 2009 4:41 PM | Permalink | Reply to this

Re: MathML in Webkit

[H]overing my mouse over the right hand element does nothing

It should change the status-bar message. (This was not working, previously, because Mozilla did not implement that @actiontype for <maction>. I implemented a little Javascript-fu to work around that.)

A tooltip would, perhaps, be better. When I have the time, I’ll implement something for that in itex2MML.

Also, in the second example what was the intended “perhaps more-useful” behavior?

The RHS of the equation is a hyperlink to the Wikipedia page on the error function. Again, the status bar should indicate that (and, again, a tooltip would be better).

The above functionality (you should “view source” to see the corresponding MathML code) is implemented by the \statusline{}{}, \toggle{}{} and \href{}{} commands in itex.

Posted by: Jacques Distler on November 5, 2009 8:06 PM | Permalink | PGP Sig | Reply to this

Re: MathML in Webkit

MathML is now turned on by default in the WebKit nightly builds. Yay!

WebKit bug
Changeset

The tooltips and hyperlinks don’t work yet, and some of the overbars in Pure Spinor Signature are rendered a bit funky, but it’s a good start.

Posted by: Nicholas Shanks on August 5, 2010 12:41 PM | Permalink | PGP Sig | Reply to this

Re: MathML in Webkit

Hi Jacques,

I know this is an old post, but how is Chromium/Chrome going with MathML? I only run Firefox at present to get MathML (n-category cafe and related sites), and would love to switch to a slimmer browser.

Posted by: David Roberts on September 7, 2011 7:50 PM | Permalink | Reply to this

Re: MathML in Webkit

Safari 5 has MathML turned on by default. And MacOSX Lion ships with the STIX fonts installed. That sounds great.

Alas, the MathML support is … rudimentary … at best. Instead, all my software (including the n-lab and n-café) deliver MathJax-based rendering.

That’s slow (and doesn’t support mixing SVG and MathML), but acceptable.

You can compare the built-in MathML support with the MathJax rendering by tinkering with the User-Agent string of your browser: pretend to be Firefox, and you’ll get the native MathML rendering; otherwise, you’ll get the MathJax rendering.

Posted by: Jacques Distler on September 7, 2011 8:10 PM | Permalink | PGP Sig | Reply to this

Re: MathML in Webkit

Yes, but what about Chrome? Or is Webkit in general like this?

Posted by: David Roberts on September 8, 2011 12:56 AM | Permalink | Reply to this

Re: MathML in Webkit

Webkit’s MathML support is what it is. Whether any given Webkit-based browser has it turned on, I don’t know.

But there’s an easy way to find out …

Posted by: Jacques Distler on September 8, 2011 1:00 AM | Permalink | PGP Sig | Reply to this

Re: MathML in Webkit

Of course…duh. I suppose extensions/plug-ins etc are possible, too.

Thanks. :)

Posted by: David Roberts on September 8, 2011 1:44 AM | Permalink | Reply to this

Post a New Comment