Skip to content

Conversation

@cderv
Copy link
Collaborator

@cderv cderv commented Jan 12, 2023

So that we get vector instead of unnamed list as e.g some knitr options expect vector. This closes #3909

Context

Setting multiple for dev was not working

---
title: "Document"
format: 
  html:
    embed-resources: false
knitr:
  opts_chunk:
    dev:
      - png
      - pdf
      - svg
---

```{r}
library(ggplot2)
ggplot() + ggtitle("this is a title")
```

because Quarto parses the YAML then pass it to the R process using JSON message that is parsed with jsonlite but knitr$opts_chunk$dev is seen as a unamed list and not coerced to a vector.

This creates issue within knitr which expect a vector for some options and currently does not handle or coerce list to vector itself.

I believe that YAML parsing does correctly see this as a vector, so it seems ok to simplify when parsing the JSON.
This will also convert to Matrix and Dataframe in some case - if we want to prevent that we could do

request <- jsonlite::parse_json(input, simplifyVector = TRUE, simplifyDataFrame = FALSE, simplifyMatrix = FALSE)

but seems too much.

If this is too broad fix anyway, We could simplify only the knitr fields in the message.;

BTW I tried to add a test using the new smoke-all folder - Hopefully adding a file is enough for it to be run.

So that we get vector instead of unnamed list as e.g some knitr options expect vector.

Add test for special issue with `dev` option
@cderv cderv requested a review from jjallaire January 12, 2023 10:36
@jjallaire
Copy link
Collaborator

It seems unlikely that a data frame or matrix would ever be passed so I agree that's too much. Will merge as is. Thanks!

@jjallaire jjallaire merged commit 1805286 into main Jan 12, 2023
@cderv cderv deleted the knitr-options-yaml branch January 12, 2023 11:31
cscheid pushed a commit that referenced this pull request Jan 19, 2023
So that we get vector instead of unnamed list as e.g some knitr options expect vector.

Add test for special issue with `dev` option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error setting multipe dev value in knitr opts_chunk in YAML

3 participants