chasberry / orgmode-accessories

Add ons for orgmode
78 stars 18 forks source link

Different output results in export dispatch using file vs. buffer #32

Closed knightgu closed 1 year ago

knightgu commented 1 year ago

When exporting using ox-ravel, I got different results using [m] Ravel-markdown file and [M] Ravel-markdown buffer in org-export-dispatch. The following gives an example of the difference:

Org file:

#+TITLE: Org Ravel
#+DATE: May 21, 2023
#+OPTIONS: toc:nil author:nil email:nil rmd_yaml:header

#+begin_export yaml
output: html_document
#+end_export

We demonstrate how to use Org for literate programming.

#+name: area-of-a-circle
#+ATTR_RAVEL: echo=TRUE
#+begin_src R
  radius <- 2
  area <- pi * radius^2
#+end_src

The area of a circle with radius src_R{radius} is
\[
  A=\pi(2)^{2}=`r area`.
\]

Markdown file using C-c C-e r m (Ravel-markdown file):

We demonstrate how to use Org for literate programming.

The area of a circle with radius `r radius ` is
$$
  A=\pi(2)^{2}=`r area`.
$$

R markdown buffer using C-c C-e r M (Ravel-markdown buffer):

---
# YAML header created by ox-ravel
title: Org Ravel
date: May 21, 2023
output: html_document
---
We demonstrate how to use Org for literate programming.

```{r}
#| label: area-of-a-circle
#| echo: TRUE
radius <- 2
area <- pi * radius^2

The area of a circle with radius r radius is $$ A=\pi(2)^{2}=r area. $$



Obviously, the `Ravel-markdown buffer` option gives what I want. However, I _do not want to save the buffer to a file every time_ I export the org file. Is there any way to make the `C-c C-e r m` option to save as an R markdown file (that includes the YAML header and many others). Thanks! 
chasberry commented 1 year ago

When I tried your example, the buffer and the file were identical.

Are you sure you didn't accidentally hit C-b for body-only?

If so, try M-: (org-ravel-export-to-file 'ravel-markdown) and see what happens. If it works, try the the export dispatcher again and look carefully to see that Body only: off is shown. If so and you still get the file without the header, my bet is some issue in the export dispatch.

knightgu commented 1 year ago

Running M-: (org-ravel-export-to-file 'ravel-markdown) gives the expected R markdown file. You are right that this is a problem with my org export dispatch. Specifically, the C-c C-e r m keybinding was masked by the org-ref markdown export. I will fix that on my end. Thanks for your help @chasberry.