getnikola / plugins

Extra plugins for Nikola
https://plugins.getnikola.com/
MIT License
59 stars 95 forks source link

[orgmode] support :results file and other raw org output from babel RESULTS block #163

Closed jamescasbon closed 8 years ago

jamescasbon commented 8 years ago

I have a block of code:

#+begin_src python :session :results file
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
#plt.xkcd()
fig=plt.figure(figsize=(6,4))
#plt.plot([1,3,2])
x = np.random.normal(size=50)
sns.distplot(x);
x = np.random.normal(size=100)
sns.distplot(x);
fig.tight_layout()
plt.savefig("../images/myfig.svg")
"../images/myfig.svg" # return this to org-mode
#+end_src

#+RESULTS:
[[file:../images/myfig.svg]]

This displays the image nicely in emacs, but no image when exporting. The image is correct, and if you delete '#+RESULTS:' line nikola will display the image.

The org export should handle this correctly so we can see outputs from babel.

Ideally, it should also allow tables as output (other raw org stuff) as here: http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html

punchagan commented 8 years ago

Thank you for the detailed bug report. I shall look into it.

jamescasbon commented 8 years ago

I tried the ob-ipython plugin. This works for image output. I can't tell the difference in the org file:

python:
#+RESULTS:
[[file:../images/myfig.svg]]

ipython:
#+RESULTS:
[[file:../images/image2.svg]]

but the latter works. I don't know what machinery exists in the org babel export to make this different. I can't get raw output (tables) from ob-ipython.

In other words, this is possibly emacs' problem.

jamescasbon commented 8 years ago

Ok, if you use the ":file ../images/whatever.png" babel option this works fine. You return the image contents from the block.