-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfilter.lua
56 lines (52 loc) · 1.29 KB
/
filter.lua
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
46
47
48
49
50
51
52
53
54
55
56
function BulletList(elem)
local l = elem.content[1][2]
if l and l.tag == 'BulletList' and l.content[1][1].content[1].text == ':' then
return pandoc.DefinitionList(elem.content:map(
function (item)
item[1] = item[1]:walk {
Code = function(elem)
return pandoc.Strong(elem.text)
end
}.content
item[2] = item[2].content:map(
function (blocks)
-- remove : and space
blocks[1].content:remove(1)
blocks[1].content:remove(1)
return blocks
end
)
return item
end
))
end
return elem
end
function Header(elem)
if elem.level == 1 then
return elem:walk {
Str = function(elem)
return string.upper(elem.text)
end
}
end
return elem
end
function RawBlock(raw)
return
raw.format:match 'html' and pandoc.read(raw.text, 'html').blocks or
raw
end
function RawInline(raw)
return
raw.text == "<sup>" and "^" or
raw.text == "<sub>" and "_" or
raw
end
function Meta(meta)
local format = "(%d+)-(%d+)-(%d+)"
local y, m, d = pandoc.utils.stringify(meta.date):match(format)
local date = os.time({ year = y, month = m, day = d })
meta.date = pandoc.Str(os.date("%B %d, %Y", date):gsub(" 0", " "))
return meta
end