Class: ReVIEW::HTMLTOCPrinter

Inherits:
TOCPrinter show all
Includes:
HTMLUtils
Defined in:
lib/review/tocprinter.rb

Constant Summary

Constants included from HTMLUtils

ReVIEW::HTMLUtils::ESC

Instance Method Summary collapse

Methods included from HTMLUtils

#escape_comment, #escape_html, #highlight, #highlight_pygments?, #normalize_id, #strip_html, #unescape_html

Methods inherited from TOCPrinter

default_upper_level, #initialize, #nkffilter, #print?

Constructor Details

This class inherits a constructor from ReVIEW::TOCPrinter

Instance Method Details



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/review/tocprinter.rb', line 107

def print_book(book)
  return unless print?(1)
  html = ""
  book.each_part do |part|
    html << h1(part.name) if part.name
    part.each_section do |chap|
      if chap.number
        name = "chap#{chap.number}"
        label = "#{chap.number}#{chap.label}"
        html << h2(a_name(escape_html(name), escape_html(label)))
      else
        label = "#{chap.label}"
        html << h2(escape_html(label))
      end
      return unless print?(2)
      if print?(3)
        html << chap_sections_to_s(chap)
      else
        html << chapter_to_s(chap)
      end
    end
  end
  layout_file = File.join(book.basedir, "layouts", "layout.html.erb")
  unless File.exist?(layout_file) # backward compatibility
    layout_file = File.join(book.basedir, "layouts", "layout.erb")
  end
  puts HTMLLayout.new(
    {'body' => html, 'title' => "目次"}, layout_file).result
end