Make the text representation of a report element as html.

def make_html(self):
        """
        Make the text representation of a report element as html.
        """
        html = None
        if self.function == 'total':
            html = u'<table border="0" width="100%" rules="cols" cellpadding="2">\n'\
                   '<tr><th colspan="2" align="left"><h3><font color="{1}">'\
                   '{0}</font></h3></th></tr>\n'\
                   .format(htmlsafe(self.title.strip()), self.color)

            for res in self.results:
                html = u'{0}<tr><td valign="top" align="right">{1}</td>'\
                       '<td valign="top" width="90%">{2}</td></tr>'\
                       .format(html, res[0], res[1])

        elif self.function == 'top':
            html = u'<table border="0" width="100%" rules="cols" cellpadding="2">\n'\
                   '<tr><th colspan="2" align="left"><h3><font color="{1}">'\
                   '{0}</font></h3></th></tr>\n'\
                   .format(htmlsafe(self.title.strip()), self.color)

            if self.results[0] is not None:
                for res in self.results:
                    if res is not None:
                        html = u'{0}<tr><td valign="top" align="right">{1}</td>'\
                               '<td valign="top" width="90%">{2}</td></tr>'\
                               .format(html, res[0], ', '.join(res[1]))
            else:
                html = u'{0}<tr><td valign="top" align="left">{1}</td>'\
                       .format(html, "None")
                
        elif self.function == 'table':
            html = u'<h3><font color="{1}">{0}</font></h3>'\
                   '<table width="100%" rules="cols" cellpadding="2">\n'\
                   '<tr bgcolor="#aaaaaa">'\
                   .format(htmlsafe(self.title.strip()), self.color)
            
            headers = re.split('\s*,\s*', self.headers)
            for i in range(len(headers)):
                html = '{0}<th align="center" colspan="1">'\
                       '<font color="black">{1}</font></th>'\
                       .format(html, headers[i].strip('"'))

            html = u'{0}</tr>\n'.format(html)
            
            oddflag = False
            lastval = ""            
            for res in sorted(self.results, key=lambda x: x[0]):
                if lastval != res[0]:
                    oddflag = not oddflag
                    if oddflag:
                        html = u'{0}<tr bgcolor="#dddddd">'.format(html)
                    else:
                        html = u'{0}<tr>'.format(html)

                    html = u'{0}<td valign="top" width="15%">{1}</td>'\
                           .format(html, res[0])
                else:
                    if oddflag:
                        html = u'{0}<tr bgcolor="#dddddd">'.format(html)
                    else:
                        html = u'{0}<tr>'.format(html)

                    html = u'{0}<td valign="top" width="15%">&nbsp;</td>'.format(html)
                lastval = res[0]
                
                for i in range(1, len(headers)-1):
                    html = u'{0}<td valign="top" width="15%">{1}</td>'.format(html, res[i])
                lastcol = get_fmt_results(res[-1], limit=10, fmt=u'<font color="darkred">{0}</font>')

                if lastcol[-1].find(u" more skipped]") > -1:
                    html = u'{0}<td valign="top" width="{1}%">{2} {3}</td></tr>\n'\
                           .format(html, 100-15*(len(headers)-1),
                                   u', '.join(lastcol[:-1]), lastcol[-1])
                else:
                    html = u'{0}<td valign="top" width="{1}%">{2}</td></tr>\n'\
                           .format(html, 100-15*(len(headers)-1), u', '.join(lastcol))

        self.html = u'{0}</table>\n<p>\n'.format(html)