def METHOD_NAME(self, tokensource, outfile):
    self._define_colors(outfile)
    outfile.write('.nf\n\\f[CR]\n')
    if self.linenos:
        self._write_lineno(outfile)
    for ttype, value in tokensource:
        while ttype not in self.styles:
            ttype = ttype.parent
        start, end = self.styles[ttype]
        for line in value.splitlines(True):
            if self.wrap > 0:
                line = self._wrap_line(line)
            if start and end:
                text = self._escape_chars(line.rstrip('\n'))
                if text != '':
                    outfile.write(''.join((start, text, end)))
            else:
                outfile.write(self._escape_chars(line.rstrip('\n')))
            if line.endswith('\n'):
                if self.linenos:
                    self._write_lineno(outfile)
                    self._linelen = 0
                else:
                    outfile.write('\n')
                    self._linelen = 0
    outfile.write('\n.fi')