4 * Copyright 2005 $ThePhpWikiProgrammingTeam
5 * Copyright 2009 Marc-Etienne Vargenau, Alcatel-Lucent
7 * This file is part of PhpWiki.
9 * PhpWiki is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * PhpWiki is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once 'lib/ASCIIMathPHP/ASCIIMathPHP.class.php';
27 * Render ASCII math as MathML
28 * Requires ENABLE_XHTML_XML = true
29 * See http://www.jcphysics.com/ASCIIMath/
30 * Syntax: http://www1.chapman.edu/~jipsen/mathml/asciimathsyntax.xml
31 * Example: "int_-1^1 sqrt(1-x^2)dx = pi/2"
32 * => <math xmlns="http://www.w3.org/1998/Math/MathML">
33 <mrow><msubsup><mo>∫</mo><mn>-1</mn><mn>1</mn></msubsup></mrow>
34 <msqrt><mrow><mn>1</mn><mo>-</mo><msup><mi>x</mi><mn>2</mn></msup></mrow></msqrt>
38 <mfrac><mi>π</mi><mo>2</mo></mfrac>
41 class WikiPlugin_AsciiMath
46 return _("AsciiMath");
49 function getDescription()
51 return _("Render ASCII Math as MathML.");
54 function getDefaultArguments()
59 function handle_plugin_args_cruft(&$argstr, &$args)
61 $this->source = $argstr;
64 function run($dbi, $argstr, &$request, $basepage)
66 $args = $this->getArgs($argstr, $request);
67 if (empty($this->source)) {
68 return HTML::div(array('class' => "error"), "Please provide a formula to AsciiMath plugin");
71 include 'lib/ASCIIMathPHP/ASCIIMathPHP.cfg.php';
72 $ascii_math = new ASCIIMathPHP($symbol_arr, $this->source);
73 $ascii_math->genMathML();
74 return HTML::raw($ascii_math->getMathML());
82 // c-hanging-comment-ender-p: nil
83 // indent-tabs-mode: nil