blob: 3edaaafa0313ddecf1ae298db84329d3ca887204 (
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
45
|
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
load 'pandoc.rb'
require 'erb'
require 'date'
license_urls = {
"CC BY-SA-3.0" => 'https://creativecommons.org/licenses/by-sa/3.0/',
'WTFPL-2' => "http://www.wtfpl.net/txt/copying/",
}
author_urls = {
"Luke Shumaker" => "mailto:lukeshu@sbcglobal.net",
}
template = 'template.erb'
infile = ARGV.first
Pandoc::prog='pandoc'
input = File.read(infile)
doc = Pandoc::load('markdown-markdown_in_html_blocks', input)
@title = doc['title'] || input.split("\n",2).first
@author = doc['author'] || "Luke Shumaker"
@date = Date.parse(doc['date']) unless doc['date'].nil?
@license = doc['license'] || "CC BY-SA-3.0"
unless license_urls[@license].nil?
@license="<a href=\"#{license_urls[@license]}\">#{@license}</a>"
end
unless author_urls[@author].nil?
@author="<a href=\"#{author_urls[@author]}\">#{@author}</a>"
end
@breadcrumbs = '<a href="/">Luke Shumaker</a> » '
if (infile =~ /.*\/index(\..*)?/)
@breadcrumbs += "blog"
else
@breadcrumbs += '<a href=/blog>blog</a> » ' + infile.sub(/\..*$/,'').sub(/^.*\//,'')
end
@content = doc.to('html5')
erb = ERB.new(File.read(template));
erb.filename = template
erb.run()
|