view data/plugin/macro/span.py @ 531:bd8e88710547

span macro - see MoinMoin:MacroMarket/span
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 22 Jun 2010 13:54:17 +0200
parents
children 942f9b55773e
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - span generating macro

    Supported attrs: css_class, id, lang, dir, title, align

    Unsupported attrs: style - can contain javascript, XSS danger
                       event attrs - same reason

    Usage:
    <<span(red)>>some text contained in a span with css class red<<span>>
    <<span(css_class=red)>>same as above<<span>>
    <<span(id=foobar)>>some text in a span with id foobar<<span>>
    <<span(title="read this!")>>some text with a mouseover title<<span>>

    @copyright: 2010 MoinMoin:ThomasWaldmann
    @license: GNU GPL, see COPYING for details.
"""

Dependencies = []

from MoinMoin.wikiutil import required_arg

def macro_span(macro,
               # first the stuff we can directly give to span formatter:
               css_class=u'',
               id=u'',
               lang=u'',
               dir=u'',
               title=u'',
               align=u'',
               # dangerous, see docstring:
               #style=u'',
              ):
    attrs = {}
    for key, value in [
        ('css_class', css_class), ('id', id),
        ('lang', lang), ('dir', dir),
        ('title', title), ('align', align),
        #('style', style),
        ]:
        if value:
            attrs[key] = value
    span = macro.formatter.span
    if attrs:
        return span(True, **attrs)
    else:
        return span(False)