Class: Kitabu::Exporter::HTML
Class Attribute Summary collapse
-
.footnote_index ⇒ Object
The footnote index control.
Attributes inherited from Base
Instance Method Summary collapse
-
#content ⇒ Object
Return all chapters wrapped in a
div.chapter
tag. -
#export ⇒ Object
Parse all files and save the parsed content to
output/book_name.html
. - #reset_footnote_index! ⇒ Object
Methods inherited from Base
#config, #copy_directory, export, #handle_error, #initialize, #name, #render_template, #source_list, #spawn_command, #ui
Constructor Details
This class inherits a constructor from Kitabu::Exporter::Base
Class Attribute Details
.footnote_index ⇒ Object
The footnote index control. We have to manipulate footnotes because each chapter starts from 1, so we have duplicated references.
10 11 12 |
# File 'lib/kitabu/exporter/html.rb', line 10 def footnote_index @footnote_index end |
Instance Method Details
#content ⇒ Object
Return all chapters wrapped in a div.chapter
tag.
38 39 40 41 42 43 44 45 46 |
# File 'lib/kitabu/exporter/html.rb', line 38 def content buffer = [].tap do |content| source_list.each_chapter do |files| content << %[<div class="chapter">#{render_chapter(files)}</div>] end end buffer.join end |
#export ⇒ Object
Parse all files and save the parsed content to output/book_name.html
.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/kitabu/exporter/html.rb', line 16 def export super copy_images! copy_fonts! export_stylesheets! File.open(root_dir.join("output/#{name}.html"), "w") do |file| file << parse_layout(content) end true rescue StandardError => error handle_error(error) false end |
#reset_footnote_index! ⇒ Object
32 33 34 |
# File 'lib/kitabu/exporter/html.rb', line 32 def reset_footnote_index! self.class.footnote_index = 1 end |