-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfilter_example.lua
More file actions
51 lines (48 loc) · 1.7 KB
/
Copy pathfilter_example.lua
File metadata and controls
51 lines (48 loc) · 1.7 KB
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
--[[ this is a pandoc filter which takes items inside of an examples
block like this:
::: examples
a
b
c
:::
And then fills in the actual div for each example.
]]
function Div(elem)
if elem.attr.classes[1] == "examples" then
local content2 = {}
local i = 1
for _, block in pairs(elem.content[1]["content"]) do
local text = block["text"]
if text ~= nil then
path = text:gsub(":.*", "")
option = text:gsub(".*:", "")
if text:match("^demos/") then
name = path:gsub(".*/", "")
link = "demos/" .. name .. "/" .. name
source = "demos/" .. name
else
name = path
link = "examples/" .. name
source = "examples/" .. name .. ".c"
end
if option == "no_try" then
try_link = pandoc.Str("")
else
try_link = pandoc.Link("try", "https://allegro5.org/examples/" .. link .. ".html", "Try", {class = "try"})
end
content2[i] = pandoc.Div(
pandoc.Para {
pandoc.Str(name),
try_link,
pandoc.Link("source", "https://github.com/liballeg/allegro5/tree/master/" .. source, "Source", {class = "try"}),
pandoc.LineBreak(),
pandoc.Image(name .. " screenshot", "screenshots/" .. name .. ".png")
},
{class = "example"})
i = i + 1
end
end
elem.content = content2
return elem
end
end