- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一组分布在文件夹层次结构中的 RMarkdown 文档。所有文档都引用相同的 CSS 和页眉/页脚文件。我目前有硬编码这些文件的路径,但这很难维护。我更喜欢动态生成路径。
这有效(日期在代码中动态生成):
---
title: "Untitled"
date: "`r Sys.Date()`"
output: html_document
---
---
title: "Untitled"
date: "`r Sys.Date()`"
output:
html_document:
css: '`r here::here("styles/styles.css")`'
includes:
before_body: '`r here::here("styles/header.html")`'
after_body: '`r here::here("styles/footer.html")`'
---
styles.css
,
header.html
和
footer.html
都位于
styles/
项目根目录下的文件夹。当我使用
here::here()
引用这些文件时从控制台它完美地工作。
File `r here::here( not found in resource path
Error: pandoc document conversion failed with error 99
pandoc: `r here::here("styles/header.html")`: openBinaryFile: does not exist
(No such file or directory)
最佳答案
使用 yaml::yaml.load()
解析 YAML header 功能。
该函数的手册页解释说
There is a built-in handler that will evaluate expressions that are tagged with the
!expr
tag. Currently this handler is enabled by default, but the handler is being disabled by default in an upcoming version for safety and security reasons. If you do not explicity set theeval.expr
argument toTRUE
, you will get a warning if an expression is evaluated. Alternately, you can set the option namedyaml.eval.expr
via theoptions
function to turn off the warning.
---
title: "Untitled"
date: "`r Sys.Date()`"
output:
html_document:
css: !expr here::here("styles/styles.css")
includes:
before_body: !expr here::here("styles/header.html")
after_body: !expr here::here("styles/footer.html")
---
关于r - 如何将 here() 用于 css、before_body 和 after_body 的路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56681879/
我有一个 LaTeX 部分,放在我的 knitr 生成的 PDF 文档的顶部。我通过使用 YAML 选项实现了这一点 output: pdf_document: include
我有一组分布在文件夹层次结构中的 RMarkdown 文档。所有文档都引用相同的 CSS 和页眉/页脚文件。我目前有硬编码这些文件的路径,但这很难维护。我更喜欢动态生成路径。 这有效(日期在代码中动态
我是一名优秀的程序员,十分优秀!