# File lib/review/tocprinter.rb, line 99 def print_book(book) @out.puts '<ul class="book-toc">' book.each_part do |part| print_part(part) end @out.puts '</ul>' end
# File lib/review/tocprinter.rb, line 114 def print_chapter(chap) chap_node = TOCParser.chapter_node(chap) ext = chap.book.config["htmlext"] || "html" path = chap.path.sub(/\.re/, "."+ext) if chap_node.number && chap.on_CHAPS? label = "#{chap.number} #{chap.title}" else label = chap.title end @out.puts li(a_name(path, escape_html(label))) return unless print?(2) if print?(3) @out.puts chap_sections_to_s(chap_node) else @out.puts chapter_to_s(chap_node) end end
# File lib/review/tocprinter.rb, line 107 def print_part(part) if part.number @out.puts li(part.title) end super end
# File lib/review/tocprinter.rb, line 165 def a_name(name, label) %Q(<a name="#{name}">#{label}</a>) end
# File lib/review/tocprinter.rb, line 134 def chap_sections_to_s(chap) return "" if chap.section_size < 1 res = [] res << "<ol>" chap.each_section do |sec| res << li(escape_html(sec.label)) end res << "</ol>" return res.join("\n") end
# File lib/review/tocprinter.rb, line 145 def chapter_to_s(chap) res = [] chap.each_section do |sec| res << li(escape_html(sec.label)) next unless print?(4) if sec.section_size > 0 res << "<ul>" sec.each_section do |node| res << li(escape_html(node.label)) end res << "</ul>" end end return res.join("\n") end
# File lib/review/tocprinter.rb, line 161 def li(content) "<li>#{content}</li>" end