diff --git a/news/changelog-1.9.md b/news/changelog-1.9.md index 14f341aa6d9..9cbd373b0cc 100644 --- a/news/changelog-1.9.md +++ b/news/changelog-1.9.md @@ -32,6 +32,7 @@ All changes included in 1.9: - ([#11929](https://github.com/quarto-dev/quarto-cli/issues/11929)): Import all `brand.typography.fonts` in CSS, whether or not fonts are referenced by typography elements. - ([#13413](https://github.com/quarto-dev/quarto-cli/issues/13413)): Fix uncentered play button in `video` shortcodes from cross-reference divs. (author: @bruvellu) - ([#13508](https://github.com/quarto-dev/quarto-cli/issues/13508)): Add `aria-label` support to `video` shortcode for improved accessibility. +- ([#13825](https://github.com/quarto-dev/quarto-cli/issues/13825)): Fix `column: margin` not working with `renderings: [light, dark]` option. Column classes are now preserved when applying theme classes to cell outputs. ### `typst` diff --git a/src/resources/filters/quarto-post/cell-renderings.lua b/src/resources/filters/quarto-post/cell-renderings.lua index e7cd4534706..5de0f313e14 100644 --- a/src/resources/filters/quarto-post/cell-renderings.lua +++ b/src/resources/filters/quarto-post/cell-renderings.lua @@ -52,8 +52,11 @@ function choose_cell_renderings() blocks:insert(darkDiv) end elseif quarto.format.isHtmlOutput() and lightDiv and darkDiv then - blocks:insert(pandoc.Div(lightDiv.content, pandoc.Attr("", {'light-content'}, {}))) - blocks:insert(pandoc.Div(darkDiv.content, pandoc.Attr("", {'dark-content'}, {}))) + -- Preserve existing classes (e.g., column-margin, cell-output-display) and add theme class + lightDiv.classes:insert('light-content') + darkDiv.classes:insert('dark-content') + blocks:insert(lightDiv) + blocks:insert(darkDiv) else blocks:insert(lightDiv or darkDiv) end diff --git a/tests/docs/smoke-all/dark-mode/renderings-column-margin.qmd b/tests/docs/smoke-all/dark-mode/renderings-column-margin.qmd new file mode 100644 index 00000000000..ea6d3cc0ae7 --- /dev/null +++ b/tests/docs/smoke-all/dark-mode/renderings-column-margin.qmd @@ -0,0 +1,27 @@ +--- +title: "renderings with column-margin" +format: + html: + theme: + light: flatly + dark: darkly +_quarto: + tests: + html: + ensureHtmlElements: + - + - 'div.cell div.column-margin div.cell-output-display.light-content' + - 'div.cell div.column-margin div.cell-output-display.dark-content' + - [] +--- + +This tests that `column: margin` works together with `renderings: [light, dark]`. +The column-margin class should be preserved when creating light/dark content divs. + +```{r} +#| column: margin +#| renderings: [light, dark] + +knitr::kable(data.frame(x = "Light mode", y = 1)) +knitr::kable(data.frame(x = "Dark mode", y = 2)) +```