diff --git a/src/resources/filters/customnodes/floatreftarget.lua b/src/resources/filters/customnodes/floatreftarget.lua index c722ccf620c..67390d6555d 100644 --- a/src/resources/filters/customnodes/floatreftarget.lua +++ b/src/resources/filters/customnodes/floatreftarget.lua @@ -1081,11 +1081,14 @@ end, function(float) warn("Can't render float without content") return pandoc.Null() end - local im = quarto.utils.match("Plain/[1]/Image")(float.content) - if im == nil then + local im_plain = quarto.utils.match("Plain/[1]/Image")(float.content) + local im_para = quarto.utils.match("Para/[1]/Image")(float.content) + if not im_plain and not im_para then warn("PowerPoint output for FloatRefTargets require a single image as content") return pandoc.Null() end + + local im = im_plain or im_para decorate_caption_with_crossref(float) im.caption = quarto.utils.as_inlines(float.caption_long) return pandoc.Para({im}) diff --git a/tests/docs/smoke-all/2024/06/24/8667.qmd b/tests/docs/smoke-all/2024/06/24/8667.qmd index 4c2ccbca2a2..d65a17e447e 100644 --- a/tests/docs/smoke-all/2024/06/24/8667.qmd +++ b/tests/docs/smoke-all/2024/06/24/8667.qmd @@ -1,5 +1,16 @@ --- format: pptx +_quarto: + tests: + pptx: + ensurePptxXpath: + - + - 1 + - + - '//p:pic' + - '//p:cNvPr[contains(@descr, "existing-image.jpg")]' + - '//a:t[contains(text(),"FigureĀ 1")]' + - [] --- ## Slide Title diff --git a/tests/docs/smoke-all/2024/09/30/10931-2.qmd b/tests/docs/smoke-all/2024/09/30/10931-2.qmd new file mode 100644 index 00000000000..bc787c75e5f --- /dev/null +++ b/tests/docs/smoke-all/2024/09/30/10931-2.qmd @@ -0,0 +1,28 @@ +--- +title: Unsupported floatref gives Lua warning and empty content +format: pptx +_quarto: + tests: + pptx: + printsMessage: + - INFO + - 'WARNING.*FloatRefTargets require' + ensurePptxXpath: + - + - 2 + - [] + - ['//a:tbl'] + +--- + +## slide with fig div + +::: {#fig-table} + +| A | B | +|---|---| +| C | D | + +A table treated like a figure + +::: diff --git a/tests/docs/smoke-all/2024/09/30/10931.qmd b/tests/docs/smoke-all/2024/09/30/10931.qmd new file mode 100644 index 00000000000..274f9526dae --- /dev/null +++ b/tests/docs/smoke-all/2024/09/30/10931.qmd @@ -0,0 +1,27 @@ +--- +title: Testing floatref div in pptx +format: pptx +_quarto: + tests: + pptx: + ensurePptxXpath: + - + - 2 + - + - '//p:pic' + - '//a:t[contains(text(),"FigureĀ 1")]' + - [] +--- + +## slide with fig div + +::: {#fig-graph1} + +```{r} +#| echo: false +plot(1:10) +``` + +A graph + +:::