Download and install the plugin using the Plugin Manager using the following URL. Refer to Plugins on how to install plugins manually.
See it
This Code is similar to the Plugin highlight The difference is only, that not the background-color but the font-color changes
Put this code into lib/plugins/fontfamily/syntax.php:
<?php /** * fontcolor Plugin: Allows user-defined font colors * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author modified by ThorstenStratmann <thorsten.stratmann@web.de> * @link http://www.dokuwiki.org/plugin:fontcolor * @version 4.0 */ 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_fontcolor extends DokuWiki_Syntax_Plugin { function getInfo(){ // return some info return array( 'author' => 'ThorstenStratmann', 'email' => 'thorsten.stratmann@web.de', 'date' => '2010-03-23', 'name' => 'fontcolor Plugin', 'desc' => 'color text with a specific color Syntax: <fc color>Your Text </fc>', 'url' => 'http://www.dokuwiki.org/plugin:fontcolor', ); } // What kind of syntax are we? function getType(){ return 'formatting'; } // What kind of syntax do we allow (optional) function getAllowedTypes() { return array('formatting', 'substition', 'disabled'); } // What about paragraphs? (optional) function getPType(){ return 'normal'; } // Where to sort in? function getSort(){ return 90; } // Connect pattern to lexer function connectTo($mode) { $this->Lexer->addEntryPattern('(?i)<fc(?: .+?)?>(?=.+</fc>)',$mode,'plugin_fontcolor'); } function postConnect() { $this->Lexer->addExitPattern('(?i)</fc>','plugin_fontcolor'); } // Handle the match function handle($match, $state, $pos, &$handler){ switch ($state) { case DOKU_LEXER_ENTER : preg_match("/(?i)<fc (.+?)>/", $match, $color); // get the color if ( $this->_isValid($color[1]) ) return array($state, $color[1]); break; case DOKU_LEXER_MATCHED : break; case DOKU_LEXER_UNMATCHED : return array($state, $match); break; case DOKU_LEXER_EXIT : break; case DOKU_LEXER_SPECIAL : break; } return array($state, "#ff0"); } // Create output function render($mode, &$renderer, $data) { if($mode == 'xhtml'){ list($state, $color) = $data; switch ($state) { case DOKU_LEXER_ENTER : $renderer->doc .= "<span style=\"color: $color\">"; break; case DOKU_LEXER_MATCHED : break; case DOKU_LEXER_UNMATCHED : $renderer->doc .= $renderer->_xmlEntities($color); break; case DOKU_LEXER_EXIT : $renderer->doc .= "</span>"; 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 "colorname", "#fff[fff]", "rgb(255[%],255[%],255[%])" function _isValid($c) { $c = trim($c); $pattern = "/ (^[a-zA-Z]+$)| #colorname - not verified (^\#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$)| #colorvalue (^rgb\(([0-9]{1,3}%?,){2}[0-9]{1,3}%?\)$) #rgb triplet /x"; return (preg_match($pattern, $c)); } } //Setup VIM: ex: et ts=4 sw=4 enc=utf-8 :
Put this code into lib/plugins/fontcolor/action.php:
<?php /** * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Andreas Gohr <andi@splitbrain.org> */ // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'action.php'); class action_plugin_fontcolor extends DokuWiki_Action_Plugin { /** * return some info * * @author Andreas Gohr <andi@splitbrain.org> */ function getInfo(){ return array_merge(confToHash(dirname(__FILE__).'/README'), array('name' => 'Toolbar Component')); } /** * register the eventhandlers * * @author Andreas Gohr <andi@splitbrain.org> */ function register(&$controller){ $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handle_toolbar', array ()); } function handle_toolbar(&$event, $param) { $event->data[] = array ( 'type' => 'picker', 'title' => $this->getLang('picker'), 'icon' => '../../plugins/fontcolor/images/toolbar/picker.png', 'list' => array( array( 'type' => 'format', 'title' => $this->getLang('black'), 'icon' => '../../plugins/fontcolor/images/toolbar/black.png', 'open' => '<fc #000000>', 'close' => '</fc>', ), array( 'type' => 'format', 'title' => $this->getLang('maroon'), 'icon' => '../../plugins/fontcolor/images/toolbar/maroon.png', 'open' => '<fc #800000>', 'close' => '</fc>', ), array( 'type' => 'format', 'title' => $this->getLang('green'), 'icon' => '../../plugins/fontcolor/images/toolbar/green.png', 'open' => '<fc #008000>', 'close' => '</fc>', ), array( 'type' => 'format', 'title' => $this->getLang('olive'), 'icon' => '../../plugins/fontcolor/images/toolbar/olive.png', 'open' => '<fc #808000>', 'close' => '</fc>', ), array( 'type' => 'format', 'title' => $this->getLang('navy'), 'icon' => '../../plugins/fontcolor/images/toolbar/navy.png', 'open' => '<fc #000080>', 'close' => '</fc>', ), array( 'type' => 'format', 'title' => $this->getLang('purple'), 'icon' => '../../plugins/fontcolor/images/toolbar/purple.png', 'open' => '<fc #800080>', 'close' => '</fc>', ), array( 'type' => 'format', 'title' => $this->getLang('teal'), 'icon' => '../../plugins/fontcolor/images/toolbar/teal.png', 'open' => '<fc #008080>', 'close' => '</fc>', ), array( 'type' => 'format', 'title' => $this->getLang('silver'), 'icon' => '../../plugins/fontcolor/images/toolbar/silver.png', 'open' => '<fc #C0C0C0>', 'close' => '</fc>', ), array( 'type' => 'format', 'title' => $this->getLang('gray'), 'icon' => '../../plugins/fontcolor/images/toolbar/gray.png', 'open' => '<fc #808080>', 'close' => '</fc>', ), array( 'type' => 'format', 'title' => $this->getLang('red'), 'icon' => '../../plugins/fontcolor/images/toolbar/red.png', 'open' => '<fc #FF0000>', 'close' => '</fc>', ), array( 'type' => 'format', 'title' => $this->getLang('lime'), 'icon' => '../../plugins/fontcolor/images/toolbar/lime.png', 'open' => '<fc #00FF00>', 'close' => '</fc>', ), array( 'type' => 'format', 'title' => $this->getLang('yellow'), 'icon' => '../../plugins/fontcolor/images/toolbar/yellow.png', 'open' => '<fc #FFFF00>', 'close' => '</fc>', ), array( 'type' => 'format', 'title' => $this->getLang('blue'), 'icon' => '../../plugins/fontcolor/images/toolbar/blue.png', 'open' => '<fc #0000FF>', 'close' => '</fc>', ), array( 'type' => 'format', 'title' => $this->getLang('fuchsia'), 'icon' => '../../plugins/fontcolor/images/toolbar/fuchsia.png', 'open' => '<fc #FF00FF>', 'close' => '</fc>', ), array( 'type' => 'format', 'title' => $this->getLang('aqua'), 'icon' => '../../plugins/fontcolor/images/toolbar/aqua.png', 'open' => '<fc #00FFFF>', 'close' => '</fc>', ), array( 'type' => 'format', 'title' => $this->getLang('white'), 'icon' => '../../plugins/fontcolor/images/toolbar/white.png', 'open' => '<fc #FFFFFF>', 'close' => '</fc>', ), ) ); } }
Though the plugin works fine within the text, it does not show in the toolbar any more.
This happens in Release 2009-12-25c “Lemming” of DokuWiki.
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's cache. Worked for me. (03/24/2010)
At first it didn't work for me either, then I changed my template to default and back, et voilà (03/29/2010)
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 </fc></fc> or only if <fc #FFFFFF > is makrked it should be changed to <fc #FF00FF >. Thanks!
Why one cannot nest FC tags? <fc #ff0000>This is a red message, <fc #ff0000>but this is a blue one.</fc> And now it's red again.</fc> Do you plan to support this kind of nesting in the very close future? Thanks
Hi, I installed the plugin manually, just by cp'ing the directory over to /lib/plugins/fontcolor. The function works, but it's not in the toolbar. I saw other people mention that but clearing cache did not work for me. I'm not sure what the one person meant by changing their template, I'm pretty new to this dokuwiki.
Any ideas?
I got the same Problem, the Toolbar does not apper in Anteater Version Problem solved after one Day, may be a Caching Problem
2011-06-10 Are there any way to get the ODT export colorized too ?
Thanks.
2011-08-20 Would be cool having it working inside a title, like
====foo<fc red>bar</fc>====
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, supress, italic … Thanks anyway, it's very usefull :)