diff --git a/src/resources/filters/layout/pandoc3_figure.lua b/src/resources/filters/layout/pandoc3_figure.lua index ad4924e93cc..89bba648c6a 100644 --- a/src/resources/filters/layout/pandoc3_figure.lua +++ b/src/resources/filters/layout/pandoc3_figure.lua @@ -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 diff --git a/tests/docs/smoke-all/2025/04/23/issue-12598.qmd b/tests/docs/smoke-all/2025/04/23/issue-12598.qmd new file mode 100644 index 00000000000..2e05526ae7d --- /dev/null +++ b/tests/docs/smoke-all/2025/04/23/issue-12598.qmd @@ -0,0 +1,13 @@ +--- +format: revealjs +_quarto: + tests: + revealjs: + ensureHtmlElements: + - ["div.fragment"] + - [] +--- + +## Slide title + +![caption](image.jpg){.fragment}