demonstrating {.content-visible when-format='html'} fails in posit.cloud #9798
-
DescriptionDear all, we are currently showcasing (and demonstrate) the benefits of a R/Quarto based workflow for technical documentation at work. Today's Q&A made us showcasing how to hide certain outputs in static formats. Is there a chance to make this work within the posit.cloud environment? Thanks for any pointers. ---
title: "Demo Study"
format:
docx: default
#html: defailt
---
```{r}
#| label: setup
library(tidyverse)
library(plotly)
```
## Kicking-off the document
Very important text.
## Towards adding interactive plots
```{r}
gg <- starwars |>
select(name, height, mass, sex, gender, homeworld) |>
mutate(height_m = height/100, BMI = mass / height_m^2) |>
summarise(AVG_BMI = mean(BMI, na.rm = TRUE), .by = sex) |>
ggplot() + geom_col(aes(x = AVG_BMI, y = sex))
```
```{r}
gg + labs(title = "static")
```
Can we add/hide portion of the document dependent on the output format?
::: {.content-visible when-format="html"}
Will only appear in HTML.
```{r}
# we use plotly:: notation to highlight the package (which is already loaded above)
plotly::ggplotly(gg + labs(title = "interactive"))
```
:::
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
How does it fails on posit.cloud ? Do you have an error message ? If I am guessing correctly, you have a knitr rendering error mentioning non-HTML format and saying webshot or webshot2 needs to be applied to get a screenshot to be included in non HTML format. You would get the same message in R Markdown ecosystem. So if I am right you need to either install the package webshot2 or webshot and its dependencies. Then it should work. I believe it is not working posit.cloud because the environment comes fresh, and you may not have installed those packages yet, while locally you may have them already. The reason of this message is because There are ways to skip the rendering using knitr helpers (like Hope it helps. i'll wait for you to confirm before closing |
Beta Was this translation helpful? Give feedback.
How does it fails on posit.cloud ? Do you have an error message ?
If I am guessing correctly, you have a knitr rendering error mentioning non-HTML format and saying webshot or webshot2 needs to be applied to get a screenshot to be included in non HTML format. You would get the same message in R Markdown ecosystem.
So if I am right you need to either install the package webshot2 or webshot and its dependencies. Then it should work. I believe it is not working posit.cloud because the environment comes fresh, and you may not hav…