Document changes to ob-ein. Error when no :image header specified.

ob-ein will alert the user if they are generating an image in the ob-ein source
block and no :image header has been supplied. Added some documentation for good
measure, though people will probably still get tripped up by this.
This commit is contained in:
John Miller 2017-01-18 10:31:30 -06:00
parent 7e222f3ebf
commit 5c945a174f
2 changed files with 20 additions and 0 deletions

View file

@ -369,6 +369,22 @@ argument. The format for the session argument is
sys.version
#+END_SRC
If your code block generates an image, like from an matplotlib plot, then
specify the file to save the image to using the `:image` argument as in the
example below:
.. code:: python
#BEGIN_SRC ein :session 8888/Untitled.ipynb
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
x = np.linspace(0, 1, 100)
y = np.random.rand(100,1)
plt.plot(x,y)
#+END_SRC
You can also link to an IPython notebook from org-mode_ files.
1. Call org-mode function :el:symbol:`org-store-link`

View file

@ -66,10 +66,14 @@
(case key
((svg image/svg)
(progn
(when (null file)
(error "Please specify an :image header argument when generating images."))
(ein:write-base64-decoded-image value file)
(format "[[file:%s]]" file)))
((png image/png jpeg image/jpeg)
(progn
(when (null file)
(error "Please specify an :image header argument when generating images."))
(ein:write-base64-image value file)
(format "[[file:%s]]" file)))
(t (plist-get json type)))))