Sha256: 4e4bf33dc3cb1ce6fda629dcac12d720fbdd5e69d0e9bd666ee1bc6c30a001ee

Contents?: true

Size: 559 Bytes

Versions: 1

Compression:

Stored size: 559 Bytes

Contents

module Rpub
  class Epub
    class HtmlToc < XmlFile
      attr_reader :book

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

      def render
        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.id].join('#')
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rpub-0.1.0 lib/rpub/epub/html_toc.rb