If I simply copy and paste an HTML code provided by YouTube into a .Rmd file, this works fine for gitbook output. Here is an example of the code
<iframe width="560" height="315" src="https://www.youtube.com/embed/9AI3BkKQhn0"
frameborder="0" allow="accelerometer; autoplay; encrypted-media;
gyroscope; picture-in-picture" allowfullscreen>
</iframe>
However, I get error messages for PDF and EPUB outputs. In order to avoid this, I thought I could use conditional compilation, e.g.
```{r}
if (knitr::is_html_output(excludes = "epub")) {
<iframe width="560" height="315"
src="https://www.youtube.com/embed/9AI3BkKQhn0"
frameborder="0" allow="accelerometer; autoplay; encrypted-media;
gyroscope; picture-in-picture" allowfullscreen>
</iframe>
}
```
However, this gets crossed out already in the RStudio editor for unexpected tokens. What is wrong here? Is there a way around this issue?