fontsize plugin

fontsize plugin by Jesús A. Álvarez
This plugin allows text in different sizes.

Last updated on 2008-04-25. Provides Syntax.
Compatible with DokuWiki >= 2005-07-01.

Similar to fontsize2, typography, wrap.

Tagged with style, typography.

    Download dokuwiki-plugin-fontsize.tgz

    Description

    This plugin allows to write text in different sizes.

    Syntax

    Enclose the text in ## tags to make it larger, and in ,, to make it smaller.
    Add more #s or ,s to increase or decrease the size in steps of 20%.

    ##this text is shown at 120% of the base size##, ###this is 140%### ####and this is 160%####
    ,,this is smaller, at 80%,, and ,,,this is at 60%,,,
    ,,if I were to put a comma after a small text,,%%,%% I would need to enclose the comma in double percent signs

    ##this text is shown at 120% of the base size##, ###this is 140%### ####and this is 160%#### ,,this is smaller, at 80%,, and ,,,this is at 60%,,, ,,if I were to put a comma after a small text,,, I would need to enclose the comma in double percent signs

    Source Code

    Create a directory fontsize in /wiki/lib/plugins and save the code in a syntax.php file there.

    <?php
    /**
    * Font Size Plugin: Allow different font sizes
    * 
    * @license    GPL 3 (http://www.gnu.org/licenses/gpl.html)
    * @author     Jesús A. Álvarez <zydeco [at] namedfork [dot] net>
    */
     
    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');
     
    class  syntax_plugin_fontsize extends DokuWiki_Syntax_Plugin {
     
    	function getInfo(){
    		return array(
    			'author' => 'Jesús A. Álvarez',
    			'email'  => 'zydeco@namedfork.net',
    			'date'   => '2008-04-25',
    			'name'   => 'Font Size Plugin',
    			'desc'   => 'Allow different font sizes.',
    			'url'    => 'http://www.dokuwiki.org/plugin:fontsize',
    			);
    	}
     
    	function getType() { return('formatting'); }
    	function getSort() { return 131; }
     
    	function connectTo($mode) {
    		$this->Lexer->addEntryPattern('##+(?=.*##+)',$mode,'plugin_fontsize');
    		$this->Lexer->addEntryPattern(',,+(?=.*,,+)',$mode,'plugin_fontsize');
    	}
     
        function postConnect() {
            $this->Lexer->addExitPattern('##+', 'plugin_fontsize');
            $this->Lexer->addExitPattern(',,+', 'plugin_fontsize');
        }
     
    	function handle($match, $state, $pos, &$handler){
    		switch ($state) {
    			case DOKU_LEXER_ENTER:
    				if ($match{1} == '#')
    					$size = (strlen($match)*20)+80 .'%';
    				else
    					$size = 120-(strlen($match)*20) . '%';
    				return array($state, $size);
    			case DOKU_LEXER_UNMATCHED:	return array($state, $match);
    			case DOKU_LEXER_EXIT:		return array($state, '');
    		}
    		return array();
    	}
     
    	function render($mode, &$renderer, $data) {
    		if ($mode == 'xhtml') {
    			list($state, $match) = $data;
    			switch ($state) {
    				case DOKU_LEXER_ENTER:
    					$renderer->doc .= "<span style='font-size:$match;'>"; break;
    				case DOKU_LEXER_UNMATCHED:
    					$renderer->doc .= $renderer->_xmlEntities($match); break;
    				case DOKU_LEXER_EXIT:
    					$renderer->doc .= '</span>'; break;
    			}
    			return true;
    		}
    		return false;
    	}
     
    }
    //Setup VIM: ex: et ts=4 enc=utf-8 :

    Discussion

    Hi. Is is me or I can't get the system to recognize a link if it's put in smalltext?

    ,, [[http://www.giocoestudio.it|programma]] ,,
    

    this does not work…

    Tnx!


    Work neither with H1, H2, H3 etc titles :(

    ====== ##########big title for blind ppl########## ======
    
    

    Too bad.


    Hi! I have fontsize2 up and working, but fontsize does not. Have the syntax.php in the plugins folder, but the plugin does not work and does not appear in plugins in the config. Why :-?

     
    plugin/fontsize.txt · Last modified: 2009/10/08 17:10 by laynee
     
    Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
    Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
    WikiForumIRCBugsGitXRefTranslate