all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Charles C. Berry" <ccberry@ucsd.edu>
To: Xebar Saram <zeltakc@gmail.com>
Cc: org mode <emacs-orgmode@gnu.org>, Philip Hudson <phil.hudson@iname.com>
Subject: Re: convert rmarkdown (rmd) files to orgmode?
Date: Wed, 20 Jul 2016 10:20:09 -0700	[thread overview]
Message-ID: <alpine.OSX.2.20.1607200956080.624@charles-berrys-macbook.local> (raw)
In-Reply-To: <CAOQHXPrTCTP8efb_EZv1fsrdv6Sf0Q_zPKsGXfn6_4c=c1EsGQ@mail.gmail.com>

On Wed, 20 Jul 2016, Xebar Saram wrote:

> thx phil
>
> the Rmd format is actually quite different than md so that conversion didnt
> go well
>

I tried this

 	pandoc -f markdown -t org input-file.Rmd -o output-file.org

then I opened `output-file.org' and put this src block at the very top:

#+BEGIN_SRC emacs-lisp :results silent
   (replace-regexp "^=[{]r \\([^}]*\\)[}]\\(.*\\)=$"
 		  "#+name: \\1
   ,#+begin_src R
   \\2
   ,#+end_src")

#+END_SRC

When I execute that code block, all the converted code chunks become src 
blocks.

This isn't perfect as chunk options are appended to the `#+NAME:...' line, 
but if you want to play with the regexp's you can probably get it to pick 
those out and put them on a separate line. Or just write another src block 
with another `replace-regexp' to fix those lines.

With a little effort you can write a command file for `sed' to do what the 
code block above does and then pipe the pandoc output to that command like 
this:

: pandoc -f markdown -t org input-file.Rmd | \
: sed -f convert-chunks > output-file.org

and you have an org document ready (or almost ready) to go.


HTH,

Chuck

  reply	other threads:[~2016-07-20 17:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-20  4:28 convert rmarkdown (rmd) files to orgmode? Xebar Saram
     [not found] ` <CAJ1MqVF4Cq3ogH34P6AtSf0-ZX7ic=tApuX-ad=+14pLF7p1Aw@mail.gmail.com>
2016-07-20 11:15   ` Xebar Saram
2016-07-20 17:20     ` Charles C. Berry [this message]
2016-07-20 17:29       ` Xebar Saram
2016-07-20 17:42         ` Charles C. Berry
2016-07-20 18:00           ` Xebar Saram
2016-07-21  6:48             ` Xebar Saram
2016-07-21 16:27               ` Charles C. Berry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.OSX.2.20.1607200956080.624@charles-berrys-macbook.local \
    --to=ccberry@ucsd.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=phil.hudson@iname.com \
    --cc=zeltakc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.