1<?php 2/** 3* Font Size Plugin: Allow different font sizes 4* 5* @license GPL 3 (http://www.gnu.org/licenses/gpl.html) 6* @author Jesús A. Álvarez <zydeco@namedfork.net> 7*/ 8 9if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 11require_once(DOKU_PLUGIN.'syntax.php'); 12 13class syntax_plugin_fontsize extends DokuWiki_Syntax_Plugin { 14 15 function getInfo(){ 16 return array( 17 'author' => 'Jesús A. Álvarez', 18 'email' => 'zydeco@namedfork.net', 19 'date' => '2008-04-25', 20 'name' => 'Font Size Plugin', 21 'desc' => 'Allow different font sizes.', 22 'url' => 'https://www.dokuwiki.org/plugin:fontsize', 23 ); 24 } 25 26 function getType() { return('formatting'); } 27 function getSort() { return 131; } 28 29 function connectTo($mode) { 30 $this->Lexer->addEntryPattern('##+(?=.*##+)',$mode,'plugin_fontsize'); 31 $this->Lexer->addEntryPattern(',,+(?=.*,,+)',$mode,'plugin_fontsize'); 32 } 33 34 function postConnect() { 35 $this->Lexer->addExitPattern('##+', 'plugin_fontsize'); 36 $this->Lexer->addExitPattern(',,+', 'plugin_fontsize'); 37 } 38 39 function handle($match, $state, $pos, &$handler){ 40 switch ($state) { 41 case DOKU_LEXER_ENTER: 42 if ($match{1} == '#') 43 $size = (strlen($match)*20)+80 .'%'; 44 else 45 $size = 120-(strlen($match)*20) . '%'; 46 return array($state, $size); 47 case DOKU_LEXER_UNMATCHED: return array($state, $match); 48 case DOKU_LEXER_EXIT: return array($state, ''); 49 } 50 return array(); 51 } 52 53 function render($mode, &$renderer, $data) { 54 if ($mode == 'xhtml') { 55 list($state, $match) = $data; 56 switch ($state) { 57 case DOKU_LEXER_ENTER: 58 $renderer->doc .= "<span style='font-size:$match;'>"; break; 59 case DOKU_LEXER_UNMATCHED: 60 $renderer->doc .= $renderer->_xmlEntities($match); break; 61 case DOKU_LEXER_EXIT: 62 $renderer->doc .= '</span>'; break; 63 } 64 return true; 65 } 66 return false; 67 } 68 69} 70//Setup VIM: ex: et ts=4 enc=utf-8 :