From e31c98a5c269609eeb4c28eaa4c0cb400b0e1940 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 16 Mar 2025 08:32:11 +0100 Subject: [PATCH] Adding color version 2022-10-19 (e28b337). Signed-off-by: Daniel Baumann --- plugins/55/color/README.md | 18 +++ plugins/55/color/images/picker_blue_gray.png | Bin 0 -> 139 bytes plugins/55/color/images/picker_gold.png | Bin 0 -> 139 bytes plugins/55/color/images/picker_green.png | Bin 0 -> 139 bytes plugins/55/color/images/picker_lavender.png | Bin 0 -> 139 bytes plugins/55/color/images/picker_light_gray.png | Bin 0 -> 139 bytes .../color/images/picker_light_turquoise.png | Bin 0 -> 139 bytes .../55/color/images/picker_light_yellow.png | Bin 0 -> 134 bytes plugins/55/color/images/picker_lime.png | Bin 0 -> 139 bytes plugins/55/color/images/picker_orange.png | Bin 0 -> 139 bytes plugins/55/color/images/picker_red.png | Bin 0 -> 139 bytes plugins/55/color/images/picker_rose.png | Bin 0 -> 139 bytes plugins/55/color/images/picker_turquoise.png | Bin 0 -> 139 bytes plugins/55/color/images/picker_yellow.png | Bin 0 -> 155 bytes plugins/55/color/images/toolbar_icon.png | Bin 0 -> 385 bytes plugins/55/color/plugin.info.txt | 7 ++ plugins/55/color/script.js | 91 ++++++++++++++ plugins/55/color/syntax.php | 115 ++++++++++++++++++ 18 files changed, 231 insertions(+) create mode 100644 plugins/55/color/README.md create mode 100644 plugins/55/color/images/picker_blue_gray.png create mode 100644 plugins/55/color/images/picker_gold.png create mode 100644 plugins/55/color/images/picker_green.png create mode 100644 plugins/55/color/images/picker_lavender.png create mode 100644 plugins/55/color/images/picker_light_gray.png create mode 100644 plugins/55/color/images/picker_light_turquoise.png create mode 100644 plugins/55/color/images/picker_light_yellow.png create mode 100644 plugins/55/color/images/picker_lime.png create mode 100644 plugins/55/color/images/picker_orange.png create mode 100644 plugins/55/color/images/picker_red.png create mode 100644 plugins/55/color/images/picker_rose.png create mode 100644 plugins/55/color/images/picker_turquoise.png create mode 100644 plugins/55/color/images/picker_yellow.png create mode 100644 plugins/55/color/images/toolbar_icon.png create mode 100644 plugins/55/color/plugin.info.txt create mode 100644 plugins/55/color/script.js create mode 100644 plugins/55/color/syntax.php diff --git a/plugins/55/color/README.md b/plugins/55/color/README.md new file mode 100644 index 0000000..cc379c5 --- /dev/null +++ b/plugins/55/color/README.md @@ -0,0 +1,18 @@ +# color Plugin + +This is a plugin for [dokuwiki](https://www.dokuwiki.org/start).. + +See the plugin [homepage](https://www.dokuwiki.org/plugin:color) for detailed documentation. Here we provide a brief summary of the required syntax: + +``` +⟨text⟩ +⟨text⟩ +``` + +- Square brackets indicates optional parts. + +- `⟨fg color⟩` and `⟨bg color⟩` are CSS color specifications. Either one may be empty, in which case it is ignored. + +- In the first syntax, the color specification(s) MUST NOT include a slash (`/`). +- In the second syntax, the color specification(s) MUST NOT include a colon character (`:`). We do not know any legal CSS color specification that does include a colon, nor do we anticipate that one will appear in the future. +- The resulting HTML is a `` element containing `⟨text⟩`, colorized with the given foreground and background colors. diff --git a/plugins/55/color/images/picker_blue_gray.png b/plugins/55/color/images/picker_blue_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..ebed38be60ad9424f7f805cd7cdda7a2492f88b5 GIT binary patch literal 139 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucK?P42#}EtuWStpX`Wrzopr0CM*wqyPW_ literal 0 HcmV?d00001 diff --git a/plugins/55/color/images/picker_gold.png b/plugins/55/color/images/picker_gold.png new file mode 100644 index 0000000000000000000000000000000000000000..bb6ded736e791e1164682c62337ead03f3a987e2 GIT binary patch literal 139 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucK?P42#}Etuu6{1-oD!M<>R2G@ literal 0 HcmV?d00001 diff --git a/plugins/55/color/images/picker_light_yellow.png b/plugins/55/color/images/picker_light_yellow.png new file mode 100644 index 0000000000000000000000000000000000000000..4da4af2f5cae41caee2ac041777672617a6e6d16 GIT binary patch literal 134 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL1|AH#}Etuzopr0EA8@r2qf` literal 0 HcmV?d00001 diff --git a/plugins/55/color/images/picker_orange.png b/plugins/55/color/images/picker_orange.png new file mode 100644 index 0000000000000000000000000000000000000000..ddbac084b9156a86757b33d42f3ec7ac9f2cb6d9 GIT binary patch literal 139 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucK?P42#}Etuwp00i_>zopr0Cc-0QUCw| literal 0 HcmV?d00001 diff --git a/plugins/55/color/images/picker_yellow.png b/plugins/55/color/images/picker_yellow.png new file mode 100644 index 0000000000000000000000000000000000000000..0204813fcfa13f625d7160e8aafc5c6c3e8144a1 GIT binary patch literal 155 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucK?6@0#}EtusmC|+G8k|iF!*Obo&D51)m2Z9 le*V_)Z};=bWE5gUvDvnd0=Ew?C;{qa@O1TaS?83{1OWXYGQ9u* literal 0 HcmV?d00001 diff --git a/plugins/55/color/images/toolbar_icon.png b/plugins/55/color/images/toolbar_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..988d63750971e1e4c65aea03698811b5948b6d80 GIT binary patch literal 385 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucLCF%=h?3y^w370~qEv>0#LT=By}Z;C1rt33 zJwt=FTwDi$iavU}IEGmGFP*fJkI_-Y_5C+4`Gy~jy}}2sGL&$*6IvVcp;Co_%{)sw*=%U%FU2^T%?H zls^aAI<7=~jaaQ#Qd@5&oYP=7F`0jg-Ah674Ilr$^x42zrt-=3>hmM5Ce8EGR|$XK z8NvIAsYzb@@0|u^`M-*H8V_?vY}zWYq?~EpI{lc2%~fjiRZgBfKKcHBrZ0L`cWi2y ciY7ncy(%NnEjUAI0nqadp00i_>zopr06dJC$^ZZW literal 0 HcmV?d00001 diff --git a/plugins/55/color/plugin.info.txt b/plugins/55/color/plugin.info.txt new file mode 100644 index 0000000..daa3163 --- /dev/null +++ b/plugins/55/color/plugin.info.txt @@ -0,0 +1,7 @@ +base color +author Harald Hanche-Olsen +email harald.hanche-olsen@ntnu.no +date 2022-10-19 +name color syntax plugin +desc Write colored text in DokuWiki. +url https://www.dokuwiki.org/plugin:color diff --git a/plugins/55/color/script.js b/plugins/55/color/script.js new file mode 100644 index 0000000..6f9388a --- /dev/null +++ b/plugins/55/color/script.js @@ -0,0 +1,91 @@ +/* JavaScript function to create color toolbar in Dokuwiki */ +/* see http://www.dokuwiki.org/plugin:color for more info */ + +color_icobase = "../../plugins/color/images/"; + +if(window.toolbar != undefined) { + toolbar[toolbar.length] = { + "type":"picker", + "title":"Color Text", + "icon":color_icobase+"toolbar_icon.png", + "list":[{ + "type":"format", + "title":"Gray Colored Text", + "icon":color_icobase+"picker_light_gray.png", + "open":"", + "close":"" + }, { + "type":"format", + "title":"Rose Highlighted Text", + "icon":color_icobase+"picker_rose.png", + "open":"", + "close":"" + }, { + "type":"format", + "title":"Red Highlighted Text", + "icon":color_icobase+"picker_red.png", + "open":"", + "close":"" + }, { + "type":"format", + "title":"Orange Highlighted Text", + "icon":color_icobase+"picker_orange.png", + "open":"", + "close":"" + }, { + "type":"format", + "title":"Gold Highlighted Text", + "icon":color_icobase+"picker_gold.png", + "open":"", + "close":"" + }, { + "type":"format", + "title":"Yellow Highlighted Text", + "icon":color_icobase+"picker_yellow.png", + "open":"", + "close":"" + }, { + "type":"format", + "title":"Light Yellow Highlighted Text", + "icon":color_icobase+"picker_light_yellow.png", + "open":"", + "close":"" + }, { + "type":"format", + "title":"Green Highlighted Text", + "icon":color_icobase+"picker_green.png", + "open":"", + "close":"" + }, { + "type":"format", + "title":"Lime Highlighted Text", + "icon":color_icobase+"picker_lime.png", + "open":"", + "close":"" + }, { + "type":"format", + "title":"Turquoise Highlighted Text", + "icon":color_icobase+"picker_turquoise.png", + "open":"", + "close":"" + }, { + "type":"format", + "title":"Light Turquoise Highlighted Text", + "icon":color_icobase+"picker_light_turquoise.png", + "open":"", + "close":"" + }, { + "type":"format", + "title":"Blue-Gray Highlighted Text", + "icon":color_icobase+"picker_blue_gray.png", + "open":"", + "close":"" + }, { + "type":"format", + "title":"Lavender Highlighted Text", + "icon":color_icobase+"picker_lavender.png", + "open":"", + "close":"" + }] + }; +} \ No newline at end of file diff --git a/plugins/55/color/syntax.php b/plugins/55/color/syntax.php new file mode 100644 index 0000000..3fc52e9 --- /dev/null +++ b/plugins/55/color/syntax.php @@ -0,0 +1,115 @@ + + */ + +// must be run within DokuWiki +if(!defined('DOKU_INC')) die(); + +/** + * All DokuWiki plugins to extend the parser/rendering mechanism + * need to inherit from this class + */ +class syntax_plugin_color extends DokuWiki_Syntax_Plugin { + + function getType(){ return 'formatting'; } + function getAllowedTypes() { return array('formatting', 'substition', 'disabled'); } + function getSort(){ return 158; } + function connectTo($mode) { $this->Lexer->addEntryPattern('(?=.*?)',$mode,'plugin_color'); } + function postConnect() { $this->Lexer->addExitPattern('','plugin_color'); } + + + /** + * Handle the match + */ + function handle($match, $state, $pos, Doku_Handler $handler){ + switch ($state) { + case DOKU_LEXER_ENTER : + $str = substr($match, 6, -1); + if (false === strpbrk($str,':')){ + $m = explode('/', $str); + } else { + $m = explode(':', $str); + } + $color = $this->_specToCSS('color', $m[0]); + $background = $this->_specToCSS('background-color', + isset($m[1]) ? $m[1] : null); + return [$state, [$color, $background]]; + + case DOKU_LEXER_UNMATCHED : return array($state, $match); + case DOKU_LEXER_EXIT : return array($state, ''); + } + return array(); + } + + /** + * Create output + */ + function render($mode, Doku_Renderer $renderer, $data) { + if($mode == 'xhtml'){ + list($state, $match) = $data; + switch ($state) { + case DOKU_LEXER_ENTER : + list($color, $background) = $match; + $renderer->doc .= ""; + break; + + case DOKU_LEXER_UNMATCHED : $renderer->doc .= $renderer->_xmlEntities($match); break; + case DOKU_LEXER_EXIT : $renderer->doc .= ""; break; + } + return true; + } + if($mode == 'odt'){ + list($state, $match) = $data; + switch ($state) { + case DOKU_LEXER_ENTER : + list($color, $background) = $match; + if (class_exists('ODTDocument')) { + $renderer->_odtSpanOpenUseCSS (NULL, 'style="'.$color.$background.'"'); + } + break; + + case DOKU_LEXER_UNMATCHED : + $renderer->cdata($match); + break; + + case DOKU_LEXER_EXIT : + if (class_exists('ODTDocument')) { + $renderer->_odtSpanClose(); + } + break; + } + return true; + } + if($mode == 'metadata'){ + list($state, $match) = $data; + switch ($state) { + case DOKU_LEXER_UNMATCHED : + if ($renderer->capture) $renderer->cdata($match); + break; + } + return true; + } + return false; + } + + // Build a CSS attribute:value pair. + function _specToCSS($attrib, $c) { + $c = trim($c); + return ((!empty($c) && + $this->_isValid($c)) ? $attrib.':'.$c.';' + : null); + } + + // validate color value $c + // this is cut price validation - only to ensure there is nothing harmful + // just ensure that no illegal characters are included therein + // leave it to the browsers to ignore a faulty colour specification + function _isValid($c) { + return (false === strpbrk($c, '"\'<>&;')); + } +} +?>