view data/plugin/macro/span.py @ 532:942f9b55773e

span macro: remove support for align attr as it is deprecated
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 22 Jun 2010 14:21:59 +0200
parents bd8e88710547
children 1f9926e7f5b5
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - span generating macro

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

    Unsupported attrs: style - can contain javascript, XSS danger
                       event attrs - same reason
                       align - deprecated by the W3C (use css classes)

    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'',
               # deprecated by W3C:
               #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)