I am revising a bookdown html book to include a pdf version for print publication (not for reading the pdf directly). I'd like to get advice on how to conditionally exclude some content based on the output type.
Technical: I have iframes in my Rmd files (not inside code chunks) that embed Youtube videos and gifs in the main column. I also have iframes that display content in the margins when placed inside {marginfigure} code chunks (Tufte-style). Here's an example. Is there a way to suppress these iframes for the pdf output?
Style: I'm looking for examples of books that have an enhanced html version that includes this type of multimedia content AND a standard pdf version (for publishing as a hard copy). I'm interested to see how the print version might reference this omitted material, if at all. For instance, in place of a Youtube video in the print version, is it best practice to include a video icon with a shortlink that the print reader could type into a browser?
Thanks, @maelle. This is great. It seems like this should be the trick.
However, I wonder if I'm misunderstanding how to apply this in my use case. I have some content in margin notes:
```{marginfigure, eval=knitr::is_html_output(), echo=FALSE}
Testing the use of margin notes. Testing the use of margin notes. Testing the use of margin notes. Testing the use of margin notes.
```
And I have iframes not inside any chunk, just in the Rmarkdown body:
My text. More text. See this video.
<iframe>...</iframe>
That was a cool video
Can I use this approach with marginfigure chunks?
Is there a way to use this with content not in chunks? Maybe there is some way to put my iframes in a chunk and then use the approach you showed?