DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:masciimath

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:masciimath [2011-06-22 00:13] 87.73.100.138plugin:masciimath [2022-07-29 23:30] (current) Klap-in
Line 2: Line 2:
  
 ---- plugin ---- ---- plugin ----
-description: Implementation of ASCIIMathPHP for Dokuwiki+description: Simple beautiful math - server-side ASCIIMathML to MathML parsing
 author     : Morten Nielsen  author     : Morten Nielsen 
 email      : mortenb@gmail.com email      : mortenb@gmail.com
 type       : syntax type       : syntax
-lastupdate : 2011-06-22 +lastupdate : 2014-04-22 
-compatible : Tested with 2011-05-25a “Rincewind”+compatible : Weatherwax
 depends    :  depends    : 
 conflicts  conflicts 
Line 13: Line 13:
 tags       : Formula, Math tags       : Formula, Math
  
-downloadurl: # eg. http://github.com//dokuwiki-plugin-masciimath/zipball/master +downloadurl: https://github.com/M0rtenB/dokuwiki-masciimath/zipball/master 
-bugtracker : # eg. http://github.com//dokuwiki-plugin-masciimath/issues +bugtracker : https://github.com/M0rtenB/dokuwiki-masciimath/issues 
-sourcerepo : # eg. http://github.com//dokuwiki-plugin-masciimath/+sourcerepo : https://github.com/M0rtenB/dokuwiki-masciimath
 donationurl:  donationurl: 
 ---- ----
Line 21: Line 21:
 === Description === === Description ===
  
-This is an implementation of [[http://www.oldschool.com.sg/index.php/module/Shared/action/Static/tmpl/ASCIIMathPHP|ASCIIMathPHP]] for DokuWiki. ASCIIMathPHP is a PHP port of the brilliant [[wp>ASCIIMathML]] standard for easy encoding of math.+This is an implementation of Peter Jipsen's ASCIIMathML.js, but in pure PHP, i.ethe translation is done serverside, and no JavaScript is necessary.
  
-It's similar to [[plugin:asciimathml]] but doesn't rely on JavaScript. +To try it out: 
- +  * Install the plugin, i.e. create folder called "masciimath" in the Dokuwiki plugin folder, and put the plugin files here
-=== Installation and Plugin Code === +  * Create a wikipage with the following ASCIIMathML code in it: <code>`x_(1,2)=(-b+-sqrt(b^2-4a c))/(2a)`</code
- +  * View your wiki using Firefox (the only browser with a complete MathML implementation).
-Create a plugin directory named ''masciimath'' and put these files in it: +
-  - ''syntax.php'' from below +
-  - ''ASCIIMathPHP.cfg.php'' and ''ASCIIMathPHP.class.php'' from the ASCIIMathPHP download (you may have to rename them) +
- +
-<file php syntax.php> +
-<?php +
-/** +
- * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html) +
- * @author     Morten Nielsen <mortenb@gmail.com> +
- */ +
- +
-if(!defined('DOKU_INC')) die(); +
-if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/')+
-require_once(DOKU_PLUGIN.'syntax.php'); +
-include_once(dirname(__FILE__).'/ASCIIMathPHP.class.php'); +
- +
-class syntax_plugin_masciimath extends DokuWiki_Syntax_Plugin { +
- +
-    function getInfo(){ +
-        return array( +
-            'author' => 'Morten Nielsen', +
-            'email'  => 'mortenb@gmail.com', +
-            'date'   => '2011-06-22', +
-            'name'   => 'M-AsciiMath', +
-            'desc'   => 'Implementation of AsciiMathPHP for DokuWiki', +
-            'url'    => 'http://www.dokuwiki.org/wiki:plugins', +
-        ); +
-    } +
- +
-    function getType(){ return 'substition';+
-    function getSort(){ return 300; } +
-    function connectTo($mode) { $this->Lexer->addSpecialPattern('`.*?`',$mode,'plugin_masciimath');+
- +
-    function handle($match, $state, $pos, &$handler){ +
-      $txt = $match; +
-      $txt = str_replace('`', '', $txt); +
-      include(dirname(__FILE__).'/ASCIIMathPHP.cfg.php'); +
-      $math_object = new ASCIIMathPHP($symbol_arr); +
-   $math_object->setExpr($txt)+
-   $math_object->genMathML()+
-   $txt = $math_object->getMathML(); +
-   #$txt = preg_replace ('/<math(.*)>/i', '<math$1><mstyle fontfamily="sans-serif" displaystyle="true">', $txt); +
-   #$txt = preg_replace ('/<\/math>/i', '</mstyle></math>', $txt); +
-   $raw = $match; +
-   $raw = str_replace ('"', "''", $raw);  # compromise .. +
-   return array($txt, $raw)+
-+
- +
-    function render($mode, &$renderer, $data) { +
-        if ($mode!='xhtml') return false; +
-        list($txt, $raw) = $data; +
-        $renderer->doc .= '<span class="acmath" title="'.$raw.'">'.$txt.'</span>'; +
-        return true; +
-    } +
-+
-?> +
-</file> +
- +
-=== Discussion === +
- +
-The two commented lines beautify the output IMHO, uncomment them if you prefer.+
plugin/masciimath.1308694386.txt.gz · Last modified: 2011-06-22 00:13 by 87.73.100.138

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki