Class: ReVIEW::WEBTOCPrinter
Constant Summary
Constants included
from HTMLUtils
HTMLUtils::ESC
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from HTMLUtils
#escape_comment, #escape_html, #highlight, #highlight?, #normalize_id, #strip_html, #unescape_html
Methods inherited from TOCPrinter
default_upper_level, #initialize, #print?
Class Method Details
.book_to_string(book) ⇒ Object
7
8
9
10
11
12
|
# File 'lib/review/webtocprinter.rb', line 7
def self.book_to_string(book)
io = StringIO.new
ReVIEW::WEBTOCPrinter.new(1, {}, io).print_book(book)
io.seek(0)
io.read
end
|
Instance Method Details
#print_book(book) ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/review/webtocprinter.rb', line 14
def print_book(book)
@out.puts '<ul class="book-toc">'
@out.puts "<li><a href=\"index.html\">TOP</a></li>\n"
book.each_part do |part|
print_part(part)
end
@out.puts '</ul>'
end
|
#print_chapter(chap) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/review/webtocprinter.rb', line 35
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 href=\"#{path}\">#{h(label)}</a></li>\n"
end
|
#print_part(part) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/review/webtocprinter.rb', line 23
def print_part(part)
if part.number
@out.puts "<li>#{h(part.title)}\n<ul>\n"
end
part.each_chapter do |chap|
print_chapter(chap)
end
if part.number
@out.puts "</ul>\n</li>\n"
end
end
|