def fontify(self, code): "Return a fontified version of some Python code." if code[0] == '\n': code = code[1:] tags = PyFontify.fontify(code) fontifiedCode = '' pos = 0 for k, i, j, dummy in tags: fontifiedCode = fontifiedCode + code[pos:i] s, e = self.formats[k] fontifiedCode = fontifiedCode + s + code[i:j] + e pos = j fontifiedCode = fontifiedCode + code[pos:] return fontifiedCode