2 rcs_id('$Id: AsciiMath.php,v 1.2 2007-02-22 19:55:44 rurban Exp $');
4 Copyright 2005 $ThePhpWikiProgrammingTeam
6 This file is part of PhpWiki.
8 PhpWiki is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 PhpWiki is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with PhpWiki; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 require_once("lib/ASCIIMathPHP/ASCIIMathPHP.class.php");
26 * Render ASCII math as MathML
27 * Requires ENABLE_XHTML_XML = true
28 * See http://www.jcphysics.com/ASCIIMath/
29 * Syntax: http://www1.chapman.edu/~jipsen/mathml/asciimathsyntax.xml
30 * Example: "int_-1^1 sqrt(1-x^2)dx = pi/2"
31 * => <math xmlns="http://www.w3.org/1998/Math/MathML">
32 <mrow><msubsup><mo>∫</mo><mn>-1</mn><mn>1</mn></msubsup></mrow>
33 <msqrt><mrow><mn>1</mn><mo>-</mo><msup><mi>x</mi><mn>2</mn></msup></mrow></msqrt>
37 <mfrac><mi>π</mi><mo>2</mo></mfrac>
40 class WikiPlugin_AsciiMath
44 return _("AsciiMath");
47 function getDescription() {
48 return _("Render ASCII Math as MathML");
51 function getVersion() {
52 return preg_replace("/[Revision: $]/", '',
56 function getDefaultArguments() {
59 function handle_plugin_args_cruft(&$argstr, &$args) {
60 $this->source = $argstr;
63 function run($dbi, $argstr, &$request, $basepage) {
64 $args = $this->getArgs($argstr, $request);
65 if (empty($this->source))
68 include("lib/ASCIIMathPHP/ASCIIMathPHP.cfg.php");
69 $ascii_math = new ASCIIMathPHP($symbol_arr, $this->source);
70 $ascii_math->genMathML();
71 return HTML::Raw($ascii_math->getMathML());
75 // $Log: not supported by cvs2svn $
76 // Revision 1.1 2005/01/29 21:50:38 rurban
77 // new MathML plugin and lib
84 // c-hanging-comment-ender-p: nil
85 // indent-tabs-mode: nil