1<?php 2/** 3 * Mediasyntax Plugin: Mediawiki style teletyper text 4 * 5 * This is a part of the mediasyntax plugin for dokuwiki. It handles the <tt> tag. 6 * 7 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 8 * @author Thorsten Staerk <dev@staerk.de> 9 */ 10class syntax_plugin_mediasyntax_teletyper extends DokuWiki_Syntax_Plugin 11{ 12 13 function getType() { return 'protected'; } 14 function getSort() { return 40; } 15 16 function connectTo($mode) 17 { 18 $this->Lexer->addEntryPattern( 19 '<tt>', 20 $mode, 21 'plugin_mediasyntax_teletyper' 22 ); 23 } 24 25 function postConnect() 26 { 27 $this->Lexer->addExitPattern( 28 '</tt>', 29 'plugin_mediasyntax_teletyper' 30 ); 31 } 32 33 function handle($match, $state, $pos, Doku_Handler $handler) 34 { 35 dbglog("entering function ".__FUNCTION__.", match is $match, state is $state, pos is $pos"); 36 if ($state == DOKU_LEXER_UNMATCHED) return array($state,$match); 37 if ($state == DOKU_LEXER_ENTER) return array($state,$match); 38 if ($state == DOKU_LEXER_EXIT) return array($state,$match); 39 } 40 41 function render($mode, Doku_Renderer $renderer, $data) 42 // For understanding this see the very valuable code by Christopher Smith on http://www.dokuwiki.org/devel:syntax_plugins 43 // $data is always what the function handle returned! 44 { 45 dbglog("entering function ".__FUNCTION__.", mode is $mode, data is $data, data's type is ".gettype($data)); 46 list($state,$match) = $data; 47 dbglog("state is $state, match is $match"); 48 if ($mode == 'xhtml') 49 { 50 if ($state==DOKU_LEXER_ENTER) $renderer->doc .= "<tt>"; 51 if ($state==DOKU_LEXER_UNMATCHED) $renderer->doc .= $match; 52 if ($state==DOKU_LEXER_EXIT) $renderer->doc .= "</tt>"; 53 } 54 return false; 55 } 56} 57 58//Setup VIM: ex: et ts=4 enc=utf-8 : 59