Running transformation with pandoc

Hi! I am very new to RStudio and pandoc. I am trying to convert demo markdown to docx using pandoc. The RStudio R Markdown console outputs the following command to execute the transformation:
/usr/local/bin/pandoc +RTS -K512m -RTS --to docx --from markdown+autolink_bare_uris+tex_math_single_backslash+smart --output abc.docx --highlight-style tango --lua-filter /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rmarkdown/rmd/lua/pagebreak.lua

However when I try to run it from the terminal I get:

pandoc: openBinaryFile: does not exist (No such file or directory)

Any idea what I do wrong?
I use MacOS.

Can you provide a full reproductible example ?

This error means that the file abc.Rmd you are trying to convert did not produce correctly the md file for pandoc.

How did you create the document and how did you run the conversion ? rmarkdown::render ?

Are you on local file system ?

I just installed the RStudio, then File -> New File -> R Markdown -> Document -> Word
Kint to Word works and R Markdown console lists the commands:

/usr/local/bin/pandoc +RTS -K512m -RTS --to docx --from markdown+autolink_bare_uris+tex_math_single_backslash+smart --output aaa.docx --highlight-style tango --lua-filter /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rmarkdown/rmd/lua/pagebreak.lua

When I try to run the pandoc command from Terminal, I get exception message I mentioned above.

just reproduce the step with no error.

What do you want to achieve ? Why are you trying to execute this command from the terminal ?
Rmarkdown will use this command to generate the output document using intermediary files it created. Those files are cleaned after a render by default. So you can't just copy paste and run, you need to adapt the logic

I would like to run the md -> docx transformation from command line. Is it possible?

You can use pandoc at the command line but you'll need to go through pandoc documentation.
You'll have to create the markdown input for pandoc or generate it from Rmarkdown, then pass any argument you need though command line.

there is a keep_md argument in rmarkdown::*_document function to keep the md document generated, and there is a clean argument to set to FALSE to keep the intermediary files.

Rmarkdown is not really designed to be used at 50% of its process. It happends that some argument to pandoc command are temp file created by rmarkdown. You'll however find some pandoc functions helps like pandoc_convert - maybe they can help.

basically, the issue you have is that the input file for pandoc ( does not exists - you'll need to keep it, or create a new one to pass to pandoc. Pandoc take md inputs not rmd inputs.

Hope it helps.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.