Class: Rpub::Commands::Preview
- Includes:
- Rpub::CompilationHelpers
- Defined in:
- lib/rpub/commands/preview.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(*args) ⇒ Preview
constructor
A new instance of Preview.
- #invoke ⇒ Object
Methods included from Rpub::CompilationHelpers
#config, #create_book, #layout, #markdown_files, #styles
Methods inherited from Base
Methods included from SubclassTracker
#each, #identifier, #inherited, #matching
Constructor Details
#initialize(*args) ⇒ Preview
Returns a new instance of Preview.
8 9 10 11 |
# File 'lib/rpub/commands/preview.rb', line 8 def initialize(*args) super @filename = 'preview.html' end |
Instance Method Details
#invoke ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/rpub/commands/preview.rb', line 13 def invoke super return unless markdown_files.any? concatenation = markdown_files.join("\n") File.open(@filename, 'w') do |f| f.write move_styles_inline(Kramdown::Document.new(concatenation, KRAMDOWN_OPTIONS.merge(:template => layout)).to_html) end end |