diff options
author | Volpeon <git@volpeon.ink> | 2021-12-29 15:51:49 +0100 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2021-12-29 15:51:49 +0100 |
commit | 312015e8f74ca1738e7160e5d66cad9dcb07c6fd (patch) | |
tree | 0fa7922b190e22bfd82627d4b65552a981cd0340 /filters | |
parent | Support for more complex layouts (diff) | |
download | volpeon.ink-312015e8f74ca1738e7160e5d66cad9dcb07c6fd.tar.gz volpeon.ink-312015e8f74ca1738e7160e5d66cad9dcb07c6fd.tar.bz2 volpeon.ink-312015e8f74ca1738e7160e5d66cad9dcb07c6fd.zip |
Initial gallery macro
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 |