plugin:asciisvg
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plugin:asciisvg [2009-12-03 16:41] – 193.175.53.21 | plugin: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:// | [[http:// | ||
This plugin integrates [[http:// | This plugin integrates [[http:// | ||
- | |||
- | - Update 1: 2008-08-05: The '' | ||
===== Installation ===== | ===== Installation ===== | ||
- | - Download the source archive (~11k)from [[http://www.mediafire.com/? | + | - Download the source archive (~11k)from [[http://littlewikiplugins.codeplex.com/releases/ |
- | - Unpack it in your DokuWiki plugins directory '' | + | - Unpack it in your DokuWiki plugins directory '' |
- '' | - '' | ||
- | | + | with the following files |
- | - Make sure you have enabled | + | |
+ | - d.svg | ||
+ | - script.js | ||
+ | - syntax.php | ||
+ | |||
+ | Thats it! | ||
+ | |||
+ | ===== Usage/Syntax ===== | ||
+ | < | ||
+ | < | ||
+ | </code> | ||
+ | **Example** | ||
+ | < | ||
+ | <asvg 117/ | ||
+ | initPicture(0, | ||
+ | a=[0,0]; b=[1,1] | ||
+ | rect(a,b) | ||
+ | stroke='red' | ||
+ | ellipse([.5, | ||
+ | stroke='blue' | ||
+ | ellipse([.5, | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | * For details syntax of ASCIIsvg see [[http:// | ||
+ | * Also http:// | ||
Line 32: | Line 57: | ||
** syntax.php** | ** syntax.php** | ||
<code php> | <code php> | ||
- | |||
<?php | <?php | ||
- | | + | /** |
- | /** | + | * Plugin |
- | | + | * |
- | * | + | * @license GPL 2 http:// |
- | * @license | + | * @author |
- | * @author | + | |
- | | + | |
- | + | | |
- | if(!defined(' | + | |
+ | */ | ||
+ | |||
+ | // must be run within DokuWiki | ||
+ | if(!defined(' | ||
if(!defined(' | if(!defined(' | ||
require_once(DOKU_PLUGIN.' | require_once(DOKU_PLUGIN.' | ||
- | + | ||
/** | /** | ||
* All DokuWiki plugins to extend the parser/ | * All DokuWiki plugins to extend the parser/ | ||
Line 51: | Line 80: | ||
*/ | */ | ||
class syntax_plugin_asciisvg extends DokuWiki_Syntax_Plugin { | class syntax_plugin_asciisvg extends DokuWiki_Syntax_Plugin { | ||
- | + | ||
/** | /** | ||
- | | + | |
*/ | */ | ||
function getInfo(){ | function getInfo(){ | ||
Line 62: | Line 91: | ||
' | ' | ||
' | ' | ||
- | ' | + | ' |
); | ); | ||
} | } | ||
- | + | ||
function getType(){ return ' | function getType(){ return ' | ||
- | function | + | function |
- | function getSort(){ return | + | function getSort(){ return |
- | } | + | |
- | //Setup VIM: ex: et ts=4 enc=utf-8 : | + | |
+ | /** | ||
+ | * Handle the match | ||
+ | */ | ||
+ | public function handle($match, | ||
+ | switch ($state) { | ||
+ | case DOKU_LEXER_ENTER : | ||
+ | list($width, | ||
+ | // if ($width="" | ||
+ | // if ($height="" | ||
+ | break; | ||
+ | case DOKU_LEXER_UNMATCHED : | ||
+ | return array($state, | ||
+ | break; | ||
+ | case DOKU_LEXER_EXIT : | ||
+ | return array($state, | ||
+ | break; | ||
+ | } | ||
+ | return array($state, | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Create output | ||
+ | */ | ||
+ | | ||
+ | if($mode != ' | ||
+ | list($state, | ||
+ | switch ($state) { | ||
+ | case DOKU_LEXER_ENTER : | ||
+ | list($width, | ||
+ | $renderer-> | ||
+ | break; | ||
+ | case DOKU_LEXER_MATCHED : | ||
+ | break; | ||
+ | case DOKU_LEXER_UNMATCHED : | ||
+ | $renderer-> | ||
+ | break; | ||
+ | case DOKU_LEXER_EXIT : | ||
+ | $renderer-> | ||
+ | break; | ||
+ | case DOKU_LEXER_SPECIAL : | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | ?> | ||
</ | </ | ||
Line 79: | Line 153: | ||
/* | /* | ||
This script installs the ASCIIsvg JavaScript | This script installs the ASCIIsvg JavaScript | ||
- | to be used through " | + | to be used through " |
- | Mohammad Rahmani | + | @license GPL 2 http:// |
+ | | ||
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 |
- | var ASCIIsvgURL =DOKU_BASE + ' | + | document.write('< |
- | + | ||
- | document.write('< | + | |
- | + | ||
- | + | ||
- | function installASCIIsvg() | + | |
- | { | + | |
- | ASCIIsvg.Process(document); | + | |
- | } | + | |
- | + | ||
- | addInitEvent(installASCIIsvg); | + | |
</ | </ | ||
- | ===== Usage/ | ||
- | * Make sure you have enabled '' | ||
- | < | ||
- | |||
- | < | ||
- | |||
- | < | ||
- | script=' | ||
- | > | ||
- | |||
- | </ | ||
- | |||
- | </ | ||
- | |||
- | 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:// | ||
- | There are many examples under [[http:// | ||
===== Samples ===== | ===== Samples ===== | ||
Line 122: | Line 177: | ||
== Example 1 == | == Example 1 == | ||
- | < | + | < |
- | + | <asvg 117/117> | |
- | <html> | + | |
- | <embed width=" | + | initPicture(-2.2,2.2,-2.2) |
- | script=' | + | line([-2,-2],[2,2]) |
- | axes() | + | marker = ' |
- | a = [0,0] | + | line([-2,2],[2,-2]) |
- | b = [5,5] | + | |
- | | + | </asvg> |
- | line(a,b) | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | path([a,[0,5],b,[5,0]]) | + | |
- | stroke = " | + | |
- | marker = " | + | |
- | curve([a, | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | marker = " | + | |
- | | + | |
- | </html> | + | |
</ | </ | ||
- | See the result here [[http:// | + | |
== Example 2 == | == Example 2 == | ||
- | < | + | < |
- | + | <asvg 250/250> | |
- | <html> | + | initPicture(-1,6,-1,6) |
- | <embed width=" | + | |
- | script=' | + | |
- | axes() | + | b = [5,5] |
- | a = 1 | + | marker = ' |
- | stroke | + | line(a,b) |
- | update()'> | + | |
- | < | + | text(b,' |
- | function update() { | + | text(b,' |
- | plot(function | + | text(b,' |
- | | + | text(b,' |
- | } | + | |
- | </ | + | |
- | + | | |
- | </html> | + | |
+ | | ||
+ | | ||
+ | stroke = ' | ||
+ | | ||
+ | curve([a,[.25, | ||
+ | stroke = ' | ||
+ | circle([5, | ||
+ | ellipse([0, | ||
+ | stroke = ' | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
</ | </ | ||
- | See the result here [[http:// | + | |
- | + | * Asciisvg in use, see this image: [[http:// | |
- | More examples in [[http:// | + | |
===== 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/ | * Interested developers are invited to correct/ | ||
* This plugin supports ASCIIsvg 1.2.7. The newer version is included in [[http:// | * This plugin supports ASCIIsvg 1.2.7. The newer version is included in [[http:// | ||
===== Issues ===== | ===== Issues ===== | ||
- | - It seems there is a minor conflict with [[plugin: | + | |
- | | + | |
===== 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