plugin:color
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plugin:color [2016-06-25 15:01] – leeyc0 is willing to hand over the project 119.246.49.224 | plugin:color [2024-02-08 08:12] (current) – rnck | ||
---|---|---|---|
Line 2: | Line 2: | ||
---- plugin ---- | ---- plugin ---- | ||
- | description: | + | description: |
- | author | + | author |
- | email : chris@jalakai.co.uk | + | email : harald.hanche-olsen@ntnu.no |
type : Syntax | type : Syntax | ||
- | lastupdate : 2016-06-25 | + | lastupdate : 2022-10-19 |
- | compatible : 2009-12-25, 2010-11-07, 2011-05-25, 2012-01-25, 2014-05-05, 2014-09-29d, | + | compatible : Adora Belle, Weatherwax, Binky, Ponder Stibbons, Detritus, Elenor Of Tsort, Frusterick Manners, Greebo, Hogfather, Igor, Jack Jackrum, Kaos |
depends | depends | ||
conflicts | conflicts | ||
- | similar | + | similar |
- | tags : typography, highlight | + | tags : typography, highlight, color, text |
- | downloadurl: | + | downloadurl: |
- | sourcerepo : https:// | + | sourcerepo : https:// |
+ | bugtracker : https:// | ||
+ | screenshot_img: | ||
---- | ---- | ||
- | |||
- | ===== Disclaimer ===== | ||
- | Christopher Smith seems leaved the plugin unmaintained. Another user leeyc0 provided hosting of the plugin in the github, but have no time to maintain it. Anyone interested in maintainining may leave a ticket in github and leeyc0 will be glad to hand over the project | ||
===== Installation ===== | ===== Installation ===== | ||
- | Please use the plugin manager to install the plugin, no configuration needed. | + | Please use the [[plugin: |
===== Usage ===== | ===== Usage ===== | ||
Line 30: | Line 29: | ||
< | < | ||
+ | <color green> | ||
<color blue/ | <color blue/ | ||
<color # | <color # | ||
+ | <color /# | ||
+ | <color rgb(80%, | ||
+ | <color hsl(120, | ||
</ | </ | ||
- | This plugin supports the [[https:// | + | and you will see something like this: |
- | ===== Discussion ===== | + | {{https:// |
- | This source for this plugin is shown in the [[devel: | + | The foreground or background color specification can be any valid CSS color specification. Beware that some older browsers will not recognise all color specs in the latest CSS version. |
- | ===== Update History ===== | + | If you use a color specification that contains a slash (''/'' |
- | * 2008-02-06 --- Fixed a security vulnerability in the colour pattern. Any users of this plugin | + | The precise syntax is as follows. Square brackets ('' |
- | * 2014-01-04 hosted in github by leeyc0 | + | < |
- | * 2016-06-25 Added ODT support based on branch " | + | < |
+ | <color [⟨fg-color⟩]:[⟨bg-color⟩]> | ||
+ | </code> | ||
+ | You //must// use the second form if either color spec includes a slash. | ||
+ | Note that in that case, the colon separater ('':'' | ||
- | ===== Version with ODT renderer support ===== | + | No valid color spec including a colon is known at this time, but if you need to use one in the future, you //must// use the first form. This plugin does not provide a way to combine these. |
- | This modified version | + | The result |
- | --- // | + | |
- | > Ooops. The version picked up to add ODT support was from before | + | |
- | Hello, | + | Example – note the mandatory colon here: |
- | I put this plugin on our wiki. | + | |
- | That work well in the wiki but not at the time of export in odt. | + | |
- | At which place must be located the colornames.php ? | + | |
- | Do I use the last version of the plugin odt, have a solution? //cedric 2010/01/11 // | + | |
- | > Hey, Cedric. '' | + | <code> |
+ | <color hwb(120 20% 30% / 50%):>some faded dark green semi-transparent text</color> | ||
+ | </code> | ||
- | <file php syntax.php> | + | Harmless restriction: |
- | <?php | + | This plugin |
- | /** | + | |
- | * Plugin Color: Sets new colors for text and background. | + | |
- | * | + | |
- | * @license | + | |
- | * @author | + | |
- | */ | + | |
- | + | ||
- | // must be run within DokuWiki | + | |
- | if(!defined(' | + | |
- | if(!defined(' | + | |
- | require_once(DOKU_PLUGIN.' | + | |
- | + | ||
- | /** | + | |
- | * All DokuWiki plugins to extend the parser/ | + | |
- | * need to inherit from this class | + | |
- | */ | + | |
- | class syntax_plugin_color extends DokuWiki_Syntax_Plugin { | + | |
- | + | ||
- | var $odt_styles = array(); | + | |
- | /** | + | |
- | * return some info | + | |
- | */ | + | |
- | function getInfo(){ | + | |
- | return array( | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ); | + | |
- | } | + | |
- | + | ||
- | function getType(){ return ' | + | |
- | function getAllowedTypes() { return array(' | + | |
- | function getSort(){ return 158; } | + | |
- | function connectTo($mode) { $this-> | + | |
- | function postConnect() { $this-> | + | |
- | + | ||
- | + | ||
- | /** | + | |
- | * Handle the match | + | |
- | */ | + | |
- | function handle($match, | + | |
- | switch ($state) { | + | |
- | case DOKU_LEXER_ENTER : | + | |
- | list($color, | + | |
- | $color = $this-> | + | |
- | $background = $this-> | + | |
- | return array($state, | + | |
- | + | ||
- | case DOKU_LEXER_UNMATCHED : return array($state, | + | |
- | case DOKU_LEXER_EXIT : | + | |
- | } | + | |
- | return array(); | + | |
- | } | + | |
- | + | ||
- | /** | + | |
- | * Create output | + | |
- | */ | + | |
- | function render($mode, | + | |
- | if($mode == ' | + | |
- | list($state, | + | |
- | switch ($state) { | + | |
- | case DOKU_LEXER_ENTER : | + | |
- | list($color, | + | |
- | $color = $color?" | + | |
- | $background = $background?" | + | |
- | $renderer-> | + | |
- | break; | + | |
- | + | ||
- | case DOKU_LEXER_UNMATCHED : $renderer-> | + | |
- | case DOKU_LEXER_EXIT : | + | |
- | } | + | |
- | return true; | + | |
- | } | + | |
- | | + | |
- | list($state, | + | |
- | switch ($state) { | + | |
- | case DOKU_LEXER_ENTER : | + | |
- | list($color, | + | |
- | $style_index = $color.'/' | + | |
- | if(empty($this-> | + | |
- | { | + | |
- | $stylename = " | + | |
- | $this-> | + | |
- | $color = $color?' | + | |
- | $background = $background?' | + | |
- | $renderer-> | + | |
- | < | + | |
- | < | + | |
- | </ | + | |
- | } | + | |
- | $renderer-> | + | |
- | break; | + | |
- | + | ||
- | case DOKU_LEXER_UNMATCHED : $renderer-> | + | |
- | case DOKU_LEXER_EXIT : | + | |
- | } | + | |
- | return true; | + | |
- | } | + | |
- | return false; | + | |
- | } | + | |
- | + | ||
- | // validate color value $c | + | |
- | // this is cut price validation - only to ensure | + | |
- | // three basic formats | + | |
- | function _isValid($c) { | + | |
- | $c = trim($c); | + | |
- | + | ||
- | $pattern = "/ | + | |
- | ([a-zA-Z]+)| | + | |
- | (\# | + | |
- | (rgb\(([0-9]{1, | + | |
- | )\s*$/ | + | |
- | + | ||
- | if (preg_match($pattern, | + | |
- | + | ||
- | return ""; | + | |
- | } | + | |
- | /** | + | |
- | * Translate color names and RGB to hex values | + | |
- | */ | + | |
- | function _color2hex($name) | + | |
- | { | + | |
- | static $colornames = null; | + | |
- | if(is_null($colornames)) | + | |
- | { | + | |
- | include dirname(__FILE__).'/ | + | |
- | } | + | |
- | if(!preg_match('/ | + | |
- | return $colornames[$name]; | + | |
- | elseif(preg_match('/ | + | |
- | { | + | |
- | $colors = array(); | + | |
- | for($i=1; | + | |
- | { | + | |
- | $percent = substr($matches[$i], | + | |
- | $colors[$i] = $percent? | + | |
- | } | + | |
- | return sprintf('# | + | |
- | } | + | |
- | else | + | |
- | return $name; | + | |
- | } | + | |
- | } | + | |
- | + | For a reference of usable color specifications, | |
- | //Setup VIM: ex: et ts=4 enc=utf-8 : | + | [[https://developer.mozilla.org/ |
- | </file> | + | Beware that not all color specifications work on all browsers. |
+ | See the bottom of the referenced page for more information, | ||
+ | check [[https:// | ||
- | <file php colornames.php> | + | * The plugin works by wrapping contents in a %%<span>%% element with a suitable %%style%% attribute. Therefore, you cannot wrap it around block level items such as headers, lists, and tables. |
- | <?php | + | * You cannot use it //inside// headers either, since [[faq: |
+ | * The use of two or more separators (slashes in the first syntax, colons in the second) within %%'' | ||
- | // HTML 4.01 color names | + | ===== Discussion |
- | $colornames | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | + | ||
- | // | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ); | + | |
- | </ | + | |
- | ===== No header support ===== | + | This source for this plugin is shown in the [[devel: |
- | Hi there, | + | ===== Development ===== |
- | i realized that coloring of headers is not possible. The //=// delimiters turn to plain text when wrapped with the color tag. It would be great to have that feature, if possible.\\ | + | |
- | Thanks for this otherwise awesome plugin! | + | |
- | //rapho 2012/ | + | |
- | I agree that would be very helpful //newbie 2013/ | + | **Christopher Smith** seems to have left the plugin unmaintained. User **leeyc0** provided hosting of the plugin on github, but has no time to maintain it either. **Harald Hanche-Olsen** took over in October 2018. The plugin is considered fairly stable, though, and the new maintainer does not foresee a very active maintenance schedule. New feature requests will likely be rejected. |
- | This would be really nice //CyrilM 2013/ | + | ===== Update History ===== |
- | I like colourful headers as well. // HH 2014/ | + | * 2022-10-19 Allow the use of a colon separator, so that the color specs may contain a slash |
- | + | * 2022-10-16 Removed the (too stringent) syntax checking of the color specifications, | |
- | Mee Too //CW in Miami 2015/6/30// | + | * 2022-09-15 Removed deprecated and unnecessary (but harmless) code |
+ | * 2018-10-12 New maintainer | ||
+ | * 2018-10-10 Added support for rgb[a](…) and hsl[a](…) color specifications | ||
+ | * 2018-08-09 Added code for handling metadata to the render method | ||
+ | * 2016-06-25 Added ODT support based on branch " | ||
+ | * 2014-01-04 hosted | ||
+ | * 2008-02-06 --- Fixed a security vulnerability in the colour pattern. Any users of this plugin should apply this update. | ||
- | This plugin also supports background color, which is defined with ''< |
plugin/color.1466859672.txt.gz · Last modified: 2016-06-25 15:01 by 119.246.49.224