text * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Tom Trenker */ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_xterm extends DokuWiki_Syntax_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'Tom Trenker', 'email' => 'tom_trenker@yahoo.com', 'date' => '2006-08-26', 'name' => 'xterm Plugin', 'desc' => 'for displaying xterm output using Preformatted text', 'url' => 'http://www.dokuwiki.org/plugin:xterm', ); } /** * What kind of syntax are we? */ function getType(){ return 'formatting'; } /** * What kind of syntax do we allow (optional) */ function getAllowedTypes() { return array('formatting', 'disabled'); } /** * What about paragraphs? (optional) */ function getPType(){ return 'normal'; } /** * Where to sort in? */ function getSort(){ return 195; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addEntryPattern('(?=.*)',$mode,'plugin_xterm'); /* $this->Lexer->addEntryPattern('(?i)(?=.+)',$mode,'plugin_xterm'); */ } function postConnect() { $this->Lexer->addExitPattern('', 'plugin_xterm'); /* $this->Lexer->addExitPattern('(?i)','plugin_xterm'); */ } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ switch ($state) { case DOKU_LEXER_ENTER : break; case DOKU_LEXER_MATCHED : break; case DOKU_LEXER_UNMATCHED : break; case DOKU_LEXER_EXIT : break; case DOKU_LEXER_SPECIAL : break; } return array($match, $state); } /** * Create output */ function render($mode, &$renderer, $data) { if($mode == 'xhtml'){ if ($data[1] == DOKU_LEXER_ENTER){ $renderer->doc .= '
';       #     
';
            } else if ($data[1] == DOKU_LEXER_UNMATCHED){
                $renderer->doc .= $renderer->_xmlEntities($data[0]);
            } else if ($data[1] == DOKU_LEXER_EXIT){
                $renderer->doc .= '
'; # '
'; } return true; } return false; } } //Setup VIM: ex: et ts=4 enc=utf-8 : ?>