-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Boolean parameter in quarto_render
is not interpreted by .content-visible
whith when-meta
option
#211
Comments
quarto_render
is not interpreted by then when-meta
optionquarto_render
is not interpreted by .content-visible
whith when-meta
option
This is from the doc about
Now let's look at your example
In your document, you correctly define correction as a boolean. So when you render this document using Render button, the However, this Quarto feature So Currently, you need to explicitly redefine the meta - soon with a helper function (#137) Example document---
format:
pdf: default
params:
correction: true
---
```{r}
print(class(params$correction))
```
```{r}
#| label: chunk-R-condional_code
#| eval: !expr "params$correction"
print("This chunk is executed only on correction")
```
```{r}
#| include: false
write_meta <- function(meta) {
handlers <- list(logical = function(x) {
value <- ifelse(x, "true", "false")
structure(value, class = "verbatim")
})
res <- yaml::as.yaml(meta, handlers = handlers)
knitr::asis_output(paste0("---\n", res, "---\n"))
}
```
```{r}
#| echo: false
#| output: asis
write_meta(list(params = list(correction = params$correction)))
```
:::{.content-visible when-meta="params.correction"}
This text should appear when correction is set to `TRUE`
::: I moved this to this repo as I though it was a R package issue, but it may something we need to improve.
This won't modify the params inside the document YAML header for knitr engine. Let's note that it requires a new parameter interface multi engine before we can improve this. So related to |
Thank very much for the quick answer and for the working solution! |
Bug description
I have a parametrized quarto document with a boolean parameter named
correction
.This boolean controls both
R
code execution (usingparams$correction
) and text printing via thewhen-meta
option for a class.content-visible
(see the minimal example below).When I knit the document using the
Render
button on Rstudio, eveything works fine, both the code execution and text printing reacts according to the value ofcorrection
attribute.However, when I use
quarto_render
, and then give the value ofcorrection
as aR
boolean, the.content-visible
part do not reacts accordingly to the given valueSteps to reproduce
Create a
my_document.qmd
file containing the followingYou can ensure that everythings works fine when you render it from Rstudio by clicking on the
Render
button.Then, in
R
, execute:Expected behavior
The R code should produce a document
cor_TRUE.pdf
where both the print from theR
code and the text within the.content-visible
appears and a documentcor_FALSE.pdf
where none of those appears.Actual behavior
The
R
code interprets well the given parameter, but it is ignored by the.content-visible
class.Your environment
Quarto check output
Quarto 1.5.57
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.2.0: OK
Dart Sass version 1.70.0: OK
Deno version 1.41.0: OK
Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.5.57
Path: /opt/quarto/bin
[✓] Checking tools....................OK
TinyTeX: v2024.09
Chromium: (not installed)
[✓] Checking LaTeX....................OK
Using: TinyTex
Path: /home/gloaguen/.TinyTeX/bin/x86_64-linux
Version: 2024
[✓] Checking basic markdown render....OK
[✓] Checking Python 3 installation....OK
Version: 3.11.7 (Conda)
Path: /home/gloaguen/miniconda3/envs/STA2121/bin/python
Jupyter: 5.7.1
Kernels: python3
[✓] Checking Jupyter engine render....OK
[✓] Checking R installation...........OK
Version: 4.4.1
Path: /usr/lib/R
LibPaths:
- /home/gloaguen/R/x86_64-pc-linux-gnu-library/4.4
- /usr/local/lib/R/site-library
- /usr/lib/R/site-library
- /usr/lib/R/library
knitr: 1.48
rmarkdown: 2.28
[✓] Checking Knitr engine render......OK
The text was updated successfully, but these errors were encountered: