From 7aaa3a9203b28aac43427fdab5bdf592aeaf1496 Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Mon, 16 Dec 2013 16:08:33 -0800 Subject: [PATCH] convert short names like 'png' to mimetype names --- IPython/html/static/notebook/js/outputarea.js | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/IPython/html/static/notebook/js/outputarea.js b/IPython/html/static/notebook/js/outputarea.js index 3510332a1..a0641391e 100644 --- a/IPython/html/static/notebook/js/outputarea.js +++ b/IPython/html/static/notebook/js/outputarea.js @@ -288,6 +288,18 @@ var IPython = (function (IPython) { } return json; }; + + OutputArea.prototype.convert_mime_types_r = function (data) { + for (var key in data) { + var mkey = OutputArea.mime_map_r[key] || key; + if (mkey !== key) { + // move short keys to mime-type keys + data[mkey] = data[key]; + delete data[key]; + } + } + return data; + }; OutputArea.prototype.append_output = function (json, dynamic) { @@ -738,10 +750,20 @@ var IPython = (function (IPython) { // JSON serialization OutputArea.prototype.fromJSON = function (outputs) { + // add here the mapping of short key to mime type + // TODO: remove this when we update to nbformat 4 var len = outputs.length; for (var i=0; i