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.

Download & Release Notes

Note: should be installed as Color2.py

Download

Release Version

Moin Version

Release Notes

Color2-1.9.9.py

1.9.9

1.9.9

Added validation of style arguments to address security issue.

Color2-1.9.3-1.py

1.9.3-1

1.9.3-1

Added "MiniPage" support on text parameter.

Color2-1.9.3.py

1.9.3

1.9.3

Tested on 1.9.3 version of MoinMoin

Color2-1.6.py

1.6

1.7

Tested on 1.7.1 version of MoinMoin

Color2-1.6.py

1.6

1.6

Color2.py

1.5

Usage

<<Color2(text,col=text_color,bcol=background_color,font=shorthand_font)>>

Name

Description

Default value

text

The text to be colored.

None

col

Text color. CSS color property. Color names and codes can be found at W3C.

None

bcol

Background text color. CSS background-color property. Color names and codes can be found at 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 W3C.

None

Example

Tested in MoinMoin 1.9.9 (2017.05.17)

Example, in normal text:

<<Color2(red courier on blue,col=red,bcol=blue,font=1em courier)>>

<<Color2(Green Font on Yellow Background,green,yellow)>>

<<Color2(Orange Text,orange)>>

<<Color2(text="This is red on light gray, and is neither long nor short.", col="#f00", bcol="lightgray", font="1em 'Marker Felt', 'Comic Sans MS', TSCu_Comic, Georgia, serif")>>

<<Color2("This is highlighted.", bcol="yellow")>>
<<Color2("Text with commas:one,two,three",red)>>

<<Color2("Optional parameters",bcol=yellow)>>

Result:

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:

<<Color2(red courier on blue,col=red,bcol=blue,font=1em courier)>>

<<Color2(Green Font on Yellow Background,green,yellow)>>

<<Color2(Orange Text,orange)>>

<<Color2("Text with commas:one,two,three",red)>>

<<Color2("Optional parameters",bcol=yellow)>>

Tested in MoinMoin 1.8.2 (2009.03.12)

Colored text (syntax as of MoinMoin 1.7.1):

In normal text

<<Color2(color,bgcolor,font,text)>>
<<Color2(color,bgcolor,text)>>
<<Color2(color,text)>>

Example, in normal text:

<<Color2(red,blue,courier,red courier on blue)>>

<<Color2(green,yellow,Green Font on Yellow Background)>>

<<Color2(orange,Orange Text)>>

Result (somehow, courier does not work? (Answer: because font size is also needed.) example from "Description" above):

Example Normal Text

Also works within tables:

||<<Color2(red,blue,courier,red courier on blue)>><<BR>><<Color2(green,yellow,Green Font on Yellow Background)>><<BR>><<Color2(orange,Orange Text)>>||

||<style="background-color: #CCFFFF;"> <!> '''Notice!'''<<BR>>The allocation of IP addresses for the abc interfaces on the host start with 10.10.<<Color2(red,1)>>.<<Color2(red,1)>> --> (abc server .<<Color2(red,rack 1, rack position 1)>>). ||

Example Tables

Bugs

This macro should be refactored

  1. use of arg parser for macros (DONE - default parameter parsing for macros in 1.9.X)

  2. use of wikiutil.renderText() (DONE)

  3. /!\ user input needs to be escaped XSS problems (DONE - uses formatter.escapedText(text))

  4. /!\ style arguments checked for valid or well-formed CSS to prevent CSS injection attacks (DONE -- CSS validation added in 1.9.9)

Discussion

MoinMoin: MacroMarket/Color2 (last edited 2017-05-18 02:34:59 by DaveHein)