我想在RMarkdown中使用Markdown输出输出自己的YAML标头。其背后的原因是从给定的源动态创建MD文件。
尝试使用results='asis'
添加它将不起作用,因为它将处理链接的输出,即:在链接中添加<>:
---
title: "test"
output:
md_document:
variant: markdown
toc: false
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
```{r testyaml, echo=FALSE, results='asis'}
h <- "
+++\n
showonlyimage = false\n
draft = false\n
image = \"http://adsf.com\" \n
date = \"2016-11-05T18:25:22+05:30\"\n
title = \"mytitle\"\n
weight = 0\n
+++\n"
cat(h, sep = " ", fill = FALSE, collapse = '\n')
输出:
+++
showonlyimage = false
draft = false
image = "<http://adsf.com>"
date = "2016-11-05T18:25:22+05:30"
title = "mytitle"
weight = 0
+++
(请注意<>包装http://adsf.com
)。
答案 0 :(得分:0)
像这样设置preserve_yaml: true
:
output:
md_document:
variant: markdown
preserve_yaml: true