1<?php
2/**
3 * Textile2-Plugin: Parses Textile2-blocks
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Ryan Schwartz <textile@ryanschwartz.net>
7 */
8
9// must be run within Dokuwiki
10if(!defined('DOKU_INC')) die();
11
12if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
13require_once(DOKU_PLUGIN.'syntax.php');
14require_once(DOKU_PLUGIN.'textile2/classTextile.php');
15
16
17/**
18 * All DokuWiki plugins to extend the parser/rendering mechanism
19 * need to inherit from this class
20 */
21class syntax_plugin_textile2 extends DokuWiki_Syntax_Plugin {
22
23    /**
24     * return some info
25     */
26    function getInfo(){
27        return array(
28            'author' => 'Ryan Schwartz',
29            'email'  => 'textile@ryanschwartz.net',
30            'date'   => '2007-02-06',
31            'name'   => 'Textile2 Plugin',
32            'desc'   => 'Parses Textile2-blocks',
33            'url'    => 'http://wiki.splitbrain.org/plugin:textile2',
34        );
35    }
36
37    /**
38     * What kind of syntax are we?
39     */
40    function getType(){
41        return 'protected';
42    }
43
44    /**
45     * Where to sort in?
46     */
47    function getSort(){
48        return 69;
49    }
50
51    function getPType() {
52        return 'block';
53    }
54
55    /**
56     * Connect pattern to lexer
57     */
58    function connectTo($mode) {
59        $this->Lexer->addEntryPattern('<textile>(?=.*</textile>)',$mode,'plugin_textile2');
60    }
61
62    function postConnect() {
63      $this->Lexer->addExitPattern('</textile>','plugin_textile2');
64    }
65
66    /**
67     * Handle the match
68     */
69    function handle($match, $state, $pos, &$handler){
70        return array($match);
71    }
72
73    /**
74     * Create output
75     */
76    function render($mode, &$renderer, $data) {
77        if($mode == 'xhtml' && $data[0] != "<textile>" && $data[0] != "</textile>") {
78            $renderme = new Textile;
79            $renderer->doc .= $renderme->TextileThis($data[0]);
80            return true;
81        }
82        return false;
83    }
84
85}
86
87//Setup VIM: ex: et ts=4 enc=utf-8 :
88?>
89