### Bug description

There seems to be an issue with plotly inside of divs that normally shouldn't be run and displayed e.g. in the following qmd file:

````md
---
title: "Untitled"
# prefer-html: true
format:
  html: default
  pdf: default
---

# Test

::: {.content-hidden when-format="html"}
Will not appear in HTML.
:::

This works:

::: {.content-hidden unless-format="html"}
Should appear in the html

```{r}
knitr::kable(mtcars, format = "html")
```
:::


The following fails with

> Error: Functions that produce HTML output found in document targeting pdf output.

::: {.content-hidden unless-format="html"}
Should appear in the html, but not in the pdf:

```{r}
library(tidyverse)
plt <- ggplot(mtcars, aes(mpg, disp)) +
  geom_point()

plotly::ggplotly(plt)
```

:::

or when forced through `prefer-html: true` with:

> LaTeX Error: Missing \begin{document}.
> 
> See the LaTeX manual or LaTeX Companion for explanation.
> Type  H <return>  for immediate help.
>  ...                                              
>                                                   
> l.78 <
>       script src="test_files/libs/htmlwidgets-1.5.4/htmlwidgets.js"></script> 
````

quarto version: 1.2.269

### Checklist

- [X] Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
- [X] Please [format your issue](https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us) so it is easier for us to read the bug report.
- [X] Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
- [X] Please document the operating system you're running. If on Linux, please provide the specific distribution.
cscheid
2022-11-09T15:16:46Z
jmbuhr
documentation enhancement
Future
open
`::: {.content-hidden unless-format="html"}` with `plotly` seems to end up in pdf output
https://github.com/quarto-dev/quarto-cli/issues/3254