def format(self, formatter, form):
        """ Parse and send the colored source.
        """
        # store line offsets in self.lines
        self.lines = [0, 0]
        pos = 0
        while 1:
            pos = string.find(self.raw, '\n', pos) + 1
            if not pos: break
            self.lines.append(pos)
        self.lines.append(len(self.raw))

        # parse the source and write it
        self.out.write(docstart)

        # write metadata
        self.out.write("\n<title>" + filename + "</title>\n")
        self.out.write('<link rel="schema.DC" href="http://purl.org/DC/elements/1.0/" />\n')
        self.out.write('<meta name="DC.Language" content="en" />\n')
        self.out.write('<meta name="DC.Format" content="text/html" />\n')
        self.out.write('<meta name="DC.Type" content="Software" />\n')
        self.out.write('<meta name="DC.Title" content="Python source of %s" />\n' % filename)
        self.out.write('<meta name="DC.Creator" content="%s" />\n' % authorname)

        #encoding
        self.out.write('<meta http-equiv="Content-Type" content="text/html; charset=%s" />\n' % docencoding)

        #Close head and begin body.  
        self.out.write("\n\t</head>\n<body>")

        self.pos = 0
        text = cStringIO.StringIO(self.raw)
        self.out.write('<pre><code>')
        try:
            tokenize.tokenize(text.readline, self)
        except tokenize.TokenError, ex:
            msg = ex[0]
            line = ex[1][0]
            self.out.write("<h3>ERROR: %s</h3>%s\n" % (
                msg, self.raw[self.lines[line]:]))
        self.out.write('</code></pre>\n')

        self.out.write(docend)
 Parse and send the colored source.
        
recipes/Python/442482_Python_source_to_XHTML_colorizer/recipe-442482.py