-
DescriptionConsider the code below:
I'm getting an error rendering this because the |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
It seems to be an issue with the R package output which triggers Quarto error, when you set ---
format: pdf
---
Something here
::: {.content-visible when-format="html"}
```{r}
knitr::kable(head(mtcars), format = "html")
```
::: FYI, the error is the following: Error: Functions that produce HTML output found in document targeting pdf output.
Please change the output type of this document to HTML.
If your aiming to have some HTML widgets shown in non-HTML format as a screenshot,
please install webshot or webshot2 R package for knitr to do the screenshot.
Alternatively, you can allow HTML output in non-HTML formats
by adding this option to the YAML front-matter of
your quarto file:
prefer-html: true
Note however that the HTML output will not be visible in non-HTML formats. I am not exactly sure why the error is triggered here (https://github.com/quarto-dev/quarto-cli/blob/main/src/execute/rmd.ts). |
Beta Was this translation helpful? Give feedback.
-
Oh, that's weird. Thanks for the reply. Removing the option solves it, and will in fact also render correctly to .pdf. |
Beta Was this translation helpful? Give feedback.
-
To be clear on the why an error is thrown - Current limitation is that Conditional Content in Quarto using the Markdown syntax will apply at the end and computation of all cells with It happens that there is mechanism with knitr to detect HTML output from chunk in non-HTML format rendering. This is why you see the issue. |
Beta Was this translation helpful? Give feedback.
This is expected error by knitr and rmarkdown because HTML code is produced in output while the output format is seen to be PDF.
So this will be detected at computation rendering time (during knitting) and an error is thown. In some cases when webshot or webshot2 is detected, a screenshot of the HTML rendered is taken (for leaflet for example).
So basically this happens because
This will be improved when we'll adapt c…