plugin:tab:old
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | plugin:tab:old [2020-05-14 21:07] (current) – created Juergen_aus_Zuendorf | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== Description ===== | ||
+ | |||
+ | Nothing too special. | ||
+ | |||
+ | ===== Use ===== | ||
+ | |||
+ | Simply insert '< | ||
+ | |||
+ | ===== Code ===== | ||
+ | <code php lib/ | ||
+ | <?php | ||
+ | /** | ||
+ | * Plugin Tab: Inserts "& | ||
+ | | ||
+ | * @license | ||
+ | * @author | ||
+ | */ | ||
+ | |||
+ | if(!defined(' | ||
+ | if(!defined(' | ||
+ | require_once(DOKU_PLUGIN.' | ||
+ | |||
+ | /** | ||
+ | * All DokuWiki plugins to extend the parser/ | ||
+ | * need to inherit from this class | ||
+ | */ | ||
+ | class syntax_plugin_tab extends DokuWiki_Syntax_Plugin { | ||
+ | |||
+ | /** | ||
+ | * return some info | ||
+ | */ | ||
+ | function getInfo(){ | ||
+ | return array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * What kind of syntax are we? | ||
+ | */ | ||
+ | function getType(){ | ||
+ | return ' | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * What kind of syntax do we allow (optional) | ||
+ | */ | ||
+ | // function getAllowedTypes() { | ||
+ | // return array(); | ||
+ | // } | ||
+ | |||
+ | /** | ||
+ | * What about paragraphs? (optional) | ||
+ | */ | ||
+ | // function getPType(){ | ||
+ | // return ' | ||
+ | // } | ||
+ | |||
+ | /** | ||
+ | * Where to sort in? | ||
+ | | ||
+ | function getSort(){ | ||
+ | return 999; | ||
+ | } | ||
+ | |||
+ | |||
+ | /** | ||
+ | * Connect pattern to lexer | ||
+ | */ | ||
+ | function connectTo($mode) { | ||
+ | $this-> | ||
+ | // $this-> | ||
+ | } | ||
+ | |||
+ | // function postConnect() { | ||
+ | // $this-> | ||
+ | // } | ||
+ | |||
+ | |||
+ | /** | ||
+ | * Handle the match | ||
+ | */ | ||
+ | function handle($match, | ||
+ | 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, | ||
+ | if($mode == ' | ||
+ | $renderer-> | ||
+ | // $renderer-> | ||
+ | return true; | ||
+ | } | ||
+ | return false; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | //Setup VIM: ex: et ts=4 enc=utf-8 : | ||
+ | </ | ||
+ | |||
+ | --- [[user> | ||
+ | -> Changes for compatibility to PHP7:\\ | ||
+ | "& | ||
+ | ===== Installation ===== | ||
+ | |||
+ | Just like any other plugin: | ||
+ | |||
+ | Enjoy! | ||
+ | |||
+ | |||
+ | |||
+ | ===== Discussion ===== | ||
+ | |||
+ | Is any really necessary? ;-) | ||
+ | |||
+ | ====== | ||
+ | Tim, | ||
+ | |||
+ | We used your code to spawn our [[plugin: | ||
+ | ~[[mailto: | ||
+ | |||
+ | ---- | ||
+ | |||
+ | 2010-05-18 | ||
+ | :?: It doesn' | ||
+ | ==== New Code ==== | ||
+ | |||
+ | Could be done in less lines (drop test code etc). | ||
+ | <code php> | ||
+ | <?php | ||
+ | |||
+ | /** | ||
+ | * Plugin Tab: Inserts "& | ||
+ | | ||
+ | * @license | ||
+ | * @author | ||
+ | */ | ||
+ | |||
+ | if(!defined(' | ||
+ | if(!defined(' | ||
+ | require_once(DOKU_PLUGIN.' | ||
+ | |||
+ | /** | ||
+ | * All DokuWiki plugins to extend the parser/ | ||
+ | * need to inherit from this class | ||
+ | */ | ||
+ | class syntax_plugin_tab extends DokuWiki_Syntax_Plugin { | ||
+ | |||
+ | /** | ||
+ | * return some info | ||
+ | */ | ||
+ | function getInfo(){ | ||
+ | return array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * What kind of syntax are we? | ||
+ | */ | ||
+ | function getType(){ | ||
+ | return ' | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Where to sort in? | ||
+ | | ||
+ | function getSort(){ | ||
+ | return 999; | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Connect pattern to lexer | ||
+ | */ | ||
+ | function connectTo($mode) { | ||
+ | $this-> | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Handle the match | ||
+ | */ | ||
+ | function handle($match, | ||
+ | return array(); | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Create output | ||
+ | */ | ||
+ | function render($mode, | ||
+ | if($mode == ' | ||
+ | $renderer-> | ||
+ | return true; | ||
+ | } | ||
+ | return false; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | When we updated to the latest version of DokuWiki, this broke. | ||
+ | |||
+ | 2011-07-26 | ||
+ | Works great in latest version using "New Code" above. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Enhancement/ | ||
+ | // | ||
+ | |||
+ | If you modify the code according below you can define the quantity of "& | ||
+ | |||
+ | following both syntax lines are working: | ||
+ | < | ||
+ | <tab> 5 times "& | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | <code php> | ||
+ | // Connect pattern to lexer | ||
+ | function connectTo($mode) { | ||
+ | $this-> | ||
+ | |||
+ | // Handle the match | ||
+ | function handle($match, | ||
+ | $match = substr($match, | ||
+ | | ||
+ | if ((strlen($match)> | ||
+ | $data .= str_repeat('&# | ||
+ | } | ||
+ | else { // if standard tab is used then insert 5 spaces | ||
+ | $data = '&# | ||
+ | } | ||
+ | return $data; | ||
+ | } | ||
+ | |||
+ | // Create output | ||
+ | function render($mode, | ||
+ | if($mode == ' | ||
+ | $renderer-> | ||
+ | return true; } | ||
+ | return false; | ||
+ | } | ||
+ | </ | ||
plugin/tab/old.txt · Last modified: 2020-05-14 21:07 by Juergen_aus_Zuendorf