Math in Mallard

Shaun McCance <shaunm at gnome.org>
Sun Jul 24 21:43:55 EDT 2011

On Sat, 2011-07-23 at 20:35 +0200, Philip Chimento wrote:
> Hi Mallard list,
> 
> Is it possible to do mathematical formulae in Mallard using external
> namespaces? As far as I can tell from the spec, the following should
> work:
> 
> <span xmlns:m="http://www.w3.org/1998/Math/MathML">
>   <m:math><m:mrow>
>     <m:mi>n</m:mi><m:msup><m:mn>2</m:mn></m:msup>
>     <m:mo>&#x2265;<!--geq--></m:mo>
>     <m:mi>V</m:mi>
>   </m:mrow>
> </m:math></span>
> 
> Or does the processing tool also have to be aware of how to deal with
> the external namespace?

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.

Here's a few things I'd like to address implementation-wise to get
better MathML support in yelp-xsl:

1) Browsers generally only support presentation MathML. There are
stylesheets that convert from content to presentation. Embedding
or duplicating those would be nice.

2) I'd like to allow Mallard links using the mal:xref attribute on
MathML elements, like we do with SVG:

http://projectmallard.org/about/learn/svg.html#xref

3) It might also be nice to allow Mallard inlines in m:mtext or
even other token elements.

4) It would be good to have a parameter to disable MathML and have
the stylesheets use the altimg and alttext attributes. This would
allow you to build HTML specifically targeting places where you
know MathML isn't supported.

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.

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.

--
Shaun