Skip to content

Commit 1c0460c

Browse files
claude: warn when cell-renderings has duplicate names
When the `renderings` attribute contains duplicate names like `[dark, light, dark, light]`, only the last cell output for each name is used. This change adds a warning to alert users that their earlier outputs are being silently dropped. Fixes #13900 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 525c821 commit 1c0460c

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

news/changelog-1.9.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ All changes included in 1.9:
3232
- ([#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.
3333
- ([#13413](https://github.com/quarto-dev/quarto-cli/issues/13413)): Fix uncentered play button in `video` shortcodes from cross-reference divs. (author: @bruvellu)
3434
- ([#13508](https://github.com/quarto-dev/quarto-cli/issues/13508)): Add `aria-label` support to `video` shortcode for improved accessibility.
35+
- ([#13900](https://github.com/quarto-dev/quarto-cli/issues/13900)): Warn when `renderings` cell option contains duplicate names. Previously, duplicate names like `[dark, light, dark, light]` would silently use only the last output for each name.
3536

3637
### `typst`
3738

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ function choose_cell_renderings()
3838
end
3939

4040
local outputs = {}
41+
local seen = {}
4142
for i, r in ipairs(renderings) do
43+
if seen[r] then
44+
quarto.log.warning("duplicate rendering name '" .. r .. "' in renderings; only the last cell output with each name will be used")
45+
end
46+
seen[r] = true
4247
outputs[r] = cods[i]
4348
end
4449
local lightDiv = outputs['light']
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: "Test duplicate rendering names warning"
3+
format: html
4+
execute:
5+
echo: false
6+
_quarto:
7+
tests:
8+
html:
9+
printsMessage:
10+
level: INFO
11+
regex: "duplicate rendering name 'dark' in renderings"
12+
---
13+
14+
```{r}
15+
#| renderings: [dark, light, dark, light]
16+
17+
plot(1, main = "Plot 1 (dark)")
18+
plot(2, main = "Plot 2 (light)")
19+
plot(3, main = "Plot 3 (dark)")
20+
plot(4, main = "Plot 4 (light)")
21+
```

0 commit comments

Comments
 (0)