From ecc78dbafcfa2917289506535598db85f063114c Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 30 Sep 2024 15:21:28 +0200 Subject: [PATCH 1/4] floatreftarger, pptx- Correctly handle unsupported floatref `quarto.utils.match` returns false not nil --- src/resources/filters/customnodes/floatreftarget.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/resources/filters/customnodes/floatreftarget.lua b/src/resources/filters/customnodes/floatreftarget.lua index c722ccf620c..855b2ea9cad 100644 --- a/src/resources/filters/customnodes/floatreftarget.lua +++ b/src/resources/filters/customnodes/floatreftarget.lua @@ -1082,13 +1082,14 @@ end, function(float) return pandoc.Null() end local im = quarto.utils.match("Plain/[1]/Image")(float.content) - if im == nil then + if im then + decorate_caption_with_crossref(float) + im.caption = quarto.utils.as_inlines(float.caption_long) + return pandoc.Para({im}) + else warn("PowerPoint output for FloatRefTargets require a single image as content") return pandoc.Null() end - decorate_caption_with_crossref(float) - im.caption = quarto.utils.as_inlines(float.caption_long) - return pandoc.Para({im}) end) global_table_guid_id = 0 \ No newline at end of file From 74cf6a27df9f1ab1cf3da35f8ce023828fe557de Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 30 Sep 2024 15:43:42 +0200 Subject: [PATCH 2/4] floatreftarget, pptx - support Div floatref containing 1 image in Powerpoint --- .../filters/customnodes/floatreftarget.lua | 14 +++++----- tests/docs/smoke-all/2024/09/30/10931.qmd | 27 +++++++++++++++++++ 2 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 tests/docs/smoke-all/2024/09/30/10931.qmd diff --git a/src/resources/filters/customnodes/floatreftarget.lua b/src/resources/filters/customnodes/floatreftarget.lua index 855b2ea9cad..67390d6555d 100644 --- a/src/resources/filters/customnodes/floatreftarget.lua +++ b/src/resources/filters/customnodes/floatreftarget.lua @@ -1081,15 +1081,17 @@ 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 then - decorate_caption_with_crossref(float) - im.caption = quarto.utils.as_inlines(float.caption_long) - return pandoc.Para({im}) - else + 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}) end) global_table_guid_id = 0 \ No newline at end of file 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 + +::: From d2891da33df8bf5a9f7fc61b7e9271d96f663e8b Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 30 Sep 2024 15:44:06 +0200 Subject: [PATCH 3/4] tests, pptx - Add XPATH check for preview inline image crossref --- tests/docs/smoke-all/2024/06/24/8667.qmd | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 From 0f43002f3c4b155059f6a34558d1d5a193a8b2b6 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 30 Sep 2024 16:03:54 +0200 Subject: [PATCH 4/4] floatreftarget, pptx - Add a test for unsupported floatref leading to warning and empty content --- tests/docs/smoke-all/2024/09/30/10931-2.qmd | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/docs/smoke-all/2024/09/30/10931-2.qmd 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 + +:::