Little Steps
As many of you know, the reason I started this blog was because I thought the weblogs would prove to be an excellent vehicle for “informal” physics discussions.
Being able to type equations (preferably in TeX) and have them display inline in your browser is an essential part of that. My first attempt to put MathML in this blog didn’t work so well. Perhaps you think I entirely abandoned the notion. Not at all.
Some of you might also have noticed my dogged obsession with bringing this blog up to full XHTML 1.1 compliance which must, I admit, seem pretty quixotic.
Anyway, there was method to my madness. With a little mod_rewrite
trick in the .htaccess
file of this blog,
RewriteEngine On RewriteBase /~distler/blog/ RewriteRule ^$ index.html RewriteCond %{HTTP_USER_AGENT} Gecko RewriteRule \.html$ - [T=text/xml] RewriteCond %{HTTP_USER_AGENT} Safari RewriteRule \.html$ - [T=text/html]
I can serve up XML to Gecko-based browsers which grock MathML (but only when rendering XML files), while sending “plain old” HTML to other browsers. It’s actually the same file; just the MIME-Type is altered, depending on what browser does the asking.
This only works if my blog is 100% valid XHTML. XML parsers puke at the slightest error and refuse to render the page, unlike your basic HTML parser, which will try to render something out of even the most broken HTML.
I think I’ve succeeded. There were surprising bits of invalid (X)HTML hidden away in obscure corners of MovableType, as this thread delineates. I think I’ve caught everything now, but if you’re running a Gecko-based browser and something here returns an XML parser-error, let me know.
Assuming you have the fonts installed, this means that (MathML)
will look like (screenshot)
in a Gecko-based browser.
But, of course, that’s only the first step. In the forthcoming version of MovableType, Ben and Mena have announced the introduction of a Text-Filtering API. I’ve already mentioned some of the benefits, but for present purposes,
the biggest payoff is that we can write posts with embedded itex (a dialect of LaTeX) and have MovableType automatically run them through itex2mml
to convert them to embedded MathML.
That’s not quite how I created this post. Instead I ran it through the online itex2mml converter. But you get the idea…
Posted by distler at January 18, 2003 4:17 PM