DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:tab

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:tab [2011-09-22 12:00] – [Enhancement/Feature Extension] 93.199.162.152plugin:tab [2020-05-14 22:36] (current) – [Tab Plugin] Juergen_aus_Zuendorf
Line 1: Line 1:
-====== Tab ======+====== Tab Plugin ======
  
 ---- plugin ---- ---- plugin ----
-description: Inserts 5 non-breaking spaced to 'force' a tab +description: Inserts 5 non-breaking spaces to 'force' a tab 
-author     : Tim Skoch +author     : Juergen_aus_Zuendorf (previous Tim Skoch) 
-email      : timskoch@hotmail.com+email      : H-J-Schuemmer@Web.de
 type       : syntax type       : syntax
-lastupdate : 2006-08-16 +lastupdate : 2020-05-14 
-compatible :+compatible : 2018-04-22b "Greebo"
 depends    : depends    :
 conflicts  : conflicts  :
 similar    : nbsp similar    : nbsp
 tags       : typography tags       : typography
 +
 +downloadurl: https://github.com/Juergen-aus-Koeln/dokuwiki-plugin-tab/archive/master.zip
 +bugtracker : https://github.com/Juergen-aus-Koeln/dokuwiki-plugin-tab/issues
 +sourcerepo : https://github.com/Juergen-aus-Koeln/dokuwiki-plugin-tab/
 ---- ----
  
Line 17: Line 21:
 ===== Description ===== ===== Description =====
  
