def METHOD_NAME(self, text):
    pylexer = PythonLexer(**self.options)
    tblexer = PythonTracebackLexer(**self.options)
    curcode = ""
    insertions = []
    for match in line_re.finditer(text):
        line = match.group()
        input_prompt = self.input_prompt.match(line)
        continue_prompt = self.continue_prompt.match(line.rstrip())
        output_prompt = self.output_prompt.match(line)
        if line.startswith("#"):
            insertions.append((len(curcode), [(0, Comment, line)]))
        elif input_prompt is not None:
            insertions.append(
                (len(curcode), [(0, Generic.Prompt, input_prompt.group())])
            )
            curcode += line[input_prompt.end() :]
        elif continue_prompt is not None:
            insertions.append(
                (len(curcode), [(0, Generic.Prompt, continue_prompt.group())])
            )
            curcode += line[continue_prompt.end() :]
        elif output_prompt is not None:
            # Use the 'error' token for output.  We should probably make
            # our own token, but error is typicaly in a bright color like
            # red, so it works fine for our output prompts.
            insertions.append(
                (len(curcode), [(0, Generic.Error, output_prompt.group())])
            )
            curcode += line[output_prompt.end() :]
        else:
            if curcode:
                for item in do_insertions(
                    insertions, pylexer.METHOD_NAME(curcode)
                ):
                    yield item
                    curcode = ""
                    insertions = []
            yield match.start(), Generic.Output, line
    if curcode:
        for item in do_insertions(
            insertions, pylexer.METHOD_NAME(curcode)
        ):
            yield item