首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用_site.yml文件时渲染Xaringan Rmd

使用_site.yml文件时渲染Xaringan Rmd
EN

Stack Overflow用户
提问于 2019-05-10 00:44:53
回答 1查看 193关注 0票数 1

我有一个包含三个文件的网站。

_site.yml

name: Website
navbar:
  title: Website
  right:
    - text: Home
    - text: Info
output:
  html_document:
    theme: flatly
    highlight: tango

index.Rmd

---
title: Welcome
output:
  html_document:
    theme: united
    highlight: textmate
---

This is the index.

test.Rmd

---
title: Test
output:
  html_document:
    theme: united
    highlight: textmate
---

This is the test file.

```{r}

2+2

如果我运行rmarkdown::render("test.Rmd"),我会得到一个包含网站标题的超文本标记语言。这类似于运行rmarkdown::render_site()的输出。

如果我删除_site.yml文件并运行相同的命令,我会得到常规的HTML输出:

因此,如果存在,render()必须使用_site.yml。可以禁用此功能吗?我想创建一个常规的超文本标记语言输出,即使_site.yml文件存在。这是一个特别的问题,当我有xaringan演示文稿时,我不希望它们与网站标题一起呈现。

EN

回答 1

Stack Overflow用户

发布于 2019-05-10 03:46:13

我不认为有一种方法可以在rmarkdown中禁用它,但您可以尝试以下解决方法来暂时重命名它,然后再重新命名它:

render_without_site_yml <- function(input, ...) {
  dir <- dirname(input)
  site_yml <- file.path(dir, "_site.yml")
  if (file.exists(site_yml)) {
    newname <- file.path(dir, "_site.yml.save")
    if (file.exists(newname))
      stop("'_site.yml.save' exists!")
    file.rename(site_yml, newname)
    on.exit(file.rename(newname, site_yml))
  }
  rmarkdown::render(input, ...)
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56064050

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档