Reputation: 488
I would like to use knitr to generate a Markdown document. In that Markdown document, I'd like to include some YAML that is generated by a separate program. However, inserting that text as a plain YAML is conflated with the standard frontmatter part of a knitr document. I'm unsure how to escape the YAML that is intended to be in the Markdown output.
That is, the knitr document would follow something like:
---
output: github_document
---
---
foo: bar
---
Lorem Ipsum
Would generate a corresponding Markdown file:
---
foo: bar
---
Lorem Ipsum
Within the knitr document, have tried a few ways to escape the ---
, including:
\---
which outputs as \-–
(en-dash em-dash)
\-\-\-
outputs as \---
-\--
outputs as \---
Upvotes: 1
Views: 172
Reputation: 3242
---
title: "show asis yaml header"
author: "Daniel"
date: "6/28/2020"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
````markdown
---
title: "show asis yaml header"
author: "Daniel"
date: "6/28/2020"
output: html_document
---
````
You want to have a markdown
chunk to show your yaml header. it renders to HTML like this
Upvotes: 4