def self.outline(node, to_depth = 2)
toc_level = nil
sections = node.sections
unless sections.empty?
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|
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