blob: 06c183f1d06f2662633e5c45d998a1183924cb69 (
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
|
#!/usr/bin/lua
markdown = require('discount')
yaml = require('yaml')
function read_meta(file)
local f = assert(io.open(file))
local header, body = f:read("*a"):match("^(%-%-%-.-%-%-%-)(.*)$")
f:close()
local m = yaml.load(header)
m.pagename = file:gsub("%.md$", ""):gsub("^.*/", "")
m.md = file
m.html = m.pagename..".html"
return m
end
function print_md(meta)
io.write(("|%s|%s|\n"):format(meta.date, meta.title))
end
a = {}
j=1
for i=1, #arg do
local m = read_meta(arg[i])
if m.date then
a[j] = m
j = j + 1
end
end
table.sort(a, function(a,b)
return a.date < b.date
end)
io.write(yaml.dump(a))
|