summaryrefslogtreecommitdiffstats
path: root/filters
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2021-12-29 19:16:35 +0100
committerVolpeon <git@volpeon.ink>2021-12-29 19:16:35 +0100
commitbcee1a0f4615d90bd714adf8bea79baffe006579 (patch)
tree2cd6b6cd74a47420a4b4a5b0eedb5ae185d91a05 /filters
parentInitial gallery macro (diff)
downloadvolpeon.ink-bcee1a0f4615d90bd714adf8bea79baffe006579.tar.gz
volpeon.ink-bcee1a0f4615d90bd714adf8bea79baffe006579.tar.bz2
volpeon.ink-bcee1a0f4615d90bd714adf8bea79baffe006579.zip
Added lightbox
Diffstat (limited to 'filters')
-rw-r--r--filters/macros.lua31
1 files changed, 8 insertions, 23 deletions
diff --git a/filters/macros.lua b/filters/macros.lua
index dc04cfd..2864bef 100644
--- a/filters/macros.lua
+++ b/filters/macros.lua
@@ -4,36 +4,21 @@ function note(el)
4 return el 4 return el
5end 5end
6 6
7function gallery(el) 7function figure(el)
8 el.classes = pandoc.List() 8 local images = 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 9
19 local lel = pandoc.Link(iel, iel.src) 10 pandoc.walk_block(el, { Image = function(iel) images:insert(iel) end })
20 lel.classes = pandoc.List()
21 lel.classes:insert("c-gallery__item")
22 11
23 imageList.content:insert(lel) 12 return pandoc.RawBlock("html",
24 end, 13 "<figure><a href=\"" .. images[1].src .. "\"><img src=\"" .. images[1].src .. "\" title=\"" ..
25 }) 14 images[1].title .. "\" /></a></figure>")
26
27 el.content = { cur, imageList }
28
29 return el
30end 15end
31 16
32function Div(el) 17function Div(el)
33 if el.classes:includes("note") then 18 if el.classes:includes("note") then
34 el = note(el) 19 el = note(el)
35 elseif el.classes:includes("gallery") then 20 elseif el.classes:includes("figure") then
36 el = gallery(el) 21 el = figure(el)
37 end 22 end
38 23
39 return el 24 return el