Example of a macro that wraps wiki content in a div

Usage:

 <<float side='right' >>
 some content to float
 <</float>>

The opening and closing
markup of the macro must
each be on a line by themselves
and cannot have leading whitespace.

from creoleparser import core, dialects, parse_args
import genshi.builder as bldr

def float_div(body,side='right', *pos,**kw):
    if side not in ('left','right'):
        return None
    contents = text2html.generate(body)
    return bldr.tag.div(contents, style='float:'+side)

def macro_func(macro_name, arg_string,body,isblock,environ):
    pos, kw = parse_args(arg_string)
    if macro_name == 'float' and isblock and body:
        return float_div(body,*pos,**kw)

dialect = dialects.create_dialect(
    creole11_base,
    no_wiki_monospace=False,
    macro_func=macro_func
    )
text2html = core.Parser(dialect)