Skip to content

::: {.content-hidden unless-format="html"} with plotly seems to end up in pdf output #3254

@jmbuhr

Description

@jmbuhr

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:

---
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

  • 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.
  • Please format your issue so it is easier for us to read the bug report.
  • Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
  • Please document the operating system you're running. If on Linux, please provide the specific distribution.

Metadata

Metadata

Assignees

Labels

documentationDoc improvements & quarto-webenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions