1<?php 2/** 3 * DokuWiki Plugin floatdiv (Syntax Component) 4 * 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author Tinkerghost <geek@rentedgeek.com> 7 */ 8 9// must be run within Dokuwiki 10if (!defined('DOKU_INC')) die(); 11 12if (!defined('DOKU_LF')) define('DOKU_LF', "\n"); 13if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t"); 14if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 15 16require_once DOKU_PLUGIN.'syntax.php'; 17 18class syntax_plugin_floatdiv_floathead extends DokuWiki_Syntax_Plugin { 19 public function getType() { 20 return 'formatting'; 21 } 22 23 public function getPType() { 24 return 'block'; 25 } 26 27 public function getSort() { 28 return 32; 29 } 30 31 32 public function connectTo($mode) { 33 $this->Lexer->addSpecialPattern('~\$+ .+? \$+~',$mode,'plugin_floatdiv_floathead'); 34// $this->Lexer->addEntryPattern('<FIXME>',$mode,'plugin_floatdiv_floathead'); 35 } 36 37// public function postConnect() { 38// $this->Lexer->addExitPattern('</FIXME>','plugin_floatdiv_floathead'); 39// } 40 41 public function handle($match, $state, $pos, &$handler){ 42 preg_match('/^~(\$+) (.+)? (\$+)~/',$match,$matches); 43 return array(strlen($matches[1]),$matches[2]); 44 } 45 46 public function render($mode, &$renderer, $data) { 47 if($mode != 'xhtml') return false; 48 list($size,$match) = $data; 49 if ($size > 6){$size = 6;} 50 $renderer->doc .= "<div class='floathead$size'>". 51 $renderer->_xmlEntities($match)."</div>"; 52 return true; 53 } 54} 55 56// vim:ts=4:sw=4:et: 57