DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:larger

This is an old revision of the document!


Table of Contents

Larger Plugin

Note: This plugin will be discontinued. A BBCode plugin making different text sizes possible will be realeased soon.

Description

With this plugin the syntax of DokuWiki is extended to allow text with larger font size. The syntax to use this plugin is…

#+Larger text+#

You can see the plugin in action here.

Plugin

Put the following PHP file in /lib/plugins/larger/syntax.php.

<?php
/**
 * Larger Plugin: enables larger text font size with syntax #+text+#
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Esther Brunner <esther [at] kaffeehaus [dot] ch>
 */
 
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_larger extends DokuWiki_Syntax_Plugin {
 
    /**
     * return some info
     */
    function getInfo(){
        return array(
            'author' => 'Esther Brunner',
            'email'  => 'esther@kaffeehaus.ch',
            'date'   => '2005-06-27',
            'name'   => 'Larger Plugin',
            'desc'   => 'Enables larger text',
            'url'    => 'http://www.dokuwiki.org/plugin:larger',
        );
    }
 
    /**
     * Constructor - adds allowed modes
     */
    function syntax_plugin_larger(){
        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 106;
    }
 
    /**
    * Connect pattern to lexer
    */
    function connectTo($mode) {
      $this->Lexer->addEntryPattern('#\+(?=.*\+#)',$mode,'plugin_larger');
    }
 
    function postConnect() {
      $this->Lexer->addExitPattern('\+#','plugin_larger');
    }
 
    /**
     * 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 .= '<span style="font-size:larger">';
            } else if ($data[1] == DOKU_LEXER_UNMATCHED){
                $renderer->doc .= $renderer->_xmlEntities($data[0]);
            } else if ($data[1] == DOKU_LEXER_EXIT){
                $renderer->doc .= '</span>';
            }
            return true;
        }
        return false;
    }
 
}
 
//Setup VIM: ex: et ts=4 enc=utf-8 :
?>
plugin/larger.1384302059.txt.gz · Last modified: 2013-11-13 01:20 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki