1<?php 2/** 3 * <text> tag that embeds plain text with linebreaks 4 */ 5 6// must be run within Dokuwiki 7if(!defined('DOKU_INC')) die(); 8 9/** 10 * All DokuWiki plugins to extend the parser/rendering mechanism 11 * need to inherit from this class 12 */ 13class syntax_plugin_plaintext_inline extends DokuWiki_Syntax_Plugin { 14 15 function getType() { return 'protected';} 16 function getPType() { return 'normal';} 17 function getSort() { return 20; } 18 19 /** 20 * Connect pattern to lexer 21 */ 22 function connectTo($mode) { 23 $this->Lexer->addSpecialPattern('<text>.*?</text>', $mode, 'plugin_plaintext_inline'); 24 } 25 26 /** 27 * Handle the match 28 */ 29 function handle($match, $state, $pos, Doku_Handler $handler){ 30 return substr($match,6,-7); 31 } 32 33 /** 34 * Create output 35 */ 36 function render($format, Doku_Renderer $renderer, $data) { 37 if($format == 'xhtml'){ 38 $renderer->doc .= str_replace( "\n", "<br/>".DOKU_LF, trim($renderer->_xmlEntities($data),"\n") ); 39 return true; 40 }else if($format == 'metadata'){ 41 $renderer->doc .= trim($data); 42 return true; 43 } 44 return false; 45 } 46} 47