DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:space

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:space [2008-11-21 21:43] – added similar plugin and another tag achplugin:space [2020-02-18 19:29] (current) Aleksandr
Line 1: Line 1:
 +====== Space Plugin ======
 +
 +---- plugin ----
 +description: Inserts 1 non-breaking spaced to 'force' a space (based on the tab plugin syntax)
 +author     : Gerardo Armendariz
 +email      : garmendariz@gmail.com
 +type       : syntax
 +lastupdate : 2006-08-16
 +compatible :
 +depends    :
 +conflicts  :
 +similar    : tab, nbsp
 +tags       : space
 +----
 +
 +
 +===== Description =====
 +
 +This plugin is completely based on the [[plugin:tab|tab plugin]] syntax by Tim Skoch. It adds a single space to the page. 
 +
 +===== Use =====
 +
 +Simply insert '<space>' into the text.  When DokuWiki parses it, it will replace '<space>' with 1 nbsp's.
 +
 +===== Code =====
 +
 +<code php syntax.php>
 +<?php
 +/**
 + * Plugin Space: Inserts "&nbsp;" into the document for every <space> it encounters
 + 
 + * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 + * @author     Gerardo Armendariz <garmendariz@gmail.com> based on Tim Skoch <timskoch@hotmail.com> tab plugin.
 + */
 + 
 +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_space extends DokuWiki_Syntax_Plugin {
 + 
 +    /**
 +     * return some info
 +     */
 +    function getInfo(){
 +        return array(
 +            'author' => 'Gerardo Armendariz',
 +            'email'  => 'garmendariz@gmail.com',
 +            'date'   => '2008-11-20',
 +            'name'   => 'Space Plugin',
 +            'desc'   => 'Inserts "&nbsp;" into the HTML of the document for every <space> it encounters',
 +            'url'    => 'http://www.dokuwiki.org/plugin:space',
 +        );
 +    }
 + 
 +    /**
 +     * What kind of syntax are we?
 +     */
 +    function getType(){
 +        return 'substition';
 +    }
 + 
 +    /**
 +     * What kind of syntax do we allow (optional)
 +     */
 +//    function getAllowedTypes() {
 +//        return array();
 +//    }
 + 
 +    /**
 +     * What about paragraphs? (optional)
 +     */
 +//    function getPType(){
 +//        return 'normal';
 +//    }
 + 
 +    /**
 +     * Where to sort in?
 +     */ 
 +    function getSort(){
 +        return 999;
 +    }
 + 
 + 
 +    /**
 +     * Connect pattern to lexer
 +     */
 +    function connectTo($mode) {
 +      $this->Lexer->addSpecialPattern('<space>',$mode,'plugin_space');
 +//      $this->Lexer->addEntryPattern('<TEST>',$mode,'plugin_test');
 +    }
 + 
 +//    function postConnect() {
 +//      $this->Lexer->addExitPattern('</TEST>','plugin_test');
 +//    }
 + 
 + 
 +    /**
 +     * Handle the match
 +     */
 +    function handle($match, $state, $pos, &$handler){
 +        switch ($state) {
 +          case DOKU_LEXER_ENTER : 
 +            break;
 +          case DOKU_LEXER_MATCHED :
 +            break;
 +          case DOKU_LEXER_UNMATCHED :
 +            break;
 +          case DOKU_LEXER_EXIT :
 +            break;
 +          case DOKU_LEXER_SPECIAL :
 +            break;
 +        }
 +        return array();
 +    }
 + 
 +    /**
 +     * Create output
 +     */
 +    function render($mode, &$renderer, $data) {
 +        if($mode == 'xhtml'){
 +            $renderer->doc .= "&nbsp;";            // ptype = 'normal'
 +//            $renderer->doc .= "<p>Hello World!</p>";     // ptype = 'block'
 +            return true;
 +        }
 +        return false;
 +    }
 +}
 + 
 +//Setup VIM: ex: et ts=4 enc=utf-8 :
 +?>
 +</code>
  

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