Thursday, December 14, 2006

MathML Workaround for Blogger

Earlier I posted about not being able to get MathML to work with Blogger. As you can see below I've a partial workaround:
Now there's still a spacing issue, but its a start. Behind the scenes its uglier
<object type="application/xhtml+xml" data="data:application/xhtml+xml;base64,PG1hdGggaWQ9ImVxdWF0aW9uIiBzdHlsZT0iZGlzcGxheTpub25lOyIgeG1sbnM9Imh0dHA6Ly93
d3cudzMub3JnLzE5OTgvTWF0aC9NYXRoTUwiPgogIDxtcm93PgogICAgPG1zdXA+CiAgICAgIDxt
ZmVuY2VkIG9wZW49IlsiIGNsb3NlPSJdIj4KICAgICAgICA8bXJvdz4KICAgICAgICAgIDxtaT5h
PC9taT4KICAgICAgICAgIDxtbz4rPC9tbz4KCiAgICAgICAgICA8bWk+YjwvbWk+CgogICAgICAg
IDwvbXJvdz4KICAgICAgPC9tZmVuY2VkPgogICAgICA8bW4+MjYwPC9tbj4KICAgIDwvbXN1cD4K
ICAgIDxtbz4rPC9tbz4KICAgIDxtc3ViPgoKICAgICAgPG1mZW5jZWQgb3Blbj0ieyIgY2xvc2U9
In0iPgoKICAgICAgICA8bXJvdz4KICAgICAgICAgIDxtaT5hPC9taT4KICAgICAgICAgIDxtbz4r
PC9tbz4KICAgICAgICAgIDxtaT5iPC9taT4KICAgICAgICA8L21yb3c+CiAgICAgIDwvbWZlbmNl
ZD4KCiAgICAgIDxtaT5pPC9taT4KCiAgICA8L21zdWI+CiAgPC9tcm93Pgo8L21hdGg+Cg=="></object>
Ugly, huh? The data URI is a base64 encoding of the following:
<math id="equation" style="display:none;" xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
  <msup>
    <mfenced open="[" close="]">
      <mrow>
        <mi>a</mi>
        <mo>+</mo>

        <mi>b</mi>

      </mrow>
    </mfenced>
    <mn>260</mn>
  </msup>
  <mo>+</mo>
  <msub>

    <mfenced open="{" close="}">

      <mrow>
        <mi>a</mi>
        <mo>+</mo>
        <mi>b</mi>
      </mrow>
    </mfenced>

    <mi>i</mi>

  </msub>
</mrow>
</math>
Now, in theory, I should just be able to set the data attribute of the object to #equation, but that doesn't seem to work for some reason. So in order to get the MathML to display without needing to put it in an external file I had to use the "data" URI scheme. If anyone knows a workaround to the base64 portion of my workaround let me know.

0 Comments:

Post a Comment

<< Home

Blog Information Profile for gg00