Skip to content

revealjs - lift Figure.fragment to surrounding div #12605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/resources/filters/layout/pandoc3_figure.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,25 @@ function render_pandoc3_figure()
return {
traverse = "topdown",
Figure = function(figure)
local has_fragment = false
figure.content = _quarto.ast.walk(figure.content, {
Image = function(img)
if img.classes:includes("fragment") then
has_fragment = true
img.classes = img.classes:filter(function(c) return c ~= "fragment" end)
return img
end
end
})

local result = html_handle_linked_image(figure)
if result ~= nil then
return result
if result == nil then
result = html_handle_image(figure)
end
if has_fragment then
result = pandoc.Div(result, pandoc.Attr("", {"fragment"}, {}))
end
return html_handle_image(figure)
return result
end
}
elseif _quarto.format.isLatexOutput() then
Expand Down
13 changes: 13 additions & 0 deletions tests/docs/smoke-all/2025/04/23/issue-12598.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
format: revealjs
_quarto:
tests:
revealjs:
ensureHtmlElements:
- ["div.fragment"]
- []
---

## Slide title

![caption](image.jpg){.fragment}
Loading