emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] How to use org src functions in other major mode (markdow)?


From: Charles Berry
Subject: Re: [O] How to use org src functions in other major mode (markdow)?
Date: Wed, 1 Jan 2014 02:58:49 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]