def text(self, data):
data = data<EOL>middle = data.lstrip(spaceCharacters)<EOL>left = data[:len(data) - len(middle)]<EOL>if left:<EOL><INDENT>yield {"<STR_LIT:type>": "<STR_LIT>", "<STR_LIT:data>": left}<EOL><DEDENT>data = middle<EOL>middle = data.rstrip(spaceCharacters)<EOL>right = data[len(middle):]<EOL>if middle:<EOL><INDENT>yield {"<STR_LIT:type>": "<STR_LIT>", "<STR_LIT:data>": middle}<EOL><DEDENT>if right:<EOL><INDENT>yield {"<STR_LIT:type>": "<STR_LIT>", "<STR_LIT:data>": right}<EOL><DEDENT>
Generates SpaceCharacters and Characters tokens

        Depending on what's in the data, this generates one or more
        ``SpaceCharacters`` and ``Characters`` tokens.

        For example:

            >>> from html5lib.treewalkers.base import TreeWalker
            >>> # Give it an empty tree just so it instantiates
            >>> walker = TreeWalker([])
            >>> list(walker.text(''))
            []
            >>> list(walker.text('  '))
            [{u'data': '  ', u'type': u'SpaceCharacters'}]
            >>> list(walker.text(' abc '))  # doctest: +NORMALIZE_WHITESPACE
            [{u'data': ' ', u'type': u'SpaceCharacters'},
            {u'data': u'abc', u'type': u'Characters'},
            {u'data': u' ', u'type': u'SpaceCharacters'}]

        :arg data: the text data

        :returns: one or more ``SpaceCharacters`` and ``Characters`` tokens