# File lib/asciidoctor/backends/html5.rb, line 28
  def self.outline(node, to_depth = 2)
    toc_level = nil
    sections = node.sections
    unless sections.empty?
      # FIXME the level for special sections should be set correctly in the model
      # sec_level will only be 0 if we have a book doctype with parts
      sec_level = sections.first.level
      if sec_level == 0 && sections.first.special
        sec_level = 1
      end
      toc_level = %(<ol type="none" class="sectlevel#{sec_level}">\n)
      numbered = node.document.attr? 'numbered'
      sections.each do |section|
        # need to check playback attributes for change in numbered setting
        # FIXME encapsulate me
        if section.attributes.has_key? :attribute_entries
          if (numbered_override = section.attributes[:attribute_entries].find {|entry| entry.name == 'numbered'})
            numbered = numbered_override.negate ? false : true
          end
        end
        section_num = numbered && !section.special && section.level > 0 && section.level < 4 ? %(#{section.sectnum} ) : nil
        toc_level = %(#{toc_level}<li><a href=\"##{section.id}\">#{section_num}#{section.caption}#{section.title}</a></li>\n)
        if section.level < to_depth && (child_toc_level = outline(section, to_depth))
          toc_level = %(#{toc_level}<li>\n#{child_toc_level}\n</li>\n)
        end
      end
      toc_level = %(#{toc_level}</ol>)
    end
    toc_level
  end