December 5, 2006

The Beginning of the End

Sam Ruby has been busy. He’s been lobbying for changes in the HTML5 Specification which will, ultimately, enable embedding of MathML and SVG in HTML5 documents. As a proof-of-concept, he unveiled a Javascript that enables embedding MathML and SVG in current HTML4 documents. If your browser supports MathML and/or SVG in XHTML, Sam’s script will make them work in HTML4.

Goodbye Draconian error-handling!

There are some restrictions. XML empty element syntax is not supported. So, in MathML, e.g. <none/> would have to be changed to <none></none>. I counted twelve lines of itex2MML code which would have to be changed to accommodate Sam’s script. That was too good to pass up.

So here’s itex2MML 1.1.6. The only change was to “fix” those 12 lines, to eliminate XML empty-element syntax. At least for Gecko-based browsers, following Sam’s instructions, you can now happily use it1 to embed MathML in good old HTML4 (or, for that matter, faux XHTML) pages, served as text/html.

Share and enjoy!

A Well-Oiled Machine

Slightly off-topic, but I just wanted to announce that one of my pet MathML-rendering bugs got fixed. What warms my heart, though, is the chronology. I submitted the bug Sunday night. In less than an hour, Phil Ringnalda had created a test-case, and cc’d Boris Zbarsky. Zbarsky quickly diagnosed the problem and, the next morning proposed a patch. The following day, the fix was approved by Roger Sidje, and checked-in. From initial bug report to check-in of the solution? 40 hours and 6 minutes.

1 You will still need to use MathML::Entities or the corresponding MovableType plugin to process the output of itex2MML, converting named entities to NCRs. But that’s easy enough.

Posted by distler at December 5, 2006 11:46 AM

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

Re: The Beginning of the End

I’m interested to see how this one works out. There seem to be a few entrenched opinions that there is no need to allow languages like SVG to be embedded in HTML (at least without crazy-cool hacks like Sam’s). I rather disagree; it seems like it would finally eliminate the last use case for XHTML and its nightmarish parsing model.

Posted by: jgraham on December 5, 2006 4:29 PM | Permalink | Reply to this

Re: The Beginning of the End

I don’t, in the end, give a hoot about XHTML.

But I’d sure as heck like it to be possible to use itex equations on WordPress, on Blogger, on … Heck, I’d like it to be possible to use itex equations on MovableType, without first having to jump through incredible hoops.

And if the Mozilla people were willing to willing to have Gecko directly consume the embedded MathML(/SVG) markup, without Sam’s Javascript to shove it down its throat, so much the better.

Posted by: Jacques Distler on December 5, 2006 4:54 PM | Permalink | PGP Sig | Reply to this

Well, that’s just frickin’ great.

Damnit, Jacques. When you run into a kid right out of school, and he’s all fired up about how awesome XHTML is, and you patiently explain the whole mess to him – no, it isn’t “faster”, no, it isn’t “more semantic”, no, it is never “smaller”, no, CSS2.1 is not actually coupled with the XHTML 1.x spec – there’s this moment where the kid’s face begins to crumple. That’s when you pat him on the shoulder. “There, there,” you say. “You can use XHTML to embed SVG and MathML! Stupid crummy ol’ HTML 4 can’t do that!”

But now even that’s gone. Can you please tell Sam to take that JS snippet down? Won’t somebody think of the children?

Posted by: Evan Goer on December 6, 2006 1:48 AM | Permalink | Reply to this

Re: Well, that’s just frickin’ great.

You forgot to mention the wonderful XML toolchain he can avail himself of, so that his friends won’t consider him a bozo.

There’s a lot of jaw-boning about this stuff on the WhatWG mailing list. The thing about Sam is that he actually sits down and writes code.

Nothing convinces like a working demo …

Posted by: Jacques Distler on December 6, 2006 3:10 AM | Permalink | PGP Sig | Reply to this

Re: Well, that’s just frickin’ great.

Hmm. My weblog backend consists entirely of XSLT transforms, and so do my screen-to-feed scrapers, and at this point I wouldn’t want to implement either in any other way. That makes HTML4 extra work for me (and I haven’t taken the time to put it in, although I now consider serving XHTML a bug).

Then again, I’m clearly an outlier.

Posted by: Aristotle Pagaltzis on December 6, 2006 5:32 AM | Permalink | Reply to this

Re: Well, that’s just frickin’ great.

Hey, an XSLT-based backend is cool and all. Actually, it doesn’t really matter if the backend is XML, flat files, a Oracle installation that cost \$50M, or whatever. That’s all invisible to me. I’m more concerned about what one actually delivers to the browser.

(Actually, at the final stage can’t you just output as HTML? I’m a bit embarrassed to admit that I’ve only done XML-to-XML and XML-to-plaintext transforms, so I don’t really know the ins and outs of turning on the HTML option.)

Now, actually, don’t tell the XHTML advocates, but I did get sort of bit by using HTML 4. My feed content just takes a raw chunk of HTML from Movable Type, and so I use XML comments to protect the feed rather than making the whole thing XML like a good citizen. Mark Pilgrim sent me an email once making fun of me for that, but la la la I’m not listening.

Posted by: Evan Goer on December 6, 2006 10:30 AM | Permalink | Reply to this

Re: Well, that’s just frickin’ great.

at the final stage can’t you just output as HTML?

Sure can, and I plan to; but I don’t yet because there’s more to it than just switching the XSLT output method. It ain’t hard, but it’s not trivial either. That was my point, incidentally.

Posted by: Aristotle Pagaltzis on December 10, 2006 7:27 AM | Permalink | Reply to this

Re: Well, that’s just frickin’ great.

at the final stage can’t you just output as HTML?

Sure can, and I plan to;

If you don’t mind my asking …. why?

Is there any actual advantage to be gained from going to the extra trouble of converting the output to HTML?

but I don’t yet because there’s more to it than just switching the XSLT output method. It ain’t hard, but it’s not trivial either.

I think it’s fair to say that, whatever “it” is, it’s almost never as trivial as they say it is.

Posted by: Jacques Distler on December 10, 2006 12:08 PM | Permalink | PGP Sig | Reply to this

Re: Well, that’s just frickin’ great.

Is there any actual advantage to be gained

In practical terms? No.

But we’re talking about my personal site and I am free to care about correctness for correctness’s sake; otherwise I’d simply have switched from application/xhtml+xml to text/html long ago.

whatever “it” is, it’s almost never as trivial as they say it is.

And funnily enough, it’s more often easy when they say it’s not than it is trivial when they say it is.

Posted by: Aristotle Pagaltzis on December 11, 2006 1:41 PM | Permalink | Reply to this

Re: Well, that’s just frickin’ great.

No, actually I escape it as CDATA. Duh. It took me about four submit attempts to get the grammar in that first sentence right. I need coffee.

Posted by: Evan Goer on December 6, 2006 10:42 AM | Permalink | Reply to this