-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlabs.lua
More file actions
32 lines (27 loc) · 833 Bytes
/
Copy pathlabs.lua
File metadata and controls
32 lines (27 loc) · 833 Bytes
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
function Image(paragraph)
local to_string = pandoc.utils.stringify
if paragraph.classes:find("labs", 1) then
local file = io.open("all_collections/_groups/" .. paragraph.src, "r")
local content = file:read("*a")
file:close()
local doc = pandoc.read(content)
-- Metadata
local meta = doc.meta
local link = to_string(meta.link)
local title = to_string(meta.title)
-- process content after metadata
local body = doc.blocks
local md = "#### " .. title .. "\n\n" .. link .. "\n\n"
-- process content blocks
for _, block in ipairs(body) do
if block.t == "Para" then
md = md .. to_string(block)
elseif block.t == "BulletList" then
for _, item in ipairs(block.content) do
md = md .. "- " .. to_string(item) .. "\n\n"
end
end
end
return pandoc.RawInline("markdown", md)
end
end