-Nothing too special.  I have some poetry on my site, so I wanted a way to add 'tabs'.  Since you can't really do tabs in HTML, I decided to just use non-breaking spaces (nbsp's) instead.  5 nbsp's = 1 tab.+Since one can't really do tabs in HTML, this plugin offers a possibility by the use of non-breaking spaces (nbsp's) instead5 nbsp's =1 tab.
  
-===== Use ===== 
  
-Simply insert '<tab>' into the text.  When DokuWiki parses it, it will replace '<tab>' with 5 nbsp's. +===== Syntax =====
-      +
-===== Code ===== +
-<code php lib/plugins/tab/syntax.php> +
-<?php +
-/** +
- * Plugin Tab: Inserts "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" into the document for every <tab> it encounters +
- *  +
- * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html) +
- * @author     Tim Skoch <timskoch@hotmail.com> +
- */ +
-  +
-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_tab extends DokuWiki_Syntax_Plugin { +
-  +
-    /** +
-     * return some info +
-     */ +
-    function getInfo(){ +
-        return array( +
-            'author' => 'Tim Skoch', +
-            'email'  => 'timskoch@hotmail.com', +
-            'date'   => '2006-08-16', +
-            'name'   => 'Tab Plugin', +
-            'desc'   => 'Inserts "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" into the html of the document for every <tab> it encounters', +
-            'url'    => 'http://www.dokuwiki.org/wiki:plugins:tab', +
-        ); +
-    } +
-  +
-    /** +
-     * 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('<tab>',$mode,'plugin_tab'); +
-//      $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;&nbsp;&nbsp;&nbsp;&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>+There are two ways to use the plugin: 
 +  - Insert ''<tab>'' into the text.  When DokuWiki parses it, it will replace '<tab>' with 5 spaces. 
 +  - Insert ''<tab#>'' where '#' is a number and defines the quantity of “&nbsp” signs.
  
-===== Installation =====+Therefore the following both syntax lines are working:
  
-Just like any other plugin:  Create a new folder "lib/plugins/tab", and create file "syntax.php" with the above code as its contents.+^ Syntax      ^ Result                                                                                           ^ 
 +| ''<tab>''   | 5 times "&nbsp;" = 1 tab                                                                         | 
 +| ''<tab2>''  | 2 times "&nbsp;" (where 2 can be each positive integer value, a negative value will be ignored)  |
  
-Enjoy! 
  
 +===== Installation =====
  
 +Install the plugin using the [[plugin:plugin|Plugin Manager]] and the download URL above, which points to latest version of the plugin. Refer to [[:Plugins]] on how to install plugins manually.
  
-===== Discussion ===== 
  
-Is any really necessary? ;-)+===== Development =====
  
-====== +The original code was written by Tim Skoch. I have updated it for compatibility to PHP7 and included the possibility proposed by taggic (2011-09-22) to extend the syntax to "<tab2>" (and so on). Finally I have created a repository at github.
-Tim,+
  
-We used your code to spawn our [[plugin:pagebreak|pagebreak]] plugin Thanks a million for giving us a starting point. +The earlier description can be found [[.:tab:old|here]].
-~[[mailto:j.mcbride@mail.utexas.edu|Jonathan]] and Chris+
  
----- 
  
-2010-05-18 +=== Change Log ===
-:?: It doesn't work in lastest version. Did you test it in lastest version? +
-==== New Code ====+
  
-Could be done in less lines (drop test code etc).  +  * **2018-02-06**: Last version of Tim Scoch 
-<code php> +  * **2020-05-14**: Acquisition and updating by Juergen
-<?php+
  
-/** 
- * Plugin Tab: Inserts "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" into the document for every <tab> it encounters 
-  
- * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html) 
- * @author     Tim Skoch <timskoch@hotmail.com> 
- */ 
-  
-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_tab extends DokuWiki_Syntax_Plugin { 
-  
-    /** 
-     * return some info 
-     */ 
-    function getInfo(){ 
-        return array( 
-            'author' => 'Tim Skoch', 
-            'email'  => 'timskoch@hotmail.com', 
-            'date'   => '2006-08-16', 
-            'name'   => 'Tab Plugin', 
-            'desc'   => 'Inserts "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" into the html of the document for every <tab> it encounters', 
-            'url'    => 'http://www.dokuwiki.org/plugin:tab', 
-        ); 
-    } 
-  
-    /** 
-     * What kind of syntax are we? 
-     */ 
-    function getType(){ 
-        return 'substition'; 
-    } 
-  
-    /** 
-     * Where to sort in? 
-     */  
-    function getSort(){ 
-        return 999; 
-    } 
-  
-    /** 
-     * Connect pattern to lexer 
-     */ 
-    function connectTo($mode) { 
-      $this->Lexer->addSpecialPattern('<tab>', $mode, 'plugin_tab'); 
-    } 
-  
-    /** 
-     * Handle the match 
-     */ 
-    function handle($match, $state, $pos, &$handler){ 
-        return array(); 
-    } 
-  
-    /** 
-     * Create output 
-     */ 
-    function render($mode, &$renderer, $data) { 
-        if($mode == 'xhtml'){ 
-            $renderer->doc .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
-            return true; 
-        } 
-        return false; 
-    } 
-} 
  
-?> +=== Known Bugs and Issues ===
-</code>+
  
-When we updated to the latest version of DokuWiki, this broke It failed to interpret "&nbsp;" as a non-breaking space, and simply displayed it as text instead.  The quick fix for me was to replace "''&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;''" with "''&#160;&#160;&#160;&#160;&#160;''" Works for us, but we are a one-language shop and our limited user base is almost exclusively using Firefox.  YMMV.\\  //--- [[nathan.randall@arbor.edu|Nathan Randall]] 2008-04-15 10:33//+Please report bugs or feature requests at the [[https://github.com/Juergen-aus-Koeln/dokuwiki-plugin-tab/issues|Bug tracker]].
  
-2011-07-26 
-Works great in latest version using "New Code" above.  Thanks 
  
----- +===== Discussion =====
- +
-==== Enhancement/Feature Extension ==== +
-//2011-09-22 by Taggic// \\  +
- +
-If you modify the code according below you can define the quantity of "&nbsp" signs. If the parameter is missing it is using automatically the old behaiviour so that nobody has to search through all pages and replace the formerly used "tabs"+
- +
-following both syntax lines are working: +
-<code> +
-<tab> 5 times "&nbsp;" as before +
-<tab2> 2 times "&nbsp;" (where 2 can be each positive integer value, a negative value will be ignored) +
-</code>+
  
-<code php> 
-    // Connect pattern to lexer 
-    function connectTo($mode) {  
-      $this->Lexer->addSpecialPattern('<tab[^}]*>', $mode, 'plugin_tab'); } 
-  
-    // Handle the match 
-    function handle($match, $state, $pos, &$handler){ 
-        $match = substr($match,4,-1);             //strip markup from start and end 
-         
-        if ((strlen($match)>0) && ($match >0)) {  // add as many space as defined if value is positive 
-            $data .= str_repeat('&#160;', $match); 
-        } 
-        else {                                    // if standard tab is used then insert 5 spaces 
-          $data = '&#160;&#160;&#160;&#160;&#160;';                         
-        } 
-        return $data; 
-    } 
  
-    // Create output 
-    function render($mode, &$renderer, $data) { 
-        if($mode == 'xhtml'){ 
-            $renderer->doc .= $data; 
-            return true;         } 
-        return false; 
-    } 
-</code> 
plugin/tab.1316685654.txt.gz · Last modified: 2011-09-22 12:00 by 93.199.162.152

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