diff options
Diffstat (limited to 'filters')
-rw-r--r-- | filters/macros.lua | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/filters/macros.lua b/filters/macros.lua index 9e9d954..dc04cfd 100644 --- a/filters/macros.lua +++ b/filters/macros.lua | |||
@@ -1,7 +1,39 @@ | |||
1 | function note(el) | ||
2 | el.classes = pandoc.List() | ||
3 | el.classes:insert("c-note") | ||
4 | return el | ||
5 | end | ||
6 | |||
7 | function gallery(el) | ||
8 | el.classes = pandoc.List() | ||
9 | el.classes:insert("c-gallery") | ||
10 | |||
11 | local cur = pandoc.Div(pandoc.List(), { class = "c-gallery__current" }) | ||
12 | local imageList = pandoc.Div(pandoc.List(), { class = "c-gallery__items" }) | ||
13 | |||
14 | pandoc.walk_block(el, { | ||
15 | Image = function(iel) | ||
16 | iel.classes = pandoc.List() | ||
17 | iel.classes:insert("c-gallery__img") | ||
18 | |||
19 | local lel = pandoc.Link(iel, iel.src) | ||
20 | lel.classes = pandoc.List() | ||
21 | lel.classes:insert("c-gallery__item") | ||
22 | |||
23 | imageList.content:insert(lel) | ||
24 | end, | ||
25 | }) | ||
26 | |||
27 | el.content = { cur, imageList } | ||
28 | |||
29 | return el | ||
30 | end | ||
31 | |||
1 | function Div(el) | 32 | function Div(el) |
2 | if el.classes:includes("note") then | 33 | if el.classes:includes("note") then |
3 | el.classes = pandoc.List() | 34 | el = note(el) |
4 | el.classes:insert("c-note") | 35 | elseif el.classes:includes("gallery") then |
36 | el = gallery(el) | ||
5 | end | 37 | end |
6 | 38 | ||
7 | return el | 39 | return el |