blob: 4e6f887427c3152bf2a4c52de7e84651496c4ef5 (
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
|
#!/usr/bin/env ruby
require 'rdiscount'
require 'erb'
license_urls = {
"CC BY-SA-3.0" => 'https://creativecommons.org/licenses/by-sa/3.0/',
'WTFPL-2' => "http://www.wtfpl.net/txt/copying/",
}
template = 'template.erb'
input = ARGV.first
lines = File.read(input).split("\n")
markdown = ''
tags = {}
for line in lines do
if (line =~ /^:/)
(key, val) = line.sub(/^:/, '').split(/\s+/, 2)
tags[key] = val
else
markdown += "\n"+line
end
end
@title = tags['title'] || lines.first
@copyright = tags['copyright'] || "Luke Shumaker"
@license = tags['license'] || "CC BY-SA-3.0"
unless license_urls[@license].nil?
@license="<a href=\"#{license_urls[@license]}\">#{@license}</a>"
end
@content = RDiscount.new(markdown).to_html
erb = ERB.new(File.read(template));
erb.filename = template
erb.run()
|