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
Next revisionBoth sides next revision
plugin:tab [2011-07-26 17:15] 129.255.1.147plugin:tab [2018-02-14 13:01] – [Code] Juergen_aus_Zuendorf
Line 1: Line 1:
-====== Tab ======+====== Tab Plugin ======
  
 ---- plugin ---- ---- plugin ----
Line 6: Line 6:
 email      : timskoch@hotmail.com email      : timskoch@hotmail.com
 type       : syntax type       : syntax
-lastupdate : 2006-08-16+lastupdate : 2018-02-06
 compatible : compatible :
 depends    : depends    :
Line 50: Line 50:
             'author' => 'Tim Skoch',             'author' => 'Tim Skoch',
             'email'  => 'timskoch@hotmail.com',             'email'  => 'timskoch@hotmail.com',
-            'date'   => '2006-08-16',+            'date'   => '2018-02-06',
             'name'   => 'Tab Plugin',             'name'   => 'Tab Plugin',
             'desc'   => 'Inserts "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" into the html of the document for every <tab> it encounters',             'desc'   => 'Inserts "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" into the html of the document for every <tab> it encounters',
Line 102: Line 102:
      * Handle the match      * Handle the match
      */      */
-    function handle($match, $state, $pos, &$handler){+    function handle($match, $state, $pos, Doku_Handler $handler){
         switch ($state) {         switch ($state) {
           case DOKU_LEXER_ENTER :            case DOKU_LEXER_ENTER : 
Line 121: Line 121:
      * Create output      * Create output
      */      */
-    function render($mode, &$renderer, $data) {+    function render($mode, Doku_Renderer $renderer, $data) {
         if($mode == 'xhtml'){         if($mode == 'xhtml'){
             $renderer->doc .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";            // ptype = 'normal'             $renderer->doc .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";            // ptype = 'normal'
Line 132: Line 132:
    
 //Setup VIM: ex: et ts=4 enc=utf-8 : //Setup VIM: ex: et ts=4 enc=utf-8 :
- 
 </code> </code>
  
 +--- [[user>Juergen_aus_Zuendorf|Juergen_aus_Zuendorf]] //2018-02-06 16:27//\\
 +-> Changes for compatibility to PHP7:\\
 +"&$handler" and "&$renderer" to "Doku_Handler $handler" and "Doku_Renderer $renderer"
 ===== Installation ===== ===== Installation =====
  
Line 240: Line 242:
  
 2011-07-26 2011-07-26
-Works great in latest version.  Thanks+Works great in latest version using "New Code" above.  Thanks 
 + 
 +---- 
 + 
 +==== 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\d*>', $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.txt · Last modified: 2020-05-14 22:36 by Juergen_aus_Zuendorf

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