require 'review/tocprinter' require 'review/i18n' require 'review/htmlutils' module ReVIEW class WEBTOCPrinter < TOCPrinter include HTMLUtils def self.book_to_string(book) ReVIEW::WEBTOCPrinter.new.print_book(book) end def print_book(book) @book = book @indent = nil @upper = 1 # only part and chapter print_result(build_result_array) end def print_result(result_array) content = <
  • TOP
  • EOT path = '' result_array.each do |result| unless result.headline result.headline = '-' end if result.name path = "#{result.name}.#{@book.config['htmlext']}" next end if result.part if result.part == 'end' content << "\n" end next end if path.start_with?('.') content << "
  • #{escape(result.headline)}" else content << %Q(
  • #{escape(result.headline)}) end if result.level == 0 content << "\n\n" end end end