MultiMarkdown and MathML - new feature and request for help

Fletcher T.Penney fletcher at
Sat Jun 10 17:02:22 EDT 2006

A lot of people have expressed interest in combining math features
with Markdown, but I am not aware of any real developments from these

I was looking around and toying with [ASCIIMathPHP](http:// and integrated it with MultiMarkdown
and my xhtml2latex XSLT transforms.

You can include math as an inline formula by using a markup similar
to inline code, such as ``x^2 + y^2 = 1`` (note the double ``).

You can include a formula as a separate paragraph in the same way, or
with a leading tab like:

`x_(1,2) = (-b+-sqrt(b^2-4ac))/(2a)`

(Note the single use of ` when prefaced by a tab)

The leading tab is not required, but is allowed as I suspect most
people would like to be able to indent the formula to distinguish it
from regular text, and don't want it interpreted as a code block.

The processing occurs in a several steps:

1) ASCIIMathPHP is run on the source markdown document converting the
formulas into MathML blocks.

2) MultiMarkdown is then run in the usual manner, with or without

3) You can then optionally use XSLT to transform the XHTML into LaTeX
or whatever by using an updated version of my xhtml2latex, or your
own XSLT files. This includes the use of [XSLT MathML Library]
( to convert the MathML into LaTeX.

This allows you to generate XHTML with embedded MathML, or to
generate LaTeX source with the math properly displayed. More
importantly, it allows you to use ASCIIMath to enter your formulas
which is MUCH more human readable than either MathML or LaTeX.


I have run into a couple of snags, that I am sure would be quite
simple to fix if I knew more about XHTML and XSLT. To demonstrate, I
have included a sample plain text file (.txt), as well as two
versions of XHTML output - (.xhtml and .html) and a LaTeX file
(.tex). These were all generated automatically from the source plain
text file.

The .xhtml setup was designed using the layout from http://

It renders properly in Firefox (with the exception of that ugliness
in square root signs, but that is not my doing...), but I cannot use
this to go through my xhtml2latex.xslt workflow. It appears that the
problem lies in the xmlns attribute:

<html xmlns="">

If I remove that attribute, the xsltproc stuff works fine.

The .html file is built using the usual DOCTYPE etc from
MultiMarkdown. It does not render properly in Firefox, but it DOES
go through my xhtml2latex.xslt files properly, to generate valid
LaTeX output (i.e. the .tex file).

Also, if I take the .xhtml file and rename it with a .html extension,
it no longer renders properly in Firefox.

Once you have the .tex file, it goes without a snag through pdflatex
to generate a pdf.


I would appreciate any input available in how to smooth this process
a bit, specifically:

1) How can I create a valid document with a .html extension?
(requiring .xhtml is going to break a bunch of other stuff)

2) How do I fix my xhtml2latex stylesheets (http:// to work with a file
that has the xmlns attribute applied to the html node? (Or with
whatever comes out of an answer to #1 above)

3) Any suggestions on the markup syntax? I sort of arbitrarily
chose the use of an extra `. I am sure there is a better way of
doing this, and would love to hear input.

4) And less importantly, is there a perl version of ASCIIMath out
there somewhere? It would be great to be able to combine the code,
but this can be worked around. Definitely lower on the priority list.

Once I get all of this working more smoothly, I will release the
updated software for public use. For now, you can see how it works
with sample documents

Thanks in advance!


PS> Yes, I realize that the included mathematical equations are not
all correct. It's just a demo...

Fletcher T. Penney
fletcher at

I'll go through life either first class or third,
but never in second.
- Noel Coward

-------------- next part --------------
author: Fletcher T. Penney
Format: complete
Title: Sample MultiMarkdownMath Document

# Math Testing #

You can use math in-line, such as ``8 + 4 = 12`` and ``155 / 12 = 10 / 2``.

Or you can use as paragraphs:

``155 / 12 = 10 / 2``

``x^2 + y^2 = 1``

Or with a blockquote-like syntax:

`x_(1,2) = (-b+-sqrt(b^2-4ac))/(2a)`

Code is not translated: `x = pi`
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.xhtml
Type: application/octet-stream
Size: 2627 bytes
Desc: not available
Url :
-------------- next part --------------
An HTML attachment was scrubbed...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.tex
Type: application/octet-stream
Size: 1981 bytes
Desc: not available
Url :
-------------- next part --------------

More information about the Markdown-Discuss mailing list