This software is a Perl extension that can convert ASCIIMathML text to MathML format. It can be used for parsing mathematical expressions written in ASCIIMathML and converting them into a more digitally-friendly format.
One of the attributes available is ForMoz, which specifies that fonts should be optimized for Netscape/Mozilla/Firefox. The parser outputs the MathML in the schema < mstyle >...< /mstyle >< /math >, and the first argument of TextToMathML is the ASCIIMathML text to be parsed into MathML. The second argument is a reference to an array of attribute/value pairs to be attached to the < math > node, and the third argument is a reference to an array of attribute/value pairs for the < mstyle > node.
Common attributes for the < math > node include "title" and "xmlns"=>"&mathml;". For the < mstyle > node, common attributes include "mathcolor" (for text color), "displaystyle"=>"true" for using display style instead of inline style, and "fontfamily".
The code snippet below shows how to use Text::ASCIIMathML:
use Text::ASCIIMathML;
$parser=new Text::ASCIIMathML();
$parser->SetAttributes(ForMoz => 1);
$ASCIIMathML = "int_0^1 e^x dx";
$mathML = $parser->TextToMathML($ASCIIMathML);
$mathML = $parser->TextToMathML($ASCIIMathML, [title=>$ASCIIMathML]);
$mathML = $parser->TextToMathML($ASCIIMathML, undef, [displaystyle=>1]);
$mathMLTree = $parser->TextToMathMLTree($ASCIIMathML);
$mathMLTree = $parser->TextToMathMLTree($ASCIIMathML, [title=>$ASCIIMathML]);
$mathMLTree = $parser->TextToMathMLTree($ASCIIMathML,undef,[displaystyle=>1]);
$mathML = $mathMLTree->text();
$latex = $mathMLTree->latex();
Overall, Text::ASCIIMathML is a powerful and customizable tool for converting ASCIIMathML text into MathML XML markup strings.
Version 0.81: N/A