emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to use org src functions in other major mode (markdow)?
@ 2013-12-29  8:02 Shuguang Sun
  2014-01-01  2:58 ` Charles Berry
  0 siblings, 1 reply; 2+ messages in thread
From: Shuguang Sun @ 2013-12-29  8:02 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: 曙光

[-- Attachment #1: Type: text/plain, Size: 360 bytes --]

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

```r
x <- 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

[-- Attachment #2: Type: text/html, Size: 494 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to use org src functions in other major mode (markdow)?
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Charles Berry @ 2014-01-01  2:58 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-01-01  2:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

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).