MacroBazaar: Color.py
| File Color.py, 486 bytes (added by ksa, 6 years ago) |
|---|
| Line | |
|---|---|
| 1 | """ |
| 2 | Macro for colorizing short text , usage is |
| 3 | |
| 4 | {{{ |
| 5 | [[Color(color, text)]] |
| 6 | }}} |
| 7 | |
| 8 | """ |
| 9 | from StringIO import StringIO |
| 10 | |
| 11 | def execute(hdf, args, env): |
| 12 | buf = StringIO() |
| 13 | if args: |
| 14 | args = args.split(', ',1) |
| 15 | buf.write("<font color='%(color)s'>%(text)s</font>" % dict(color=args[0], text=args[1])) |
| 16 | else: |
| 17 | buf.write("<p style='font-weight:bold; color:red;'>[[Color()]] macro requires a color spec and text: [[Color(color, text)]]</p>\n") |
| 18 | |
| 19 | return buf.getvalue() |
