From 632c694edca021424cd64c43bb5ed394919a6431 Mon Sep 17 00:00:00 2001 From: Gordon Woodhull Date: Tue, 15 Apr 2025 18:02:31 -0400 Subject: [PATCH 1/2] revert document renderings this feature is still a great idea but wasn't thought through needs access to the feature from engines/code what should happen with cells that don't have right number of outputs? (this would warn about them) will return to this in 1.8! --- src/resources/filters/normalize/flags.lua | 3 - .../filters/quarto-post/cell-renderings.lua | 22 +-- src/resources/schema/document-options.yml | 5 - .../ggplot-duobrand-doc-renderings.qmd | 130 ------------------ 4 files changed, 3 insertions(+), 157 deletions(-) delete mode 100644 tests/docs/smoke-all/dark-mode/ggplot-duobrand-doc-renderings.qmd diff --git a/src/resources/filters/normalize/flags.lua b/src/resources/filters/normalize/flags.lua index ca886839949..245dd571153 100644 --- a/src/resources/filters/normalize/flags.lua +++ b/src/resources/filters/normalize/flags.lua @@ -195,9 +195,6 @@ function compute_flags() elseif lightbox_auto == false then flags.has_lightbox = false end - if el.renderings then - flags.has_renderings = true - end end, }} end diff --git a/src/resources/filters/quarto-post/cell-renderings.lua b/src/resources/filters/quarto-post/cell-renderings.lua index 73341fe822a..4829a3920cf 100644 --- a/src/resources/filters/quarto-post/cell-renderings.lua +++ b/src/resources/filters/quarto-post/cell-renderings.lua @@ -8,31 +8,15 @@ 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 documentRenderings and not div.attributes["renderings"]) then + if not div.classes:includes("cell") or not div.attributes["renderings"] then return nil end - local renderings - if div.attributes['renderings'] then - local renderingsJson = div.attributes['renderings'] - renderings = jsonDecodeArray(renderingsJson) - else - renderings = documentRenderings - end + local renderingsJson = div.attributes['renderings'] + local renderings = jsonDecodeArray(renderingsJson) if not type(renderings) == "table" or #renderings == 0 then quarto.log.warning("renderings expected array of rendering names, got", renderings) return nil diff --git a/src/resources/schema/document-options.yml b/src/resources/schema/document-options.yml index 18a10f9ca80..5170a8ac705 100644 --- a/src/resources/schema/document-options.yml +++ b/src/resources/schema/document-options.yml @@ -34,11 +34,6 @@ 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] diff --git a/tests/docs/smoke-all/dark-mode/ggplot-duobrand-doc-renderings.qmd b/tests/docs/smoke-all/dark-mode/ggplot-duobrand-doc-renderings.qmd deleted file mode 100644 index cbd1dc2d2e6..00000000000 --- a/tests/docs/smoke-all/dark-mode/ggplot-duobrand-doc-renderings.qmd +++ /dev/null @@ -1,130 +0,0 @@ ---- -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 - -
- -```{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 - -
- - -### 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 >}} \ No newline at end of file From ef58b53e3297071c1e5775100d7ad2759254043b Mon Sep 17 00:00:00 2001 From: Gordon Woodhull Date: Tue, 15 Apr 2025 18:03:15 -0400 Subject: [PATCH 2/2] artifacts --- src/resources/editor/tools/vs-code.mjs | 13 +++---------- src/resources/editor/tools/yaml/web-worker.js | 13 +++---------- .../tools/yaml/yaml-intelligence-resources.json | 13 +++---------- 3 files changed, 9 insertions(+), 30 deletions(-) diff --git a/src/resources/editor/tools/vs-code.mjs b/src/resources/editor/tools/vs-code.mjs index 2f4434db469..c6c2c2bd804 100644 --- a/src/resources/editor/tools/vs-code.mjs +++ b/src/resources/editor/tools/vs-code.mjs @@ -16798,13 +16798,6 @@ 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: { @@ -24305,12 +24298,12 @@ var require_yaml_intelligence_resources = __commonJS({ mermaid: "%%" }, "handlers/mermaid/schema.yml": { - _internalId: 195005, + _internalId: 195e3, type: "object", description: "be an object", properties: { "mermaid-format": { - _internalId: 194997, + _internalId: 194992, type: "enum", enum: [ "png", @@ -24326,7 +24319,7 @@ var require_yaml_intelligence_resources = __commonJS({ exhaustiveCompletions: true }, theme: { - _internalId: 195004, + _internalId: 194999, type: "anyOf", anyOf: [ { diff --git a/src/resources/editor/tools/yaml/web-worker.js b/src/resources/editor/tools/yaml/web-worker.js index c98c737eae0..901a8967a2d 100644 --- a/src/resources/editor/tools/yaml/web-worker.js +++ b/src/resources/editor/tools/yaml/web-worker.js @@ -16799,13 +16799,6 @@ try { }, 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: { @@ -24306,12 +24299,12 @@ try { mermaid: "%%" }, "handlers/mermaid/schema.yml": { - _internalId: 195005, + _internalId: 195e3, type: "object", description: "be an object", properties: { "mermaid-format": { - _internalId: 194997, + _internalId: 194992, type: "enum", enum: [ "png", @@ -24327,7 +24320,7 @@ try { exhaustiveCompletions: true }, theme: { - _internalId: 195004, + _internalId: 194999, type: "anyOf", anyOf: [ { diff --git a/src/resources/editor/tools/yaml/yaml-intelligence-resources.json b/src/resources/editor/tools/yaml/yaml-intelligence-resources.json index 588d8aef228..0a08dee8449 100644 --- a/src/resources/editor/tools/yaml/yaml-intelligence-resources.json +++ b/src/resources/editor/tools/yaml/yaml-intelligence-resources.json @@ -9770,13 +9770,6 @@ }, "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": { @@ -17277,12 +17270,12 @@ "mermaid": "%%" }, "handlers/mermaid/schema.yml": { - "_internalId": 195005, + "_internalId": 195000, "type": "object", "description": "be an object", "properties": { "mermaid-format": { - "_internalId": 194997, + "_internalId": 194992, "type": "enum", "enum": [ "png", @@ -17298,7 +17291,7 @@ "exhaustiveCompletions": true }, "theme": { - "_internalId": 195004, + "_internalId": 194999, "type": "anyOf", "anyOf": [ {