'>>> t = Textile()
>>> t.span(r"hello %(bob)span *strong* and **bold**% goodbye")
\'hello <span class="bob">span <strong>strong</strong> and <b>bold</b></span> goodbye\''

def span(self, text):

    qtags = ('\\*\\*', '\\*', '\\?\\?', '\\-', '__', '_', '%', '\\+', '~', '\\^')
    pnct = '.,"\'?!;:'
    for qtag in qtags:
        pattern = re.compile(('\n                                                                (?:^|(?<=[\\s>%(pnct)s\\(])|\\[|([\\]}]))\n                                                                (%(qtag)s)(?!%(qtag)s)\n                                                                (%(c)s)\n                                                                (?::(\\S+))?\n                                                                ([^\\s%(qtag)s]+|\\S[^%(qtag)s\\n]*[^\\s%(qtag)s\\n])\n                                                                ([%(pnct)s]*)\n                                                                %(qtag)s\n                                                                (?:$|([\\]}])|(?=%(selfpnct)s{1,2}|\\s))\n                                                ' % {'qtag': qtag, 'c': self.c, 'pnct': pnct, 'selfpnct': self.pnct}), re.X)
        text = pattern.sub(self.fSpan, text)
    return text
