emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Charles Berry <ccberry@ucsd.edu>
To: emacs-orgmode@gnu.org
Subject: Re: How to use org src functions in other major mode (markdow)?
Date: Wed, 1 Jan 2014 02:58:49 +0000 (UTC)	[thread overview]
Message-ID: <loom.20140101T032837-568@post.gmane.org> (raw)
In-Reply-To: CACspjXcB3LSZv5m5O030bjHMBRK9yLq33tZRCdMzKBAyccfNCg@mail.gmail.com

Shuguang Sun <shuguang <at> gmail.com> writes:


> Dear all,
> Is it possible to use org src functions in other major mode, e.g., 
> markddown-mode?
> In some extend markdown, source code can be put in to block, for example, 
> r-mode for R script```rx <- 1:10```
> Is it possible to highlight the block as org-block "#begion_src R"? How 
> to run org-edit-src-code on such markdown blocks?
> Best Regards,
> Shuguang Sun
> 


Shuguang,


I cannot tell if you want to move org-mode format to *.Rnd or vice versa.

If you work in org-mode, you can export to markdown. 

If you want to go from markdown to org-mode pandoc will do some of the work,
but the org-mode it produces needs further prettying up and the source code
blocks need work.

If you want to use org-mode documents to produce knitr markdown, you can
use ravel.

See https://github.com/chasberry/orgmode-accessories


Here is an example. With a file like this:

--8<---------------cut here---------------start------------->8---

* header 1

#+NAME: markdown-block
#+BEGIN_SRC R
a <- 1
b <- 2
a+b
#+END_SRC

--8<---------------cut here---------------end--------------->8---


Ravel export will produce a  *.Rmd file like this:

--8<---------------cut here---------------start------------->8---
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>b
<li><a href="#sec-1">1. header 1</a></li>
</ul>
</div>
</div>
# header 1

```{r markdown-block}
a <- 1
b <- 2
a+b
```
--8<---------------cut here---------------end--------------->8---


Which knitr will render as *.md like this:


--8<---------------cut here---------------start------------->8---
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#sec-1">1. header 1</a></li>
</ul>
</div>
</div>
# header 1


```r
a <- 1
b <- 2
a + b
```

```
## [1] 3
```

--8<---------------cut here---------------end--------------->8---


HTH,

Chuck

      reply	other threads:[~2014-01-01  2:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-29  8:02 How to use org src functions in other major mode (markdow)? Shuguang Sun
2014-01-01  2:58 ` Charles Berry [this message]

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=loom.20140101T032837-568@post.gmane.org \
    --to=ccberry@ucsd.edu \
    --cc=emacs-orgmode@gnu.org \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).