MyST-NB
MyST-NB copied to clipboard
mime type application/json not supported
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).
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:
- We could implement a rendering plugin for myst-nb. But it is actually not a custom type, rather a standard type from IPython.
- The IPython
JSON
display object only stores the data, but does not provide mime type representations for it. However for other display types like Audio, it implements_repr_html_
. - The representation in JupyterLab comes from a JupyterLab "json-extension".
- Apparently, the execution output is stored in MIME types
"application/json"
and"text/plain"
, but there is no"text/html"
(which is otherwise stored, e.g. for Pandas dataframes).
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?
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.