Skip to content

Commit 1428f74

Browse files
committed
revealjs - hoist Figure.fragment to surrounding div
1 parent a1915e4 commit 1428f74

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/resources/filters/layout/pandoc3_figure.lua

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,25 @@ function render_pandoc3_figure()
6868
return {
6969
traverse = "topdown",
7070
Figure = function(figure)
71+
local has_fragment = false
72+
figure.content = _quarto.ast.walk(figure.content, {
73+
Image = function(img)
74+
if img.classes:includes("fragment") then
75+
has_fragment = true
76+
img.classes = img.classes:filter(function(c) return c ~= "fragment" end)
77+
return img
78+
end
79+
end
80+
})
81+
7182
local result = html_handle_linked_image(figure)
72-
if result ~= nil then
73-
return result
83+
if result == nil then
84+
result = html_handle_image(figure)
85+
end
86+
if has_fragment then
87+
result = pandoc.Div(result, pandoc.Attr("", {"fragment"}, {}))
7488
end
75-
return html_handle_image(figure)
89+
return result
7690
end
7791
}
7892
elseif _quarto.format.isLatexOutput() then

0 commit comments

Comments
 (0)