diff --git a/news/changelog-1.6.md b/news/changelog-1.6.md index b4c24baa57..2d4b8a89d6 100644 --- a/news/changelog-1.6.md +++ b/news/changelog-1.6.md @@ -11,6 +11,7 @@ All changes included in 1.6: ## Lua Filters and extensions +- ([#8179](https://github.com/quarto-dev/quarto-cli/issues/8179)): When merging code cells for complex layouts, do not merge cells with different languages. - ([#10004](https://github.com/quarto-dev/quarto-cli/issues/10004)): Resolve callout titles, theorem names, and `code-summary` content through `quarto_ast_pipeline()` and `process_shortcodes()`. - ([#10196](https://github.com/quarto-dev/quarto-cli/issues/10196)): Protect against nil values in `float.caption_long`. - ([#10328](https://github.com/quarto-dev/quarto-cli/issues/10328)): Interpret subcells as subfloats when subcap count matches subcell count. diff --git a/src/resources/filters/layout/layout.lua b/src/resources/filters/layout/layout.lua index 8d08bfe0b5..dd49f3a4bb 100644 --- a/src/resources/filters/layout/layout.lua +++ b/src/resources/filters/layout/layout.lua @@ -86,8 +86,16 @@ function partition_cells(float) end local function handle_preamble_codeblock(block) - if block.t == "CodeBlock" and #preamble > 0 and preamble[#preamble].t == "CodeBlock" then - preamble[#preamble].text = preamble[#preamble].text .. "\n" .. block.text + if #preamble == 0 then + preamble:insert(block) + return + end + local last = preamble[#preamble] + if block.t == "CodeBlock" and + last.t == "CodeBlock" and + -- https://pandoc.org/lua-filters.html#pandoc.list:__eq + last.classes == block.classes then + last.text = last.text .. "\n" .. block.text else preamble:insert(block) end diff --git a/tests/docs/smoke-all/2024/10/08/issue-8179.qmd b/tests/docs/smoke-all/2024/10/08/issue-8179.qmd new file mode 100644 index 0000000000..9721046e2a --- /dev/null +++ b/tests/docs/smoke-all/2024/10/08/issue-8179.qmd @@ -0,0 +1,76 @@ +--- +title: "Block layout" +format: html +engine: knitr +keep-md: true +_quarto: + tests: + html: + ensureHtmlElements: + - + - "pre.r" + - "pre.python" + - [] +--- + + + + +# Code chunk block layout + +:::: {layout="[48,-4,48]"} + +::: {} + +### R + + + +::: {.cell} + +```{.r .cell-code} +sqrt(2) +``` + +::: {.cell-output .cell-output-stdout} + +``` +[1] 1.414214 +``` + + +::: +::: + + + +::: + +::: {} + +### Python + + + +::: {.cell} + +```{.python .cell-code} +import math +math.sqrt(2) +``` + +::: {.cell-output .cell-output-stdout} + +``` +1.4142135623730951 +``` + + +::: +::: + + + +::: + +:::: \ No newline at end of file