4

Anyone know of a way to convert rmarkdown (rmd) files to orgmode?

im preparing a R course and lots of cool examples in R are in rmd format so it could be very useful to me. I tried via pandoc but results were not great

zeltak
  • 1,685
  • 11
  • 25
  • 2
    This would seem to be a duplicate of http://emacs.stackexchange.com/questions/5465/how-to-migrate-markdown-files-to-emacs-org-mode-format?rq=1 – Michael Vehrs Jul 20 '16 at 09:19
  • 1
    This isnt a duplicate. the R markdown syntax is quite different from normal pandoc and as i stated pandoc dosent convert it well – zeltak Jul 20 '16 at 09:24
  • 1
    Ok, then, what's the problem exactly? What do you mean when you say "results were not great"? As far as I can tell, embedded code blocks are a standard feature of markdown (as understood by pandoc). Aren't they supported properly by pandoc? Can you post an example? – Michael Vehrs Jul 20 '16 at 09:31
  • @MichaelVehrs RMardown isn't **just** a variant of Markdown. The code blocks in RMarkdown are intended to be executed, so that not just the code but also the results are present in the resulting markdown. Pandoc will format the code blocks, but it doesn't execute them. – Tyler Jul 20 '16 at 17:55
  • That information should have been part of the original question, if you ask me. Anyway, I'm glad you solved your problem. – Michael Vehrs Jul 21 '16 at 08:19

1 Answers1

7

Ok so for anyone interested here is the solution i found

in R (via the GUI or through R -e command line), first convert the Rmd files to md files:

require(knitr) # required for knitting from rmd to md
require(markdown) # required for md to html 
knit('test.rmd', 'test.md') # creates md file

then use pandoc to convert the md files to org:

pandoc -o test.org  test.md   

this gives an almost 1:1 org file

zeltak
  • 1,685
  • 11
  • 25