【发布时间】:2020-11-30 21:40:04
【问题描述】:
如果我只是简单地将 YouTube 提供的 HTML 代码复制并粘贴到 .Rmd 文件中,这对于 gitbook 输出效果很好。下面是代码示例
<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>
但是,我收到 PDF 和 EPUB 输出的错误消息。为了避免这种情况,我想我可以使用条件编译,例如
```{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>
}
```
但是,这已在 RStudio 编辑器中因意外标记而被删除。这里有什么问题?有没有办法解决这个问题?
【问题讨论】:
-
作为记录,这是在github.com/rstudio/bookdown/issues/927 交叉发布的。
标签: html video conditional-statements output bookdown