Beispiel #1
0
/**
 * ASCIIMathML parser
 * http://tinyurl.com/ASCIIMathPHP
 *
 * @PARAM mtch_arr array - Array of ASCIIMath expressions
 *   as returned by preg_replace_callback([pattern]). First
 *   dimension is the full matched string (with delimiter);
 *   2nd dimension is the undelimited contents (typically
 *   a capture group).
 *
 **********************************************************/
function ASCIIMathPHPCallback($mtch_arr)
{
    $txt = trim($mtch_arr[1]);
    static $asciimath;
    if (!isset($asciimath)) {
        $asciimath = new ASCIIMathPHP($symbol_arr);
    }
    $math_attr_arr = array('displaystyle' => 'true');
    $asciimath->setExpr($txt);
    $asciimath->genMathML($math_attr_arr);
    return $asciimath->getMathML();
}
Beispiel #2
0
/**
 * ASCIIMathML parser
 * http://tinyurl.com/ASCIIMathPHP
 *
 * @PARAM mtch_arr array - Array of ASCIIMath expressions
 *   as returned by preg_replace_callback([pattern]). First
 *   dimension is the full matched string (with delimiter);
 *   2nd dimension is the undelimited contents (typically
 *   a capture group).
 *
 **********************************************************/
function ASCIIMathPHPCallback($mtch_arr)
{
    $txt = trim($mtch_arr[1]);
    include 'includes/ASCIIMathPHP-2.0/ASCIIMathPHP-2.0.cfg.php';
    require_once 'includes/ASCIIMathPHP-2.0/ASCIIMathPHP-2.0.class.php';
    static $asciimath;
    if (!isset($asciimath)) {
        $asciimath = new ASCIIMathPHP($symbol_arr);
    }
    $math_attr_arr = array('displaystyle' => 'true');
    $asciimath->setExpr($txt);
    $asciimath->genMathML($math_attr_arr);
    return $asciimath->getMathML();
}