Class: Epuber::Compiler::NavGenerator

Inherits:
Generator
  • Object
show all
Defined in:
lib/epuber/compiler/nav_generator.rb

Constant Summary collapse

NCX_NAMESPACES =
{
  'xmlns' => 'http://www.daisy.org/z3986/2005/ncx/',
}.freeze
XHTML_NAMESPACES =
{
  'xmlns' => 'http://www.w3.org/1999/xhtml',
  'xmlns:epub' => 'http://www.idpf.org/2007/ops',
}.freeze
XHTML_IBOOKS_NAMESPACES =
{
  'xmlns:ibooks' => 'http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0',
  'epub:prefix' => 'ibooks: http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0',
}.freeze
LANDMARKS_MAP =
{
  landmark_cover: { type: 'cover', text: 'Cover page' },
  landmark_start_page: { type: %w[bodymatter ibooks:reader-start-page], text: 'Start Reading' },
  landmark_copyright: { type: 'copyright-page', text: 'Copyright page' },
  landmark_toc: { type: 'toc', text: 'Table of contents' },
}.freeze

Instance Attribute Summary

Attributes inherited from Generator

#compilation_context

Instance Method Summary collapse

Methods inherited from Generator

#initialize

Constructor Details

This class inherits a constructor from Epuber::Compiler::Generator

Instance Method Details

#generate_navNokogiri::XML::Document

Generates XML for toc document, the structure differs depend on epub_version

Use method #to_s to generate nice string from XML document

Returns:

  • (Nokogiri::XML::Document)


40
41
42
43
44
45
46
47
48
# File 'lib/epuber/compiler/nav_generator.rb', line 40

def generate_nav
  generate_xml do
    if @target.epub_version >= 3
      generate_xhtml_content
    else
      generate_ncx_content
    end
  end
end