chasberry / orgmode-accessories

Add ons for orgmode
78 stars 18 forks source link

quarto export and python code #33

Closed fkgruber closed 1 year ago

fkgruber commented 1 year ago

Hi CCB, I tried the most recent version of ox-ravel and I tried to export the following orgmode file


#+Title:test 
#+BABEL: :exports both :tangle yes  
#+PROPERTY: header-args :exports both :tangle yes :ravel echo=TRUE,eval=TRUE,results='markup',message=FALSE,warning=FALSE,error=FALSE,cache=2, fig.width=10,fig.height=10
#+PROPERTY: header-args:R :session *R*  :tangle yes  :exports both :colnames yes 
#+TODO: TODO(t) | DONE(d) | PARTIALLY(p)  | CANCELED(c)
#+EXPORT_FILE_NAME: 
#+OPTIONS: ^:{}
-----

#+BEGIN_EXPORT yaml
output:
    html_document:
      toc: true
      toc_float: true
      toc_depth: 3
      toc_collapsed: true
      code_fold: show
      theme: flatly
      highlight: tango
#+END_EXPORT
* R Code
#+begin_src R
head(mtcars)
#+end_src
* python code
#+begin_src python
import sys
print("testg")
#+end_src

however the export does not make the python code a code block:


YAML header created by ox-ravel

output: html_document: toc: true toc_float: true toc_depth: 3 toc_collapsed: true code_fold: show theme: flatly highlight: tango title: test


R Code

#| echo: TRUE
#| eval: TRUE
#| results: 'markup'
#| message: FALSE
#| warning: FALSE
#| error: FALSE
#| cache: 2
#| fig.width: 10
#| fig.height: 10
head(mtcars)

python code

import sys
print("testg")

Quarto supports python code so it would be great if python codes are also treated as blocks. FKG

chasberry commented 1 year ago

To use engines other than R you will need to customize org-ravel-engines.

You can do this by editing your init file, setting it as a file variable (see the Emacs manual), or interactively by typing

C-h v org-ravel-engines RET

then clicking the customize link, checking the box by Python, and checking apply or apply and save.

After that the value of org-ravel-engines should be

(("R") ("python" . "engine='python'"))

With that set, the Python code renders as

# python code

```{python}
#| echo: TRUE
#| eval: TRUE
#| results: 'markup'
#| message: FALSE
#| warning: FALSE
#| error: FALSE
#| cache: 2
#| fig.width: 10
#| fig.height: 10
import sys
print("testg")
```
fkgruber commented 1 year ago

perfect! thanks