class MyEbookPub::TOCwithChapterNumbering

Attributes

chapters[R]

Public Instance Methods

header(text, header_level) click to toggle source
# File lib/my_ebook_pub.rb, line 47
def header(text, header_level)
  return unless header_level == 1
  @chapters ||= []
  @chapters << text
  ""
end
postprocess(document) click to toggle source
# File lib/my_ebook_pub.rb, line 54
    def postprocess(document)
      items = []
      @chapters.each_with_index do |text, chapter_number|
        items << "<li><a href=\"#chapter#{chapter_number+1}\">#{text}</a></li>"
      end
return <<HERE
  <ol>
  #{items.join("\n")}
  </ol>
HERE
    end