How to preview R Markdown (.rmd) Documents?

john's Avatar


22 Aug, 2020 09:09 PM

I've just started using R Markdown to get more control over my markdown generated documents. I'm checking to see if I can get Marked 2 to use an R Markdown processor to render the document.

To that end,

  1. I made a copy of the render script in this thread -
  2. I enabled the custom processor
  3. Put the path to the script in the processor settings.
  4. Made the script executable
  5. Updated permissions
  6. Made the script executable

My Markdown 2 document screen displays this when I select the custom processor

/usr/local/bin/pandoc +RTS -K512m -RTS --to docx --from markdown+autolink_bare_uris+tex_math_single_backslash --output /var/folders/f6/nv5cjhps7ps4kz1b7l9l7b8r0000gn/T/output.loss2EUX --highlight-style tango --reference-doc svm-rmarkdown-word.docx --lua-filter /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rmarkdown/rmd/lua/pagebreak.lua [WARNING] Could not parse YAML metadata at line 33 column 1: Lexical error near "Apps Confluence, Google Chrome, Jenkins, Jira, MS Office, Nagios, Op5, SecureCRT, SharePoint " pandoc: svm-rmarkdown-word.docx: openBinaryFile: does not exist (No such file or directory) Error: pandoc document conversion failed with error 1 Execution halted

I did a manual run using the suggested syntax from the thread above, and it worked.
cat rmarkdownfile.rmd | /path/to/ > outfile.html
It seems that it cannot find a file, but I can't tell which one it cannot find from the output.

Has anyone gotten this to work that can shed some light on what I might be doing wrong?

  1. Support Staff 1 Posted by Brett on 22 Aug, 2020 10:26 PM

    Brett's Avatar

    It looks like your —reference-doc parameter needs an absolute path to the docx file.

    - Brett

  2. 2 Posted by john on 23 Aug, 2020 12:58 AM

    john's Avatar

    Thanks. That fixed the error. The document doesn't at all different than with the built-in Github md processor.

    In fact "knitr::opts_chunk$set(echo = TRUE)" appears as a code block, where R would normally run the command, not display it.

    Curiously, I had "cd /path/to/project/folder" in the script , and the template file is in that folder.

    What I was hoping for was the document to look like the Word document produced by the R markdown render command. eg
    rmarkdown::render("/path/to/file.rmd", encoding = "UTF-8")

    For now, I'll go back editing the rmd file and periodically create the MS Word document periodically to see what it looks like.

  3. Brett closed this discussion on 25 Sep, 2020 04:22 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac