plugin:class
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plugin:class [2008-12-15 17:02] – 217.128.78.18 | plugin:class [2014-08-11 15:19] (current) – [Description] 217.8.62.177 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== class plugin ====== | ||
+ | ---- plugin ---- | ||
+ | description: | ||
+ | author | ||
+ | email : janusz@ledruide.net | ||
+ | type : syntax | ||
+ | lastupdate : 2009-09-16 | ||
+ | compatible : | ||
+ | depends | ||
+ | conflicts | ||
+ | similar | ||
+ | tags : boxes, style | ||
+ | ---- | ||
+ | |||
+ | ===== Description ===== | ||
+ | |||
+ | This is a simple plugin to add a class to a content. It prevents to use | ||
+ | <code html> | ||
+ | < | ||
+ | |||
+ | This is my content. | ||
+ | |||
+ | < | ||
+ | </ | ||
+ | |||
+ | ===== Usage ===== | ||
+ | |||
+ | Just use this syntax and change " | ||
+ | |||
+ | <code html> | ||
+ | <class myStyleClass> | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Source code and installation ===== | ||
+ | |||
+ | Put the following PHP file in / | ||
+ | |||
+ | <code php syntax.php> | ||
+ | <?php | ||
+ | /** | ||
+ | * Plugin class : add a class to a content | ||
+ | * | ||
+ | * Syntax: <class myStyleClass> | ||
+ | | ||
+ | * @author | ||
+ | * @license | ||
+ | */ | ||
+ | |||
+ | if(!defined(' | ||
+ | if(!defined(' | ||
+ | require_once(DOKU_PLUGIN.' | ||
+ | |||
+ | class syntax_plugin_class extends DokuWiki_Syntax_Plugin { | ||
+ | |||
+ | /** | ||
+ | * Get an associative array with plugin info. | ||
+ | */ | ||
+ | function getInfo(){ | ||
+ | return array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | function getType(){ return ' | ||
+ | function getPType(){ return ' | ||
+ | function getAllowedTypes() { | ||
+ | return array(' | ||
+ | } | ||
+ | |||
+ | // must return a number lower than returned by native ' | ||
+ | function getSort(){ return 158; } | ||
+ | |||
+ | |||
+ | /** | ||
+ | * Connect pattern to lexer | ||
+ | */ | ||
+ | function connectTo($mode) { | ||
+ | $this-> | ||
+ | } | ||
+ | function postConnect() { | ||
+ | $this-> | ||
+ | } | ||
+ | |||
+ | |||
+ | /** | ||
+ | * Handle the match | ||
+ | */ | ||
+ | function handle($match, | ||
+ | switch ($state) { | ||
+ | case DOKU_LEXER_ENTER: | ||
+ | $data = strtolower(trim(substr($match, | ||
+ | return array($state, | ||
+ | | ||
+ | case DOKU_LEXER_UNMATCHED : | ||
+ | return array($state, | ||
+ | | ||
+ | case DOKU_LEXER_EXIT : | ||
+ | return array($state, | ||
+ | | ||
+ | } | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | |||
+ | /** | ||
+ | * output | ||
+ | */ | ||
+ | function render($mode, | ||
+ | if($mode == ' | ||
+ | list($state, | ||
+ | switch ($state) { | ||
+ | | ||
+ | case DOKU_LEXER_ENTER : | ||
+ | $renderer-> | ||
+ | break; | ||
+ | | ||
+ | case DOKU_LEXER_UNMATCHED : | ||
+ | $renderer-> | ||
+ | break; | ||
+ | | ||
+ | case DOKU_LEXER_EXIT : | ||
+ | $renderer-> | ||
+ | break; | ||
+ | } | ||
+ | return true; | ||
+ | } | ||
+ | return false; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | //Setup VIM: ex: et ts=4 enc=utf-8 : | ||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Versions ===== | ||
+ | |||
+ | * **2009-09-16** : Change '' | ||
+ | * **2008-12-15** : Change the getType() to convert the inside text in HTML code. | ||
+ | * **2008-12-08** : First version. | ||
+ | |||
+ | |||
+ | ===== Discussion ===== | ||
+ | |||
+ | How can I define font and other attributes of my class? Can it work in another pages? | ||
+ | |||
+ | It is not boxes? I cannot use <class class1>< |