From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xebar Saram Subject: Re: convert rmarkdown (rmd) files to orgmode? Date: Wed, 20 Jul 2016 20:29:32 +0300 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113e96026e9bd30538148b81 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPvJP-00008k-52 for emacs-orgmode@gnu.org; Wed, 20 Jul 2016 13:29:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPvJN-0003r0-TQ for emacs-orgmode@gnu.org; Wed, 20 Jul 2016 13:29:35 -0400 Received: from mail-yw0-x232.google.com ([2607:f8b0:4002:c05::232]:34406) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPvJN-0003qw-OE for emacs-orgmode@gnu.org; Wed, 20 Jul 2016 13:29:33 -0400 Received: by mail-yw0-x232.google.com with SMTP id z8so29813966ywa.1 for ; Wed, 20 Jul 2016 10:29:33 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: "Charles C. Berry" Cc: org mode , Philip Hudson --001a113e96026e9bd30538148b81 Content-Type: text/plain; charset=UTF-8 thx for the tips! when i try to run the source block : #+BEGIN_SRC emacs-lisp :results silent (replace-regexp "^=[{]r \\([^}]*\\)[}]\\(.*\\)=$" "#+name: \\1 ,#+begin_src R \\2 ,#+end_src") #+END_SRC i just get a nil in the message area. what am i missing? thx Z On Wed, Jul 20, 2016 at 8:20 PM, Charles C. Berry wrote: > 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 > > --001a113e96026e9bd30538148b81 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
thx for the tips!

when i try to run the= source block :

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

#+EN= D_SRC

i just get a nil in the message area. = what am i missing?

thx

Z<= /div>

On Wed= , Jul 20, 2016 at 8:20 PM, Charles C. Berry <ccberry@ucsd.edu> wrote:
On Wed, 20 Ju= l 2016, Xebar Saram wrote:

thx phil

the Rmd format is actually quite different than md so that conversion didnt=
go well


I tried this

=C2=A0 =C2=A0 =C2=A0 =C2=A0 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
=C2=A0 (replace-regexp "^=3D[{]r \\([^}]*\\)[}]\\(.*\\)=3D$"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "#+name= : \\1
=C2=A0 ,#+begin_src R
=C2=A0 \\2
=C2=A0 ,#+end_src")

#+END_SRC

When I execute that code block, all the converted code chunks become src bl= ocks.

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 l= ike 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


--001a113e96026e9bd30538148b81--