21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/markd/markd.rb', line 21
def publish(filename, out_dir_path, out_filename)
ext = File.extname(filename)
engine = create_engine ext
src = File.read filename
@html = engine.to_html(src)
doc = Nokogiri::HTML::Document.parse @html
@title = doc.css("h1:first").text
erb_src = File.read "#{APP_ROOT}/template/template.html.erb"
eruby = Erubis::Eruby.new(erb_src)
html = eruby.result(binding)
FileUtils.mkdir_p out_dir_path
File.open("#{out_dir_path}/#{out_filename}", "w") { |f| f.puts html }
dirs = ::RESOURCES.map { |d| "#{APP_ROOT}/template/#{d}"}
FileUtils.cp_r(dirs, out_dir_path)
end
|