Sha256: 4764f6d73f55c065daf1553f9c0d664a7b1f7272c70fcb14afa43ac70a1afef2

Contents?: true

Size: 628 Bytes

Versions: 3

Compression:

Stored size: 628 Bytes

Contents

module Rpub
  class Epub
    class HtmlToc < XmlFile
      attr_reader :book

      def initialize(book)
        @book = book
        super()
      end

      def render
        xml.div :id => 'toc' do
          xml.h1 'Table of Contents'
          xml.div :class => 'toc' do
            book.outline.each do |(filename, headings)|
              headings.each do |heading|
                xml.div :class => "level-#{heading.level}" do
                  xml.a heading.text, :href => [filename, heading.html_id].join('#')
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rpub-0.4.0 lib/rpub/epub/html_toc.rb
rpub-0.3.0 lib/rpub/epub/html_toc.rb
rpub-0.2.1 lib/rpub/epub/html_toc.rb