def METHOD_NAME(infile, outfile, debug):
    if debug:
        print "Infile:", infile
    toc = read_toc_data(infile, debug)
    '''
    toc_data = []
    section = re.compile(r"<h(?P<depth>[0-9])( id=\"(?P<id>[^\"]+)\")?>(?P<text>.*)</h[0-9]>")
    for line in f:
        m = section.match(line)
        if m:
            if debug:
                print "toc_data: %s" % str(((m.group('depth'), m.group('text'), m.group('id'))))
            toc_data.append((m.group('depth'), m.group('text'), m.group('id')))
    toc = ''
    if len(toc_data) > 0:
        toc = '<div id="toc">\n'
        for depth, text, link in toc_data:
            if depth >= 2 and link is not None:
                toc += '<div class="toclevel%s"><a href="#%s">%s</a></div>\n' % (
                    int(depth) - 1, link, text)
        toc += '</div>\n'