Edgewall Software

MacroBazaar: Color-0.11.py

File Color-0.11.py, 617 bytes (added by jon@…, 10 years ago)

replacement for Color.py to support 0.11

Line 
1from trac.core import *
2from trac.wiki.macros import WikiMacroBase
3from StringIO import StringIO
4
5__all__ = ['ColorMacro']
6
7class ColorMacro(WikiMacroBase):
8 """
9 Macro for colorizing short text , usage is
10
11 {{{
12 [[Color(color, text)]]
13 }}}
14
15 """
16 def render_macro(self, formatter, name, args):
17 buf = StringIO()
18 if args:
19 args = args.split(', ',1)
20 buf.write("<font color='%(color)s'>%(text)s</font>" % dict(color=args[0], text=args[1]))
21 else:
22 buf.write("<p style='font-weight:bold; color:red;'>[[Color()]] macro requires a color spec and text: [[Color(color, text)]]</p>\n")
23
24 return buf.getvalue()