executablebooks / MyST-NB

Parse and execute ipynb files in Sphinx
https://myst-nb.readthedocs.io
BSD 3-Clause "New" or "Revised" License
205 stars 83 forks source link

mime type application/json not supported #464

Open paugier opened 1 year ago

paugier commented 1 year ago

I have some cells generating as the first output json data (mime type: application/json). I get the following warning:

WARNING: skipping unknown output mime type: application/json [mystnb.unknown_mime_type]

which comes from https://github.com/executablebooks/MyST-NB/blob/master/myst_nb/core/render.py#L746

First it would be great if the same kind of nicely displayed json as in jupyter would be displayed in the documentation.

Second, I'd like to be able to silent this warning, which is not interesting for us (and we try to keep the documentation build with zero warning).

aeisenbarth commented 3 months ago

I am also very much interested in this! And it is quite disappointing that this seemingly standard IPython output type which works in Jupyter goes away when using myst-nb/nbsphinx.

Further investigation shows that it is not necessarily Myst-NB's fault:

So although it seems to be a standard output type, it is left to HTML renderers to implement the representation. JupyterLab is able to handle the missing "text/html" and just generates it from the JSON.

I think we should look whether we can patch whatever executes the notebooks to store "text/html" (not necessarily dynamic with javascript). Does this make sense? And I'm not sure in which project this is, IPython or jupterlab?

aeisenbarth commented 2 months ago

I created this plugin: https://pypi.org/project/myst-nb-json/ Just add myst-nb-json to your dependencies and the built HTML will show JSON similar to Jupyter.