jkitchin / ox-ipynb

org-mode exporter to Jupyter notebooks
175 stars 40 forks source link

jupyter-python source blacks are exported as markdown #53

Closed uliw closed 2 months ago

uliw commented 2 months ago

Exporting the following to ipynb

#+BEGIN_SRC jupyter-python
def diff_coeff(T, m0, m1, phi):
    """ Calculate the diffusion coefficient in m^2/s

    T: temperature in C, float or array
    phi: porosity in percent, float, or array
    m0, m1: parameter as from table 4.8, Chapter 4 in Boudreau 1996
    """

    return (m0 + m1 * T) * 1e-10 / (1 - np.log(phi**2))
#+END_SRC

This results in a markdown cell rather than code. Replacing jupyter-python with ipython works as expected. This is with ox-ipynb ef9ba54, and org release_9.7.10.

It's possible that I borked my config files, but as far as I can see, everything looks ok.

jkitchin commented 2 months ago

hm. I am not able to reproduce that. Is that literally all that is in your org file when you export it? no src blocks of any kind above it?

uliw commented 2 months ago

Got it! My file-template specified OX-IPYNB-LANGUAGE: ipython (I no longer recall why). Removing this, solved the problem. Thx!

jkitchin commented 2 months ago

that is something you do when there is a non-python src block first (the first one is used to get the language). I guess by specifying ipython, it would see that the jupyter-python block is another language, and just make it markdown.