Class: Bookingit::Book

Inherits:
Object
  • Object
show all
Defined in:
lib/bookingit/book.rb

Instance Method Summary collapse

Constructor Details

#initialize(config, output_dir = nil) ⇒ Book



3
4
5
6
# File 'lib/bookingit/book.rb', line 3

def initialize(config,output_dir=nil)
  @config = config
  @output_dir = output_dir || 'book'
end

Instance Method Details

#render_html!Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bookingit/book.rb', line 8

def render_html!
  mkdir @output_dir unless Dir.exists?(@output_dir)

  rendering_config = @config.rendering_config
  rendering_config[:cache] = File.expand_path('cache') if @config.cache
  renderer = Bookingit::Renderer.new(@config)
  @redcarpet = Redcarpet::Markdown.new(renderer, no_intra_emphasis: true,
                                                            tables: true,
                                                fenced_code_blocks: true,
                                                          autolink: true,
                                                     strikethrough: true,
                                                       superscript: true)

  toc = parse_chapters_to_get_headers(renderer)
  generate_chapters(renderer)
  generate_toc(toc,renderer.stylesheets,renderer.theme)
  copy_assets(renderer)
end