Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/resources/editor/tools/vs-code.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16791,6 +16791,13 @@ var require_yaml_intelligence_resources = __commonJS({
},
description: "Theme name, theme scss file, or a mix of both."
},
{
name: "renderings",
schema: {
arrayOf: "string"
},
description: "Array of rendering names, e.g. `[light, dark]`"
},
{
name: "body-classes",
tags: {
Expand Down Expand Up @@ -23341,7 +23348,7 @@ var require_yaml_intelligence_resources = __commonJS({
"Print a list of figures in the document.",
"Print a list of tables in the document.",
"Setting this to false prevents this document from being included in\nsearches.",
"Setting this to false prevents the <code>repo-actions</code> from\nappearing on this page.",
"Setting this to false prevents the <code>repo-actions</code> from\nappearing on this page. Other possible values are <code>none</code> or\none or more of <code>edit</code>, <code>source</code>, and\n<code>issue</code>, <em>e.g.</em>\n<code>[edit, source, issue]</code>.",
{
short: "Links to source repository actions",
long: "Links to source repository actions (<code>none</code> or one or more\nof <code>edit</code>, <code>source</code>, <code>issue</code>)"
Expand Down Expand Up @@ -24061,7 +24068,8 @@ var require_yaml_intelligence_resources = __commonJS({
"Disambiguating year suffix in author-date styles (e.g.&nbsp;\u201Ca\u201D in \u201CDoe,\n1999a\u201D).",
"Manuscript configuration",
"internal-schema-hack",
"List execution engines you want to give priority when determining\nwhich engine should render a notebook. If two engines have support for a\nnotebook, the one listed earlier will be chosen. Quarto\u2019s default order\nis \u2018knitr\u2019, \u2018jupyter\u2019, \u2018markdown\u2019, \u2018julia\u2019."
"List execution engines you want to give priority when determining\nwhich engine should render a notebook. If two engines have support for a\nnotebook, the one listed earlier will be chosen. Quarto\u2019s default order\nis \u2018knitr\u2019, \u2018jupyter\u2019, \u2018markdown\u2019, \u2018julia\u2019.",
"Array of rendering names, e.g.&nbsp;<code>[light, dark]</code>"
],
"schema/external-schemas.yml": [
{
Expand Down Expand Up @@ -24290,12 +24298,12 @@ var require_yaml_intelligence_resources = __commonJS({
mermaid: "%%"
},
"handlers/mermaid/schema.yml": {
_internalId: 194627,
_internalId: 194632,
type: "object",
description: "be an object",
properties: {
"mermaid-format": {
_internalId: 194619,
_internalId: 194624,
type: "enum",
enum: [
"png",
Expand All @@ -24311,7 +24319,7 @@ var require_yaml_intelligence_resources = __commonJS({
exhaustiveCompletions: true
},
theme: {
_internalId: 194626,
_internalId: 194631,
type: "anyOf",
anyOf: [
{
Expand Down
18 changes: 13 additions & 5 deletions src/resources/editor/tools/yaml/web-worker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 13 additions & 5 deletions src/resources/editor/tools/yaml/yaml-intelligence-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -9763,6 +9763,13 @@
},
"description": "Theme name, theme scss file, or a mix of both."
},
{
"name": "renderings",
"schema": {
"arrayOf": "string"
},
"description": "Array of rendering names, e.g. `[light, dark]`"
},
{
"name": "body-classes",
"tags": {
Expand Down Expand Up @@ -16313,7 +16320,7 @@
"Print a list of figures in the document.",
"Print a list of tables in the document.",
"Setting this to false prevents this document from being included in\nsearches.",
"Setting this to false prevents the <code>repo-actions</code> from\nappearing on this page.",
"Setting this to false prevents the <code>repo-actions</code> from\nappearing on this page. Other possible values are <code>none</code> or\none or more of <code>edit</code>, <code>source</code>, and\n<code>issue</code>, <em>e.g.</em>\n<code>[edit, source, issue]</code>.",
{
"short": "Links to source repository actions",
"long": "Links to source repository actions (<code>none</code> or one or more\nof <code>edit</code>, <code>source</code>, <code>issue</code>)"
Expand Down Expand Up @@ -17033,7 +17040,8 @@
"Disambiguating year suffix in author-date styles (e.g.&nbsp;“a” in “Doe,\n1999a”).",
"Manuscript configuration",
"internal-schema-hack",
"List execution engines you want to give priority when determining\nwhich engine should render a notebook. If two engines have support for a\nnotebook, the one listed earlier will be chosen. Quarto’s default order\nis ‘knitr’, ‘jupyter’, ‘markdown’, ‘julia’."
"List execution engines you want to give priority when determining\nwhich engine should render a notebook. If two engines have support for a\nnotebook, the one listed earlier will be chosen. Quarto’s default order\nis ‘knitr’, ‘jupyter’, ‘markdown’, ‘julia’.",
"Array of rendering names, e.g.&nbsp;<code>[light, dark]</code>"
],
"schema/external-schemas.yml": [
{
Expand Down Expand Up @@ -17262,12 +17270,12 @@
"mermaid": "%%"
},
"handlers/mermaid/schema.yml": {
"_internalId": 194627,
"_internalId": 194632,
"type": "object",
"description": "be an object",
"properties": {
"mermaid-format": {
"_internalId": 194619,
"_internalId": 194624,
"type": "enum",
"enum": [
"png",
Expand All @@ -17283,7 +17291,7 @@
"exhaustiveCompletions": true
},
"theme": {
"_internalId": 194626,
"_internalId": 194631,
"type": "anyOf",
"anyOf": [
{
Expand Down
3 changes: 3 additions & 0 deletions src/resources/filters/normalize/flags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ function compute_flags()
elseif lightbox_auto == false then
flags.has_lightbox = false
end
if el.renderings then
flags.has_renderings = true
end
end,
}}
end
22 changes: 19 additions & 3 deletions src/resources/filters/quarto-post/cell-renderings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,31 @@ function choose_cell_renderings()
return {json}
end
end

local documentRenderings

return {
traverse = "topdown",
Meta = function(meta)
if meta.renderings then
documentRenderings = {}
for _, inlines in ipairs(meta.renderings) do
table.insert(documentRenderings, inlines[1].text)
end
end
end,
Div = function(div)
-- Only process cell div with renderings attr
if not div.classes:includes("cell") or not div.attributes["renderings"] then
if not div.classes:includes("cell") or (not documentRenderings and not div.attributes["renderings"]) then
return nil
end
local renderingsJson = div.attributes['renderings']
local renderings = jsonDecodeArray(renderingsJson)
local renderings
if div.attributes['renderings'] then
local renderingsJson = div.attributes['renderings']
renderings = jsonDecodeArray(renderingsJson)
else
renderings = documentRenderings
end
if not type(renderings) == "table" or #renderings == 0 then
quarto.log.warning("renderings expected array of rendering names, got", renderings)
return nil
Expand Down
5 changes: 5 additions & 0 deletions src/resources/schema/document-options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
description: The dark theme name, theme scss file, or a mix of both.
description: Theme name, theme scss file, or a mix of both.

- name: renderings
schema:
arrayOf: string
description: "Array of rendering names, e.g. `[light, dark]`"

- name: body-classes
tags:
formats: [$html-doc]
Expand Down
17 changes: 17 additions & 0 deletions tests/docs/smoke-all/dark-mode/dark-brand.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
format: html
brand:
dark: slate-brand.yml
_quarto:
tests:
html:
ensureHtmlElements:
- ["link[href*=\"-dark-\"]"]
- []
---

## Hello

```markdown
![asdf](asd.png)
```
17 changes: 17 additions & 0 deletions tests/docs/smoke-all/dark-mode/dark-theme.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
format: revealjs
theme:
dark: slate
_quarto:
tests:
html:
ensureHtmlElements:
- ["link[href*=\"-dark-\"]"]
- []
---

## Hello

```markdown
![asdf](asd.png)
```
130 changes: 130 additions & 0 deletions tests/docs/smoke-all/dark-mode/ggplot-duobrand-doc-renderings.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
---
title: "knitr dark mode - ggplot"
brand:
light: united-brand.yml
dark: slate-brand.yml
execute:
echo: false
warning: false
renderings: [light, dark]
_quarto:
tests:
html:
ensureHtmlElements:
-
- 'body.quarto-light'
- 'div.cell div.light-content'
- 'div.cell div.dark-content'
- 'div.cell div.cell-code pre.code-with-copy'
- []
---

```{r}
#| echo: false
#| warning: false
library(ggplot2)

ggplot_theme <- function(bgcolor, fgcolor) {
theme_minimal(base_size = 11) %+%
theme(
panel.border = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
text = element_text(colour = fgcolor),
axis.text = element_text(colour = fgcolor),
rect = element_rect(colour = bgcolor, fill = bgcolor),
plot.background = element_rect(fill = bgcolor, colour = NA),
axis.line = element_line(colour = fgcolor),
axis.ticks = element_line(colour = fgcolor)
)
}

brand_ggplot <- function(brand_yml) {
brand <- yaml::yaml.load_file(brand_yml)
ggplot_theme(brand$color$background, brand$color$foreground)
}

united_theme <- brand_ggplot("united-brand.yml")
slate_theme <- brand_ggplot("slate-brand.yml")

colour_scale <- scale_colour_manual(values = c("darkorange", "purple", "cyan4"))
```

### no crossref, no caption

```{r}
ggplot(mtcars, aes(mpg, wt)) +
geom_point(aes(colour = factor(cyl))) +
united_theme +
colour_scale
ggplot(mtcars, aes(mpg, wt)) +
geom_point(aes(colour = factor(cyl))) +
slate_theme +
colour_scale
```

### with crossref but no caption

and `echo: true`

::: {#fig-ggplot}

```{r}
#| echo: true
#| renderings: [dark, light]

# override renderings order
ggplot(mtcars, aes(mpg, disp)) +
geom_point(aes(colour = factor(cyl))) +
slate_theme +
colour_scale
ggplot(mtcars, aes(mpg, disp)) +
geom_point(aes(colour = factor(cyl))) +
united_theme +
colour_scale
```

:::


### with caption but no crossref

<div>

```{r}
#| renderings: [dark]

# override number of renderings
ggplot(mtcars, aes(mpg, disp)) +
geom_point(aes(colour = factor(cyl))) +
slate_theme +
colour_scale
```

ggplot - dark only

</div>


### with crossref and caption

::: {#fig-ggplot-mpg-hp}
```{r}
ggplot(mtcars, aes(mpg, hp)) +
geom_point(aes(colour = factor(cyl))) +
united_theme +
colour_scale
ggplot(mtcars, aes(mpg, hp)) +
geom_point(aes(colour = factor(cyl))) +
slate_theme +
colour_scale
```

mtcars - mpg vs hp
:::

Here's a [link](https://example.com).

{{< lipsum 3 >}}
Loading