Home > Enterprise >  Specify pandoc option in YAML Markdown header
Specify pandoc option in YAML Markdown header

Time:07-15

I need to disable pandoc email obfuscation. I have tried several variations in the YAML header of the .rmd, and I can't make it work. Any feedback, even including "it can't be done", is appreciated.

I make a call from within my R script ("gary_render.R")

rmarkdown::render("gary_test.Rmd")

where gary_test.Rmd looks like

---
output:   html_document:
    pandoc_args: [
      "-M", "email-obfuscation=none"
    ]
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

My Email is [email protected]

I invoke the script

Rscript --no-save --no-restore --verbose gary_render.R

and get the following output

Error in yaml::yaml.load(..., eval.expr = TRUE) : 
  Scanner error: mapping values are not allowed in this context at line 1, column 24
Calls: <Anonymous> ... parse_yaml_front_matter -> yaml_load -> <Anonymous>
Execution halted

CodePudding user response:

Normally we can't put two ":" in the same line (that breaks YAML parsing). So you need to put html_document: in a separate line, when it is followed by other options (not necessarily pandoc ones). Also note that indentation is important in YAML. So the correct header is

---
output:
  html_document:
    pandoc_args: [
      "-M", "email-obfuscation=none"
    ]
---

Also, while this is going to work, I recommend providing a title:

---
title: something
output:
  html_document:
    pandoc_args: [
      "-M", "email-obfuscation=none"
    ]
---
  • Related