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.
  • [get | view] (2008-01-26 14:27:02, 4.9 KB) [[attachment:Color2-1.6.py]]
  • [get | view] (2011-03-01 17:09:31, 2.3 KB) [[attachment:Color2-1.9.3-1.py]]
  • [get | view] (2011-02-23 16:33:05, 2.1 KB) [[attachment:Color2-1.9.3.py]]
  • [get | view] (2017-05-18 01:43:16, 16.3 KB) [[attachment:Color2-1.9.9.py]]
  • [get | view] (2006-09-19 15:41:58, 4.7 KB) [[attachment:Color2.py]]
  • [get | view] (2008-08-11 16:41:33, 9.8 KB) [[attachment:Color2_Example.png]]
  • [get | view] (2008-08-11 16:42:00, 20.6 KB) [[attachment:Color2_ExampleTables.png]]
  • [get | view] (2009-08-08 00:18:45, 4.9 KB) [[attachment:Color2_bar.py]]
  • [get | view] (2009-08-08 02:07:07, 1.0 KB) [[attachment:Color2_bar_example.png]]
  • [get | view] (2017-05-18 02:28:07, 80.2 KB) [[attachment:Color2_example-1.9.9-at-2017-05-17.png]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.