Math in Mallard

Philip Chimento <philip.chimento at gmail.com>
Tue Jul 26 03:12:39 EDT 2011

On Mon, Jul 25, 2011 at 03:43, Shaun McCance <shaunm at gnome.org> wrote:
> That's exactly how I would embed MathML inline. But it does require
> tools to support it. I could add trivial support to yelp-xsl that
> just does an xsl:copy-of on m:math, and just assume that the HTML
> renderer supports MathML. If you're building HTML with yelp-build,
> you can use this extension stylesheet and pass it with the -x option:
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>                xmlns:m="http://www.w3.org/1998/Math/MathML"
>                version="1.0">
> <xsl:template mode="mal2html.inline.mode" match="m:*">
> <xsl:copy-of select="."/>
> </xsl:template>
> </xsl:stylesheet>
>
> Warning: I didn't test this. But I'm pretty sure it works fine.

Well, I'm using gnome-doc-tool, but that has an -x option as well.

The above stylesheet worked in XHTML mode, but not in HTML mode, at
least not in Firefox. Apparently Firefox doesn't like the elements to
be named <m:mrow>, etc. in HTML files. I'm a novice at XSLT, but
here's what I did:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
               xmlns:m="http://www.w3.org/1998/Math/MathML"
               version="1.0">
  <xsl:template mode="mal2html.inline.mode" match="m:*">
    <xsl:element name="{local-name()}"
namespace="http://www.w3.org/1998/Math/MathML">
      <xsl:apply-templates mode="mal2html.inline.mode" select="@*|node()"/>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>

> [...]
> 5) I'd want to figure out the interaction between Mallard's strict
> block/inline separation and the display attribute on m:math. Maybe
> display should be ignored, and written out as appropriate based on
> context. Maybe it should be an error for display to be the wrong
> thing for the context. Not sure here.

I would say that it should be an error to have inline display in a
block context and vice versa. I guess that wouldn't be necessary
though if you had Mallard elements for block and inline math.

> 6) And, of course, it would be nice to write up a spec and some
> schema glue to make this all well-defined. I just looked at the
> official MathML RNG from the W3C. It's not my favorite piece of
> RNG I've ever seen. I wish they'd prefixed the defined names.
>
> On top of all that, if people are writing math articles in Mallard,
> formal block elements for equations would probably be nice. Those
> could be done in a math extension. And maybe that same extension
> is the right place to define the MathML interaction in general.

Well, I'm not exactly writing a math article - just one formula and a
few symbols in a couple places in a document.

Thanks for the excellent help,
-- 
Philip