'Return a string div given a toc list.'

def build_toc_div(self, toc_list):

    div = etree.Element(u'div')
    div.attrib[u'class'] = u'toc'
    if self.title:
        header = etree.SubElement(div, u'span')
        header.attrib[u'class'] = u'toctitle'
        header.text = self.title
    def build_etree_ul(toc_list, parent):
        ul = etree.SubElement(parent, u'ul')
        for item in toc_list:
            li = etree.SubElement(ul, u'li')
            link = etree.SubElement(li, u'a')
            link.text = item.get(u'name', u'')
            link.attrib[u'href'] = (u'#' + item.get(u'id', u''))
            if item[u'children']:
                build_etree_ul(item[u'children'], li)
        return ul
    build_etree_ul(toc_list, div)
    prettify = self.markdown.treeprocessors.get(u'prettify')
    if prettify:
        prettify.run(div)
    return div
