DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:asciisvg

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:asciisvg [2009-12-03 16:41] 193.175.53.21plugin:asciisvg [2022-07-29 23:27] (current) Klap-in
Line 6: Line 6:
 email      : m.rahmani@aut.ac.ir email      : m.rahmani@aut.ac.ir
 type       : Syntax type       : Syntax
-lastupdate : 2008-08-05 +lastupdate : 2011-06-25 
-compatible : +compatible : Lemming, Anteater, Rincewind
 depends    :  depends    : 
 conflicts  conflicts 
Line 17: Line 17:
 [[http://www1.chapman.edu/~jipsen/svg/asciisvgcommands.html | ASCIIsvg]] is a layer of JavaScript functions that can be used in any HTML document to produce inline Scalable Vector Graphics viewable with both [[http://www.microsoft.com/windows/products/winfamily/ie/default.mspx | Internet Explorer]]+[[http://www.adobe.com/svg | Adobe SVGviewer]] and [[http://www.mozilla.com/en-US/firefox/ | Firefox 1.5 and later]]. [[http://www1.chapman.edu/~jipsen/svg/asciisvgcommands.html | ASCIIsvg]] has been developed by Prof. [[http://www1.chapman.edu/%7Ejipsen | Peter Jipsen]] at the university of Chapman. [[http://www1.chapman.edu/~jipsen/svg/asciisvgcommands.html | ASCIIsvg]] is a layer of JavaScript functions that can be used in any HTML document to produce inline Scalable Vector Graphics viewable with both [[http://www.microsoft.com/windows/products/winfamily/ie/default.mspx | Internet Explorer]]+[[http://www.adobe.com/svg | Adobe SVGviewer]] and [[http://www.mozilla.com/en-US/firefox/ | Firefox 1.5 and later]]. [[http://www1.chapman.edu/~jipsen/svg/asciisvgcommands.html | ASCIIsvg]] has been developed by Prof. [[http://www1.chapman.edu/%7Ejipsen | Peter Jipsen]] at the university of Chapman.
 This plugin integrates [[http://www1.chapman.edu/~jipsen/svg/asciisvgcommands.html | ASCIIsvg]] into DokuWiki. This plugin integrates [[http://www1.chapman.edu/~jipsen/svg/asciisvgcommands.html | ASCIIsvg]] into DokuWiki.
- 
-  - Update 1: 2008-08-05: The ''script.js'' was corrected. Now the main ''ASCIIsvg.js'' script resides in ''asciisvg/main'' folder. No need for separate folder under DokuWiki root. 
  
 ===== Installation ===== ===== Installation =====
  
-  - Download the source archive (~11k)from [[http://www.mediafire.com/?glkfqz5hunw|asciisvg]] +  - Download the source archive (~11k)from [[http://littlewikiplugins.codeplex.com/releases/view/68871|asciisvg]] 
-  - Unpack it in your Doku­Wiki plugins directory ''{dokuwiki}/lib/plugins'' (make sure, in­clu­ded sub­di­rec­to­ries are un­packed cor­rect­ly); this will create the following di­rec­tories+  - Unpack it in your Doku­Wiki plugins directory ''{dokuwiki}/lib/plugins'' (make sure, in­clu­ded sub­di­rec­to­ries are un­packed cor­rect­ly); this will create the following following folder
     - ''{dokuwiki}/lib/plugins/asciisvg''.     - ''{dokuwiki}/lib/plugins/asciisvg''.
-    ''{dokuwiki}/lib/plugins/asciisvg/main''+with the following files 
-  - Make sure you have enabled ''Allow embedded HTML'' in your DokuWiki Configuration Manager+  ASCIIsvg127.js 
 +  - d.svg 
 +  - script.js 
 +  - syntax.php 
 + 
 +Thats it! 
 + 
 +===== Usage/Syntax ===== 
 +<code> 
 + <asvg  width/height> ASCIIsvg notation goes here </asvg> 
 +</code> 
 +**Example** 
 +<code> 
 +<asvg 117/117> 
 +initPicture(0,1,0) 
 +a=[0,0]; b=[1,1] 
 +rect(a,b) 
 +stroke='red' 
 +ellipse([.5,.5],.5,.25) 
 +stroke='blue' 
 +ellipse([.5,.5],.25,.5) 
 +</asvg> 
 +</code> 
 + 
 + 
 + 
 +  * For details syntax of ASCIIsvg see [[http://www1.chapman.edu/~jipsen/svg/asciisvgcommands.html|ASCIIsvg command page]] 
 +  * Also http://www1.chapman.edu/~jipsen/svg/asciisvg.html
  
  
Line 32: Line 57:
 ** syntax.php** ** syntax.php**
 <code php> <code php>
- 
 <?php <?php
-  /** +/** 
-  /** + * Plugin ColorSets new colors for text and background
-    * Plugin ASCIIsvgUse ASCIIsvg for translating ASCII notation to SVG graphics+ * 
-    + * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 
-    * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html) + * @author  Mohammad Rahmani <m [dot] rahmani [at] aut [dot] ac [dot] ir> 
-    * @author     Mohammad Rahmani <m.rahmani@aut.ac.ir> + 
-   */ +  Rev. 0.20: Some bugs fixed, support for DokuWiki 2011-05-25a 
-  +  Date: Thursday, June 23, 2011 
-if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');+ 
 + */ 
 + 
 +// must be run within DokuWiki 
 +if(!defined('DOKU_INC')) die(); 
 if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
 require_once(DOKU_PLUGIN.'syntax.php'); require_once(DOKU_PLUGIN.'syntax.php');
- +
 /** /**
  * All DokuWiki plugins to extend the parser/rendering mechanism  * All DokuWiki plugins to extend the parser/rendering mechanism
Line 51: Line 80:
  */  */
 class syntax_plugin_asciisvg extends DokuWiki_Syntax_Plugin { class syntax_plugin_asciisvg extends DokuWiki_Syntax_Plugin {
- +
     /**     /**
-     Get an associative array with plugin info.+     return some info
      */      */
     function getInfo(){     function getInfo(){
Line 62: Line 91:
             'name'   => 'ASCIIsvg Plugin',             'name'   => 'ASCIIsvg Plugin',
             'desc'   => 'Translating ASCII math notation to SVG graphics',             'desc'   => 'Translating ASCII math notation to SVG graphics',
-            'url'    => 'http://www.dokuwiki.org/plugin:asciisvg',+            'url'    => 'http://wiki.splitbrain.org/plugin:asciisvg',
                      );                      );
     }     }
- +
     function getType(){ return 'formatting'; }     function getType(){ return 'formatting'; }
-    function getPType(){ return 'normal'; } +    function getAllowedTypes() { return array('formatting', 'substition', 'disabled'); } 
-    function getSort(){ return 451; } +    function getSort(){ return 158; } 
- } +    function connectTo($mode) { $this->Lexer->addEntryPattern('<asvg.*?>(?=.*?</asvg>)',$mode,'plugin_asciisvg'); 
-//Setup VIM: ex: et ts=4 enc=utf-8 :+    function postConnect() { $this->Lexer->addExitPattern('</asvg>','plugin_asciisvg'); }
  
 +/**
 +     * Handle the match
 +     */
 +    public function handle($match, $state, $pos, &$handler){
 +        switch ($state) {
 +        case DOKU_LEXER_ENTER :
 +            list($width, $height) = preg_split("/\//u", substr($match, 6, -1), 2);
 +//            if ($width="") $width="200";
 +//            if ($height="") $height="200";
 +            break;
 +        case DOKU_LEXER_UNMATCHED :
 +            return array($state, $match);
 +            break;
 +        case DOKU_LEXER_EXIT :
 +            return array($state, '');
 +            break;
 +        }
 +        return array($state, array($width, $height));
 +    }
 +
 +    /**
 +     * Create output
 +     */
 +     public function render($mode, &$renderer, $data) {
 +        if($mode != 'xhtml') return false;
 +        list($state, $match) = $data;
 +        switch ($state) {
 +        case DOKU_LEXER_ENTER :
 +            list($width, $height) = $match;
 +            $renderer->doc .= "<embed  src='d.svg' width='$width' height='$height'  script='";
 +            break;
 +        case DOKU_LEXER_MATCHED :
 +            break;
 +         case DOKU_LEXER_UNMATCHED :
 +            $renderer->doc .= $renderer->_xmlEntities($match);
 +            break;
 +         case DOKU_LEXER_EXIT :
 +            $renderer->doc .="'>";
 +            break;
 +        case DOKU_LEXER_SPECIAL :
 +            break;
 +        }
 +    }
 +}
 +?>
  
 </code> </code>
Line 79: Line 153:
 /* /*
  This script installs the ASCIIsvg JavaScript  This script installs the ASCIIsvg JavaScript
- to be used through "asciisvg" plugin in DokuWiki + to be used through "asciisvg" plugin in Dokuwiki 
-  Mohammad Rahmani+ @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 
 + @author  Mohammad Rahmani <m [dot] rahmani [at] aut [dot] ac [dot] ir> 
   Date: Sunday, 03 Aug. 2008  14:46:45   Date: Sunday, 03 Aug. 2008  14:46:45
-  Rev. 0: experimental+  Rev. 0: exprimental 
 + 
 + Rev. 0.2: Some bugs fixed 
 + Date: Thursday, June 23, 2011 
 +   - all function in the previos script.js was deleted! 
 +   - support for the latest version of Dokuwiki (2011-5-25a)
 */ */
  
-// full url to ASCIIsvg main script +// full address to ASCIIsvg main script 
-var ASCIIsvgURL =DOKU_BASE + 'lib/plugins/asciisvg/main/ASCIIsvg127.js'; +document.write('<script type="text/javascript" src="'DOKU_BASE + '/lib/plugins/asciisvg/ASCIIsvg127.js' + '"></script>');
- +
-document.write('<script type="text/javascript" src="'ASCIIsvgURL + '"></script>'); +
- +
- +
-function installASCIIsvg() +
-+
-    ASCIIsvg.Process(document); +
-+
- +
-addInitEvent(installASCIIsvg);+
  
 </code> </code>
  
-===== Usage/Syntax ===== 
-  * Make sure you have enabled ''Allow embedded HTML'' in DokuWiki ''Configuration Manager'' 
-<code> 
-  
- <html> 
- 
- <embed width="in pixels" height="in pixels" 
-  script='...ASCIIsvg commands...' 
- > 
- 
- </html> 
- 
-</code> 
- 
-This is the syntax for the tag that inserts the pictures on the wiki page. The ASCIIsvg commands are put between single quotes in the script attribute. The width and height are measured in pixels. For detailed discussion take a look at [[http://www.chapman.edu/~jipsen/svg/asciisvgcommands.html | ASCIIsvg commands]]. \\ 
-There are many examples under [[http://math.chapman.edu/cgi-bin/math.pl?ASCIIsvg_Gallery | ASCIIsvg Gallery]]. 
  
 ===== Samples ===== ===== Samples =====
Line 122: Line 177:
  
 == Example 1 == == Example 1 ==
-<code html+<code javascript
- +    <asvg 117/117
-<html+      
-<embed width="200" height="200" +    initPicture(-2.2,2.2,-2.2
-script=' initPicture(-1,6,-1,6+    line([-2,-2],[2,2]) 
- axes() +    marker = 'arrowdot' 
- a = [0,0] +    line([-2,2],[2,-2]) 
- b = [5,5] +      
- marker = "dot" +    </asvg>
- line(a,b) +
- text(a,"a",belowright) +
- text(b,"g",above) +
- text(b,"b",right) +
- text(b,"b",left) +
- text(b,"b",below) +
- text(b,"b",aboveleft) +
- text(b,"b",aboveright) +
- text(b,"b",belowleft) +
- text(b,"b",belowright) +
- stroke = "red" +
- path([a,[0,5],b,[5,0]]) +
- stroke = "green" +
- marker = "none" +
- curve([a,[.25,0],[.5,.5],[1,1],[1.5,1.5]]) +
- stroke = "blue" +
- circle([5,0],1) +
- ellipse([0,5],1,2+
- stroke = "purple" +
- rect([0,0],[2,2],null,.5,1+
- marker = "arrowdot" +
- line(a,[5,0])'> +
-</html>+
  
 </code> </code>
  
-See the result here [[http://people.web.psi.ch/geus/tiddly/asciisvgsample.html | Diagram 1]] (The diagram on the **left**).+
  
 == Example 2 == == Example 2 ==
  
-<code html+<code javascript
- +    <asvg 250/250
-<html+    initPicture(-1,6,-1,6
-<embed width="200" height="200" +     axes() 
-script='initPicture(-2,2+     a = [0,0] 
-axes() +     b [5,5] 
-a = 1 +     marker = 'dot' 
-stroke "blue" +     line(a,b) 
-update()'> +     text(a,'a',belowright) 
-<script> +     text(b,'g',above) 
-function update() { +     text(b,'b',right
-  plot(function (x){return a*x*x*x-x},"cubic"+     text(b,'b',left) 
-  setText(a,"aval"); +     text(b,'b',below) 
-} +     text(b,'b',aboveleft) 
-</script> +     text(b,'b',aboveright) 
- +     text(b,'b',belowleft) 
-</html> +     text(b,'b',belowright) 
 +     stroke = 'red' 
 +     path([a,[0,5],b,[5,0]]
 +     stroke = 'green' 
 +     marker = 'none' 
 +     curve([a,[.25,0],[.5,.5],[1,1],[1.5,1.5]]
 +     stroke = 'blue' 
 +     circle([5,0],1) 
 +     ellipse([0,5],1,2) 
 +     stroke = 'purple' 
 +     rect([0,0],[2,2],null,.5,1) 
 +     marker = 'arrowdot' 
 +     line(a,[5,0]) 
 +    </asvg>
 </code> </code>
  
-See the result here  [[http://people.web.psi.ch/geus/tiddly/asciisvgsample.html | Diagram 2]] (The diagram on the **right**). +  * More examples in [[http://math.chapman.edu/cgi-bin/math.pl?ASCIIsvg_Sandbox | ASCIIsvg sandbox]] 
- +  * Asciisvg in use, see this image: [[http://littlewikiplugins.codeplex.com/documentation|asciisvg in use]]
-More examples in [[http://math.chapman.edu/cgi-bin/math.pl?ASCIIsvg_Sandbox | ASCIIsvg sandbox]]+
  
 ===== ToDo ===== ===== ToDo =====
-  * The ASCIIsvg was implemented as a pseudo plugin here. It seems the plugin simply adds the ASCIIsvg.js into DokuWiki. It is better to add the script as a real plugin to support a syntax without enabling the embeded HTML. 
-  * The addition of ASCIIsvg.js into DokuWiki can be implemented in a more secure and safer way. 
   * Interested developers are invited to correct/modify the code to obey the DokuWiki rules. FIXME   * Interested developers are invited to correct/modify the code to obey the DokuWiki rules. FIXME
   * This plugin supports ASCIIsvg 1.2.7. The newer version is included in [[http://www1.chapman.edu/~jipsen/mathml/asciimath.html | ASCIIMatML]] and does not supported by this plugin :!:.   * This plugin supports ASCIIsvg 1.2.7. The newer version is included in [[http://www1.chapman.edu/~jipsen/mathml/asciimath.html | ASCIIMatML]] and does not supported by this plugin :!:.
  
 ===== Issues ===== ===== Issues =====
-  - It seems there is a minor conflict with [[plugin:indexmenu]]. When [[plugin:asciisvg]] is active the mouse right-click on the trees does not work. +    - There is a conflict with [[plugin:jsmath]]. When [[plugin:asciisvg]] is installed jsMath does not work anymore.
-  - There is a conflict with [[plugin:jsmath]]. When [[plugin:asciisvg]] is installed jsMath does not work anymore.+
  
 ===== Discussion ===== ===== Discussion =====
  
-It doesnt work with the newest Version it seems. Its 2009-02-14b. 
-I installed the newest plugin version, copied an example to a page but it doesnt show anything. FIXME 
plugin/asciisvg.1259854906.txt.gz · Last modified: 2009-12-03 16:41 by 193.175.53.21

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