'Render the Table of Contents.'

@verbose
def _render_toc(self, verbose=None):

    logger.info('Rendering    :    Table    of    Contents')
    html_toc = u'<div    id="container">'
    html_toc += u'<div    id="toc"><center><h4>CONTENTS</h4></center>'
    global_id = 1
    if self._sort_sections:
        sections = list((set(self.sections) & set(SECTION_ORDER)))
        custom = [section for section in self.sections if (section not in SECTION_ORDER)]
        order = [sections.index(section) for section in SECTION_ORDER if (section in sections)]
        self.sections = (np.array(sections)[order].tolist() + custom)
    (html, fnames, sectionlabels) = ([], [], [])
    for section in self.sections:
        logger.info(('%s' % section))
        for (sectionlabel, this_html, fname) in zip(self._sectionlabels, self.html, self.fnames):
            if (self._sectionvars[section] == sectionlabel):
                html.append(this_html)
                fnames.append(fname)
                sectionlabels.append(sectionlabel)
                logger.info(_get_fname(fname))
                color = _is_bad_fname(fname)
                (div_klass, tooltip, text) = _get_toc_property(fname)
                if fname.endswith(('-ave.fif', '-ave.fif.gz', '(whitened)')):
                    text = os.path.basename(fname)
                    if fname.endswith('(whitened)'):
                        fname = fname[:(-11)]
                    evokeds = read_evokeds(fname, verbose=False)
                    html_toc += toc_list.substitute(div_klass=div_klass, id=None, tooltip=fname, color='#428bca', text=text)
                    html_toc += u'<li    class="evoked"><ul>'
                    for ev in evokeds:
                        html_toc += toc_list.substitute(div_klass=div_klass, id=global_id, tooltip=fname, color=color, text=ev.comment)
                        global_id += 1
                    html_toc += u'</ul></li>'
                elif fname.endswith(tuple((VALID_EXTENSIONS + ['bem', 'custom']))):
                    html_toc += toc_list.substitute(div_klass=div_klass, id=global_id, tooltip=tooltip, color=color, text=text)
                    global_id += 1
    html_toc += u'\n</ul></div>'
    html_toc += u'<div    id="content">'
    self.html = html
    self.fnames = fnames
    self._sectionlabels = sectionlabels
    html_header = header_template.substitute(title=self.title, include=self.include, sections=self.sections, sectionvars=self._sectionvars)
    self.html.insert(0, html_header)
    self.html.insert(1, html_toc)
