====== Smaller Plugin ====== **Note:** This plugin will be discontinued. A [[plugin:BBCode]] plugin will be released soon making different text sizes possible. ===== Description ===== With this [[:plugins|plugin]] the [[:syntax]] of [[:DokuWiki]] is extended to allow text with smaller font size. The syntax to use this plugin is... #-Smaller text-# You can see the plugin in action [[http://www.qwik.ch/playground|here]]. ===== Plugin ===== Put the following PHP file in ''/lib/plugins/smaller/syntax.php''. */ 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_smaller extends DokuWiki_Syntax_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'Esther Brunner', 'email' => 'esther@kaffeehaus.ch', 'date' => '2005-06-27', 'name' => 'Smaller Plugin', 'desc' => 'Enables smaller text', 'url' => 'http://www.dokuwiki.org/plugin:smaller', ); } /** * Constructor - adds allowed modes */ function syntax_plugin_smaller(){ global $PARSER_MODES; $this->allowedModes = array_merge( $PARSER_MODES['formatting'], $PARSER_MODES['substition'], $PARSER_MODES['disabled'] ); } /** * What kind of syntax are we? */ function getType(){ return 'formatting'; } /** * Where to sort in? */ function getSort(){ return 104; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addEntryPattern('#\-(?=.*\-#)',$mode,'plugin_smaller'); } function postConnect() { $this->Lexer->addExitPattern('\-#','plugin_smaller'); } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ 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 : ?>