plugin:fontcolor
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plugin:fontcolor [2014-02-24 08:08] – 213.148.128.70 | plugin:fontcolor [2024-02-08 08:01] (current) – rnck | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
---- plugin ---- | ---- plugin ---- | ||
- | description: | + | description: |
author | author | ||
email : thorsten.stratmann@web.de | email : thorsten.stratmann@web.de | ||
type : syntax | type : syntax | ||
- | lastupdate : 2010-03-23 | + | lastupdate : 2016-03-05 |
- | compatible : Anteater, Rincewind, Angua, Adora Belle, Weatherwax, Binky | + | compatible : Frusterick Manners, |
depends | depends | ||
conflicts | conflicts | ||
- | similar | + | similar |
- | tags : typography, highlight | + | tags : typography, highlight, color |
- | downloadurl: | + | downloadurl: |
+ | bugtracker : https:// | ||
sourcerepo : https:// | sourcerepo : https:// | ||
---- | ---- | ||
- | |||
===== Download and Installation ===== | ===== Download and Installation ===== | ||
- | Download | + | Search |
+ | |||
+ | This plugin requires gdlib support, see [[tips:phpwithgd]] for help. | ||
- | * [[https:// | ||
====== Description ====== | ====== Description ====== | ||
- | See it | + | You can give colors |
- | + | < | |
- | + | < | |
- | + | ||
- | ===== Code ===== | + | |
- | This Code is similar | + | |
- | The difference is only, that not the background-color but the font-color changes | + | |
- | + | ||
- | ==== syntax.php==== | + | |
- | + | ||
- | Put this code into '' | + | |
- | + | ||
- | + | ||
- | < | + | |
- | + | ||
- | <?php | + | |
- | /** | + | |
- | * fontcolor Plugin: Allows user-defined font colors | + | |
- | * | + | |
- | * @license | + | |
- | * @author | + | |
- | * @link | + | |
- | * @version | + | |
- | */ | + | |
- | + | ||
- | if(!defined(' | + | |
- | if(!defined(' | + | |
- | require_once(DOKU_PLUGIN.' | + | |
- | + | ||
- | /** | + | |
- | * All DokuWiki plugins to extend the parser/ | + | |
- | * need to inherit from this class | + | |
- | */ | + | |
- | class syntax_plugin_fontcolor extends DokuWiki_Syntax_Plugin { | + | |
- | + | ||
- | 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) | + | |
- | | + | |
- | + | ||
- | // Where to sort in? | + | |
- | function getSort(){ return 90; } | + | |
- | + | ||
- | + | ||
- | // Connect pattern to lexer | + | |
- | function connectTo($mode) { | + | |
- | $this-> | + | |
- | } | + | |
- | function postConnect() { | + | |
- | $this-> | + | |
- | } | + | |
- | + | ||
- | + | ||
- | // Handle the match | + | |
- | function handle($match, | + | |
- | switch ($state) { | + | |
- | case DOKU_LEXER_ENTER : | + | |
- | preg_match("/ | + | |
- | if ( $this-> | + | |
- | break; | + | |
- | case DOKU_LEXER_MATCHED : | + | |
- | break; | + | |
- | case DOKU_LEXER_UNMATCHED : | + | |
- | return array($state, | + | |
- | break; | + | |
- | case DOKU_LEXER_EXIT : | + | |
- | break; | + | |
- | case DOKU_LEXER_SPECIAL : | + | |
- | break; | + | |
- | } | + | |
- | return array($state, | + | |
- | } | + | |
- | + | ||
- | // Create output | + | |
- | function render($mode, | + | |
- | if($mode == ' | + | |
- | list($state, | + | |
- | switch ($state) { | + | |
- | case DOKU_LEXER_ENTER : | + | |
- | $renderer-> | + | |
- | break; | + | |
- | case DOKU_LEXER_MATCHED : | + | |
- | break; | + | |
- | case DOKU_LEXER_UNMATCHED : | + | |
- | $renderer-> | + | |
- | break; | + | |
- | case DOKU_LEXER_EXIT : | + | |
- | $renderer-> | + | |
- | break; | + | |
- | case DOKU_LEXER_SPECIAL : | + | |
- | break; | + | |
- | } | + | |
- | return true; | + | |
- | } | + | |
- | return false; | + | |
- | } | + | |
- | + | ||
- | // validate color value $c | + | |
- | // this is cut price validation - only to ensure the basic format is | + | |
- | // correct and there is nothing harmful | + | |
- | // three basic formats | + | |
- | function _isValid($c) { | + | |
- | + | ||
- | $c = trim($c); | + | |
- | + | ||
- | $pattern = "/ | + | |
- | (^[a-zA-Z]+$)| | + | |
- | (^\# | + | |
- | (^rgb\(([0-9]{1, | + | |
- | /x"; | + | |
- | + | ||
- | return (preg_match($pattern, | + | |
- | + | ||
- | } | + | |
- | } | + | |
- | + | ||
- | //Setup VIM: ex: et ts=4 sw=4 enc=utf-8 : | + | |
</ | </ | ||
- | ==== action.php ==== | + | This syntax can be included via the toolbar using the button: {{https:// |
- | Put this code into '' | + | ===Notes=== |
+ | This formatting behaves equal to other wiki syntax like italic and bold. You can only apply it to text, not to headers. | ||
- | <code php action.php> | ||
- | <?php | + | ===== Development ===== |
- | /** | + | ==== Code ==== |
- | * @license | + | The (original) code is similar to the [[plugin:highlight|Plugin highlight]] |
- | * @author | + | The difference is only, that not the background-color but the font-color changes |
- | */ | + | |
- | // must be run within Dokuwiki | ||
- | if(!defined(' | ||
- | if(!defined(' | + | ==== Features and issues ==== |
- | require_once(DOKU_PLUGIN.' | + | Please report your issues just at https://github.com/ |
- | class action_plugin_fontcolor extends DokuWiki_Action_Plugin { | ||
- | /** | ||
- | * return some info | ||
- | * | ||
- | * @author Andreas Gohr < | ||
- | */ | ||
- | function getInfo(){ | ||
- | return array_merge(confToHash(dirname(__FILE__).'/ | ||
- | } | ||
- | /** | ||
- | * register the eventhandlers | ||
- | * | ||
- | * @author Andreas Gohr < | ||
- | */ | ||
- | function register(Doku_Event_Handler $controller){ | ||
- | $controller-> | ||
- | } | ||
- | |||
- | function handle_toolbar(& | ||
- | $event-> | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ), | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ), | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ), | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ), | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ), | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ), | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ), | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ), | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ), | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ), | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ), | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ), | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ), | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ), | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ), | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ), | ||
- | ) | ||
- | ); | ||
- | } | ||
- | } | ||
- | </ | ||
- | |||
- | ===== Question ===== | ||
- | |||
- | Though the plugin works fine within the text, it does not show in the toolbar any more. | ||
- | |||
- | This happens in Release 2009-12-25c " | ||
- | |||
- | Any ideas? | ||
- | |||
- | |||
- | ------------------- | ||
- | Have the same problems. 09-03-2010 | ||
- | |||
- | ------------------ | ||
- | |||
- | Thanks for the hint. I will look. | ||
- | |||
- | ------------------ | ||
- | |||
- | I have repaired it. Now it works. | ||
- | |||
- | Please update via the Plugin Manager. | ||
- | |||
- | ------------------ | ||
- | I just downloaded it and install it manually but the toolbar button ain't showing though the function works | ||
- | |||
- | ------------------ | ||
- | |||
- | Try cleaning your browser' | ||
- | |||
- | ------------------ | ||
- | |||
- | At first it didn't work for me either, then I changed my template to default and back, et voilà (03/ | ||
- | |||
- | ------------------ | ||
- | |||
- | If <fc #FFFFFF > text </fc> is marked to change to #FF00FF it would be nice to get <fc #FF00FF > text </fc> instead of <fc #FF00FF ><fc #FFFFFF > text </ | ||
- | |||
- | ------------------ | ||
- | Why one cannot nest FC tags? <fc # | ||
- | |||
- | ------------------ | ||
- | |||
- | Hi, I installed the plugin manually, just by cp'ing the directory over to / | ||
- | |||
- | Any ideas? | ||
- | |||
- | ------------------ | ||
- | |||
- | < | ||
- | |||
- | |||
- | ------------------- | ||
- | 2011-06-10 | ||
- | |||
- | Thanks. | ||
- | |||
- | |||
- | ------------------- | ||
- | 2011-08-20 | ||
- | < | ||
- | ====foo< | ||
- | </ | ||
- | |||
- | ------------------- | ||
- | 2011-08-30 | ||
- | Thank you for this great plugin !!! As mention more up, will be cool to make it work with titles (i think will not be easy to manage as the titles don't support anything, **bold**, __underline__, | ||
- | |||
- | ------------------- | ||
- | 2012-02-28 | ||
- | Here's a little snippet to provide odt export of colored text - copied from the [[plugin: | ||
- | Klaus | ||
- | |||
- | Put this code into '' | ||
- | |||
- | <code php> | ||
- | if($mode == ' | ||
- | list($state, | ||
- | switch ($state) { | ||
- | case DOKU_LEXER_ENTER : | ||
- | $style_index = $color; | ||
- | if(empty($this-> | ||
- | $stylename = " | ||
- | $this-> | ||
- | $color = $color?' | ||
- | $renderer-> | ||
- | < | ||
- | < | ||
- | </ | ||
- | } | ||
- | $renderer-> | ||
- | break; | ||
- | |||
- | case DOKU_LEXER_UNMATCHED : | ||
- | $renderer-> | ||
- | break; | ||
- | case DOKU_LEXER_EXIT : | ||
- | $renderer-> | ||
- | break; | ||
- | } | ||
- | return true; | ||
- | } | ||
- | </ | ||
- | |||
- | ------------------- | ||
- | Hi there, I have a problem with the toolbar-button as well, i can't see it. but there is a little button-like thing in the toolbar, but without a funktion. Is it maybe an update-problem? | ||
- | by the way, is the description as it is written here correct? | ||
- | ------------------- | ||
- | 2013-02-14 | ||
- | < | ||
- | ====foo< | ||
- | </ | ||
- | ------------------- | ||
- | 2014-02-14 Zip not complete\\ | ||
- | After install apache logs errors:\\ | ||
- | File does not exist: / | ||
- | File does not exist: / | ||
- | File does not exist: / | ||
- | File does not exist: / | ||
- | \\ | ||
- | and so on.\\ | ||
- | \\ | ||
- | The folder toolebar is not included in the install zip file.\\ | ||
- | \\ | ||
- | Please check and Fix it!\\ | ||
- | ------------------- | ||
- | ===== Bugs ===== | ||
- | |||
- | * Click on icon make automatic saving comment in Discussion plugin without adding fontcolor syntax | ||
- | * Chrome 31: //Uncaught ReferenceError: | ||
- | * screws functionality of other edit-time plugins like [[plugin: | ||
- | |||
- | < | ||
- | Uncaught ReferenceError: | ||
- | plugin_fontcolor_make_color_button | ||
- | plugin_fontcolor_toolbar_picker | ||
- | c | ||
- | p.fireWith | ||
- | b.extend.ready | ||
- | H | ||
- | </ |
plugin/fontcolor.1393225690.txt.gz · Last modified: 2014-02-24 08:08 by 213.148.128.70