[IPython-dev] custom mime types in the notebook

Cyrille Rossant cyrille.rossant at gmail.com
Fri Jul 11 12:50:50 EDT 2014


>> What's the best way to do it? Should I create a custom mime type
>> "application/myapp", and extend the notebook to use the JS app for
>> that mime type (if that's even possible)?
>
> I think this opens up a can of worms (certainly relative to the approach
> above).   Going this route, you start to introduce dependencies on how the
> notebook is served, and you make the notebook itself less portable.

Thanks. Could you elaborate on why this approach would make the
notebook less portable?

Let's take an example. Imagine I want to display 3D models in a
notebook using a JS library (like three.js).

Approach 1:

* My cell's output contains data in several mime types: PNG with a
screenshot, and OBJ (for example) with the full 3D model. It seems to
me that the nbformat is designed for this (multiple MIME types
representing the same logical data).

* If the client understands the OBJ mime type, it displays it using three.js.

* Otherwise, it just displays the PNG screenshot.

Approach 2 would be to embed the entire Javascript code in the output
+ <script include jslibraries> (like you suggest, and like mpld3 does,
unless I'm mistaken)

I guess my questions are:

* Which of those two approaches is recommended by IPython devs?
* Is the notebook designed for approach 1 use-case or not?

It seems to me that approach 1 is cleaner while approach 2 looks like
a hack, but that's just my opinion.

Best,
Cyrille



More information about the IPython-dev mailing list