Attachment 'Color2-1.9.3.py'
Download 1 """
2 MoinMoin - Color2 Macro
3
4 @copyright: 2006 by Clif Kussmaul <clif@kussmaul.org>
5 2008 by Clif Kussmaul, Dave Hein (MoinMoin:DaveHein)
6 2011 by Clif Kussmaul, Dave Hein (MoinMoin:DaveHein), Gregor Mirai
7 @license: GNU GPL, see COPYING for details
8
9 Usage: <<Color2(text,col=color,bcol=bgcolor,font=_font_)>>
10 <<Color2(text,bcol=bgcolor)>>
11 <<Color2(text,color)>>
12
13 History:
14 - 2011.02.23: [Moin 1.9] updated for Moin 1.9 by Gregor Mirai,
15 code simplified due to new parameter parsing and lots of other improvements in Moin code.
16 No MiniPage functionality for the text parameter.
17 - 2008.01.25: [Moin 1.6] updated for Moin 1.6 by Dave Hein,
18 no functional changes.
19 - 2006: [Moin 1.5] written by Clif Kussmaul
20 - originally based on Color Macro
21 Copyright (c) 2002 by Markus Gritsch <gritsch@iue.tuwien.ac.at>
22 """
23
24 from MoinMoin import wikiutil
25
26 """
27 Parameters that macro accepts are:
28 - text (the text to be colored)
29 - col (optional text color)
30 - bcol (optional background text color)
31 - font (optional font)
32
33 Examples:
34
35 <<Color2(Hello World!,col=red,bcol=blue,font=18px courier)>>
36 <<Color2(Hello World!,bcol=blue)>>
37 <<Color2(Hello World!,orange)>>
38 """
39
40 def macro_Color2(macro, text=None, col=None, bcol=None, font=None):
41 f = macro.formatter
42
43 if not text:
44 return f.strong(1) + \
45 f.text('Color2 examples : ') + \
46 f.text('<<Color2(Hello World!,red,blue,18px courier)>>, ') + \
47 f.text('<<Color2(Hello World!,col=red,bcol=blue,font=18px courier)>>, ') + \
48 f.text('<<Color2(Hello World!,#8844AA)>>') + \
49 f.strong(0) + f.linebreak(0)
50
51 style = ''
52 if col:
53 style += 'color:%s; ' % col
54 if bcol:
55 style += 'background-color:%s; ' % bcol
56 if font:
57 style += 'font:%s; ' % font
58
59 # Escape HTML stuff.
60 text = wikiutil.escape(text)
61
62 return f.rawHTML('<span style="%s">' % style) + text + f.rawHTML('</span>')
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.