function note(el) el.classes = pandoc.List() el.classes:insert("c-note") return el end function gallery(el) el.classes = pandoc.List() el.classes:insert("c-gallery") local cur = pandoc.Div(pandoc.List(), { class = "c-gallery__current" }) local imageList = pandoc.Div(pandoc.List(), { class = "c-gallery__items" }) pandoc.walk_block(el, { Image = function(iel) iel.classes = pandoc.List() iel.classes:insert("c-gallery__img") local lel = pandoc.Link(iel, iel.src) lel.classes = pandoc.List() lel.classes:insert("c-gallery__item") imageList.content:insert(lel) end, }) el.content = { cur, imageList } return el end function Div(el) if el.classes:includes("note") then el = note(el) elseif el.classes:includes("gallery") then el = gallery(el) end return el end