blob: a4ce6a19101fdd4cf67ee2b003524a15e9bc50c5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'erb'
require 'date'
load 'pandoc.rb'
Pandoc::prog='pandoc'
def erb(file, context=nil)
_erb = ERB.new(File.read(file))
_erb.filename = file
if context.nil?
return _erb.result()
else
return _erb.result(context)
end
end
template = 'lib/template.erb'
infile = ARGV.first
input = File.read(infile)
@title = 'TITLE GOES HERE'
case File.extname(infile)
when '.md'
doc = Pandoc::load('markdown', input)
@title = doc['title'] || input.split("\n",2).first
@body = doc.to('html5')
when '.org'
doc = Pandoc::load('org', input)
@title = doc['title'] || input.split("\n",2).first
@body = doc.to('html5')
when '.erb'
erb_body = ERB.new(input)
erb_body.filename = infile
@body = erb_body.result()
else
abort
end
erb = ERB.new(File.read(template));
erb.filename = template
erb.run()
|