Use toMathML rather than regular expression to handle alttext, and use proper attribute (alttext, not alt).  Fix up some formatting.