user3109180
user3109180

Reputation: 31

How do I pass pandoc_options as output_options to rmarkdown::render()

I have an Rmd file that renders into html correctly almost all of the time. However, it does not render correctly when pandoc (used in the rendering process) finds 4 spaces in the html and at that point, interprets that I want to render a markdown code snippet instead of html.

I have been told that I can turn off the markdown_in_html_blocks feature by doing something like this:
pandoc -f markdown-markdown_in_html_blocks.

I have tried calling pandoc directly rather than it being called implicitly by

rmarkdown::render()

but couldn't get that syntax to work and being able to specify this option (-markdown_in_html_blocks) directly as I call render() is preferred. Here is the latest of I have tried without success:

Base case: works but HTML output file is malformed / has a code block instead of the data that I want to display in the table.

render("reports/Pacing.Rmd")

Attempted fix: not working

rmdFmt <- rmarkdown_format("-markdown_in_html_blocks")
pandocOpts <- pandoc_options(to = "html", from = rmdFmt)
render("reports/Pacing.Rmd",output_format = "html_document",output_file = NULL, output_dir = NULL, output_options = pandocOpts)

Error message: Error in (function (toc = FALSE, toc_depth = 3, toc_float = FALSE, number_sections = FALSE, : argument 1 matches multiple formal arguments

I have tried other syntax to express that I want to turn off markdown_in_html_blocks but no luck.

Upvotes: 3

Views: 1230

Answers (2)

Quasimodo
Quasimodo

Reputation: 204

Given the following document test.Rmd...

---
title: Test
output: html_document
---

<table>
<tr>
<td>*one*</td>
<td>[a link](https://google.com)</td>
</tr>
</table>

...you can disable the markdown_in_html_blocks extension via

rmarkdown::render("test.Rmd",
                  output_options = list(md_extensions = "-markdown_in_html_blocks"))

md_extensions is one of the arguments that can be passed to rmarkdown::html_document (see ?rmarkdown::html_document for other arguments).

Upvotes: 2

Kunal Shukla
Kunal Shukla

Reputation: 31

That seems to be an open issue, but a simpler way to turn off/on such a feature is to directly update the YAML in Rmd file. This should work in your case:

output:
  html_document:
    pandoc_args: [
      "-f", "markdown-markdown_in_html_blocks"
    ]

Upvotes: 1

Related Questions