<> = Color2 = A simple macro to create colored text. One can optionally also set background color and font. '''Note:''' [[MacroMarket/span]] is a somewhat related, more powerful macro, but if one needs only colored text, this macro is much simpler to use. * '''Python versions''' - 2.5+ * '''Moin versions''' - 1.5, 1.6, 1.9 * '''Copyright''' - ClifKussmaul, DaveHein, GregorMirai * '''License''' - [[GPL|GNU GPL]] version 2 * '''Download''' - [[attachment:Color2-1.9.9.py|Latest version 2017.05.17 - 1.9.9]] == Download & Release Notes == '''Note''': should be installed as Color2.py ||'''Download''' ||<18%>'''Release Version''' ||<18%>'''Moin Version''' ||'''Release Notes''' || ||[[attachment:Color2-1.9.9.py]] ||1.9.9 ||1.9.9 ||Added validation of style arguments to address security issue. || ||[[attachment:Color2-1.9.3-1.py]] ||1.9.3-1 ||1.9.3-1 ||Added "MiniPage" support on text parameter. || ||[[attachment:Color2-1.9.3.py]] ||1.9.3 ||1.9.3 ||Tested on 1.9.3 version of MoinMoin || ||[[attachment:Color2-1.6.py]] ||1.6 ||1.7 ||Tested on 1.7.1 version of MoinMoin || ||[[attachment:Color2-1.6.py]] ||1.6 ||1.6 || || ||[[attachment:Color2.py]] || ||1.5 || || == Usage == {{{ <> }}} ||'''Name''' ||<75%>'''Description''' ||'''Default value''' || ||`text` ||The text to be colored. ||`None` || ||`col` ||Text color. CSS color property. Color names and codes can be found at [[https://www.w3.org/TR/css3-color/|W3C]]. ||`None` || ||`bcol` ||Background text color. CSS background-color property. Color names and codes can be found at [[https://www.w3.org/TR/css3-color/|W3C]]]. ||`None` || ||`font` ||Shorthand font. CSS font property; requires at least a font size and font family, e.g. `"1em Georgia, serif"`. Valid property values can be found at [[https://www.w3.org/TR/2013/CR-css-fonts-3-20131003/#propdef-font|W3C]]. ||`None` || == Example == === Tested in MoinMoin 1.9.9 (2017.05.17) === Example, in normal text: {{{ <> <> <> <> <> <> <> }}} Result: {{attachment:Color2_example-1.9.9-at-2017-05-17.png|Example 1.9.9}} === Tested in MoinMoin 1.9.3 (2011.02.23) === Colored text (syntax as of MoinMoin 1.9.3): Example, in normal text: {{{ <> <> <> <> <> }}} === Tested in MoinMoin 1.8.2 (2009.03.12) === Colored text (syntax as of MoinMoin 1.7.1): In normal text {{{ <> <> <> }}} Example, in normal text: {{{ <> <> <> }}} Result (somehow, courier does not work? (Answer: because font size is also needed.) example from "Description" above): {{attachment:Color2_Example.png|Example Normal Text}} Also works within tables: {{{ ||<><
><><
><>|| }}} {{{ || '''Notice!'''<
>The allocation of IP addresses for the abc interfaces on the host start with 10.10.<>.<> --> (abc server .<>). || }}} {{attachment:Color2_ExampleTables.png|Example Tables}} = Bugs = This macro should be refactored a. use of arg parser for macros ('''DONE''' - default parameter parsing for macros in 1.9.X) a. use of wikiutil.renderText() ('''DONE''') a. /!\ user input needs to be escaped XSS problems ('''DONE''' - uses formatter.escapedText(text)) a. /!\ style arguments checked for valid or well-formed CSS to prevent CSS injection attacks ('''DONE''' -- CSS validation added in 1.9.9) = Discussion = * If there is no syntax given by the authors, you might find some information in the .py file itself. ('''DONE''' - usage described) * When using super or subscript modifiers Color2 does not work -- PeterGurk * This macro does not give an easy way to color text that has commas in it. -- JohnJHarrison ('''DONE''' - result of default par. parsing in 1.9.X) . It seems that this macro also supports colon (:) as a delimiter, which could be a workaround for the comma (,) issue. Nonetheless, since both (,) and (:) are frequently used in normal texts, how about allowing it use a bar (|) rather than comma (,)? Example: [[attachment:Color2_bar.py]]. -- TakeoKatsuki <> {{{ <> }}} {{attachment:Color2_bar_example.png}} . It should also work if the text is entered quoted. comma is the delimiter for arguments if the argumentparser is involved. `<>` so it makes sense for one using this macro to refactor it to use the argument parser and while doing this also to fix the XSS problem. . Currently it doesn't work with quote, right? . Yes, because it is not using the argument parser. Besides looking into the moin macros e.g. [[http://hg.moinmo.in/moin/1.8/file/a6b0b1fcd463/MoinMoin/macro/EmbedObject.py|EmbedObject.py]] a simple example is given at [[http://moinmo.in/MacroMarket/HelloWorld-1.7|HelloWorld-1.7]] ([[http://moinmo.in/MoinAPI/Beispiele#macro|macro examples]]). * When using with MoinMoin 1.8.2 the macro seems to add a line break after the coloured text in the preview pane. The page is displayed correctly though. -- SamRoy * When using MoinMoin 1.9.3, there is also this problem with line break in the preview pane (but this is not a problem for our team). After saving the page is displayed correctly, BUT it is displayed again with line breaks when it is INCLUDED in some other page (and this is is big problem for our team...). Any chance of this getting fixed or any hints how we can fix it by ourselves? Thanks in advance. -- MichalAron * I've tested this "break line" with 1.6 and 1.7, and the reason is somewhere in formattext procedure. -- KrisR * Anyone tested the Color2 macro on 1.9.3? Thanks. -- lanepierce ('''DONE''') * Add this to line 74 to get rid of new line when using moinmoin version 1.5.2: {{{ text = re.sub('

', '', text).strip() }}} . ''please see SecurityFixes and upgrade your 1.5.2 wiki instance''