Top Level Namespace
Instance Method Summary collapse
Instance Method Details
#content_of(filename) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/markdown_presenter.rb', line 14 def content_of filename if filename.end_with? ".md" Kramdown::Document.new(File.read(filename)).to_html elsif filename.end_with? ".html" require 'nokogiri' doc = Nokogiri::HTML(File.read(filename)) doc.search('body')[0].inner_html else $stderr.puts "Format not supported: #{File.extname(filename)}" exit 1 end end |
#present(title, content) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/markdown_presenter.rb', line 6 def present title, content template = File.read(File.join(File.dirname(__FILE__), "../presenter.html.haml")) haml_engine = Haml::Engine.new(template) haml_engine.render(Object.new, {slides: content.split(/(?=<h1)/).reject {|s| s.chomp.empty?}, title: title}) do |filename| File.read File.join(File.dirname(__FILE__), "../", filename) end end |
#process(filename) ⇒ Object
29 30 31 |
# File 'lib/markdown_presenter.rb', line 29 def process filename puts present(filename, content_of(filename)) end |