Skip to content

Commit 93ba348

Browse files
claude: fix column-margin with renderings option (#13825)
Preserve existing classes on cell-output-display divs when applying light/dark theme classes in the cell-renderings filter. Previously, new divs were created that discarded existing classes like column-margin. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 38d4e7a commit 93ba348

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

src/resources/filters/quarto-post/cell-renderings.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ function choose_cell_renderings()
5757
blocks:insert(darkDiv)
5858
end
5959
elseif quarto.format.isHtmlOutput() and lightDiv and darkDiv then
60-
blocks:insert(pandoc.Div(lightDiv.content, pandoc.Attr("", {'light-content'}, {})))
61-
blocks:insert(pandoc.Div(darkDiv.content, pandoc.Attr("", {'dark-content'}, {})))
60+
-- Preserve existing classes (e.g., column-margin, cell-output-display) and add theme class
61+
lightDiv.classes:insert('light-content')
62+
darkDiv.classes:insert('dark-content')
63+
blocks:insert(lightDiv)
64+
blocks:insert(darkDiv)
6265
else
6366
blocks:insert(lightDiv or darkDiv)
6467
end
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: "renderings with column-margin"
3+
format:
4+
html:
5+
theme:
6+
light: flatly
7+
dark: darkly
8+
_quarto:
9+
tests:
10+
html:
11+
ensureHtmlElements:
12+
-
13+
- 'div.cell div.column-margin div.cell-output-display.light-content'
14+
- 'div.cell div.column-margin div.cell-output-display.dark-content'
15+
- []
16+
---
17+
18+
This tests that `column: margin` works together with `renderings: [light, dark]`.
19+
The column-margin class should be preserved when creating light/dark content divs.
20+
21+
```{r}
22+
#| column: margin
23+
#| renderings: [light, dark]
24+
25+
knitr::kable(data.frame(x = "Light mode", y = 1))
26+
knitr::kable(data.frame(x = "Dark mode", y = 2))
27+
```

0 commit comments

Comments
 (0)