how to access yaml metadata from knitr

2019-04-08 16:16发布

问题:

Does knitr know the value of YAML data e.g. title: or date: or some_custom_field: while it is compiling an rmarkdown doc with a YAML header?

I would like to be able to do this (pseudocode)

---
title: my title
---

The title of this document is `r knitrs_yaml_array("title")`

回答1:

That is stored in rmarkdown::metadata as a list of the form list(title = ...).