From 859f2b97f36efe3bc98c94829de178907892d771 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Mon, 24 Mar 2025 09:42:30 -0400 Subject: [PATCH 1/3] lua,decoratedcodeblock - force [H] when inside a layout (#12344) --- .../filters/customnodes/decoratedcodeblock.lua | 9 ++++----- .../filters/customnodes/panellayout.lua | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/resources/filters/customnodes/decoratedcodeblock.lua b/src/resources/filters/customnodes/decoratedcodeblock.lua index e996b0a618..5aeefb0a55 100644 --- a/src/resources/filters/customnodes/decoratedcodeblock.lua +++ b/src/resources/filters/customnodes/decoratedcodeblock.lua @@ -95,11 +95,10 @@ _quarto.ast.add_renderer("DecoratedCodeBlock", -- further, otherwise generate the listing div and return it if not param("listings", false) then local listingDiv = pandoc.Div({}) - local position = "" - if _quarto.format.isBeamerOutput() then - -- Adjust default float positionment for beamer (#5536) - position = "[H]" - end + -- Adjust default float positionment for beamer (#5536) + -- Adjust default float positionment for code blocks that request it (#12344) + local needs_hold = _quarto.format.isBeamerOutput() or node.hold + local position = needs_hold and "[H]" or "" listingDiv.content:insert(pandoc.RawBlock("latex", "\\begin{codelisting}" .. position)) local captionContent = node.caption diff --git a/src/resources/filters/customnodes/panellayout.lua b/src/resources/filters/customnodes/panellayout.lua index 6ba5cadfbd..0a48422a06 100644 --- a/src/resources/filters/customnodes/panellayout.lua +++ b/src/resources/filters/customnodes/panellayout.lua @@ -89,8 +89,23 @@ _quarto.ast.add_handler({ -- construct a minimal rows-cells div scaffolding -- so contents are properly stored in the cells slot + -- #12344: if there are decoratedcodeblocks inside the layout, + -- we need to ask them to render themselves as [H] or we'll get outer par mode errors. + local layout = tbl.layout + if quarto.format.isLatexOutput() then + layout = pandoc.List(tbl.layout):map(function(lst) + return pandoc.List(lst):map(function(cell) + return _quarto.ast.walk(cell, { + DecoratedCodeBlock = function(decorated) + decorated.hold = true + return decorated + end + }) + end) + end) + end local rows_div = pandoc.Div({}) - for i, row in ipairs(tbl.layout) do + for i, row in ipairs(layout) do local row_div = pandoc.Div(row) if tbl.is_float_reftarget then row_div = _quarto.ast.walk(row_div, { From eb4c56254cb3b93700eac2e3b3541458139eb2d5 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Mon, 24 Mar 2025 13:35:44 -0400 Subject: [PATCH 2/3] regression test --- .../docs/smoke-all/2025/03/21/issue-12344.qmd | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/docs/smoke-all/2025/03/21/issue-12344.qmd diff --git a/tests/docs/smoke-all/2025/03/21/issue-12344.qmd b/tests/docs/smoke-all/2025/03/21/issue-12344.qmd new file mode 100644 index 0000000000..6af00bd780 --- /dev/null +++ b/tests/docs/smoke-all/2025/03/21/issue-12344.qmd @@ -0,0 +1,37 @@ +--- +format: + pdf: + keep-tex: true +--- + +::: {layout-ncol="2" .column-page-right} +``` {.markdown filename="01-import.qmd"} +--- +title: Data Import and Cleaning +author: Soraya Drake +format: + html: + toc: true + code-fold: true +--- + +## Import + +... +``` + +``` {.markdown filename="02-visualization.qmd"} +--- +title: Exploratory Visualization +author: Soraya Drake +format: + html: + toc: true + code-fold: true +--- + +## Distributions + +... +``` +::: \ No newline at end of file From e38db3f63e917d8b1a8b48c22ae34c2fbb94571e Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Mon, 24 Mar 2025 13:36:35 -0400 Subject: [PATCH 3/3] changelog --- news/changelog-1.7.md | 1 + 1 file changed, 1 insertion(+) diff --git a/news/changelog-1.7.md b/news/changelog-1.7.md index 27efc6443b..3dc8ef66c9 100644 --- a/news/changelog-1.7.md +++ b/news/changelog-1.7.md @@ -52,6 +52,7 @@ All changes included in 1.7: - ([#11835](https://github.com/quarto-dev/quarto-cli/issues/11835)): Take markdown structure into account when detecting minimum heading level. - ([#11903](https://github.com/quarto-dev/quarto-cli/issues/11903)): `crossref` configuration like `fig-title` or `tbl-title` now correctly supports multi word values, e.g. `fig-title: 'Supplementary Figure'`. - ([#11878](https://github.com/quarto-dev/quarto-cli/issues/11878), [#12085](https://github.com/quarto-dev/quarto-cli/issues/12085)): Correctly fixup raw LaTeX table having an unexpected table env with options (e.g `\begin{table}[!ht]`) to be handled as crossref table. +- ([#12344](https://github.com/quarto-dev/quarto-cli/issues/12344)): Ensure decorated code blocks do not float when inside layout elements. ### Quarto PDF engine