Show More
@@ -286,6 +286,30 b' var IPython = (function (IPython) {' | |||||
286 | return remapped; |
|
286 | return remapped; | |
287 | }; |
|
287 | }; | |
288 |
|
288 | |||
|
289 | ||||
|
290 | OutputArea.output_types = [ | |||
|
291 | 'application/javascript', | |||
|
292 | 'text/html', | |||
|
293 | 'text/latex', | |||
|
294 | 'image/svg+xml', | |||
|
295 | 'image/png', | |||
|
296 | 'image/jpeg', | |||
|
297 | 'text/plain' | |||
|
298 | ]; | |||
|
299 | ||||
|
300 | OutputArea.prototype.validate_output = function (json) { | |||
|
301 | // scrub invalid outputs | |||
|
302 | // TODO: right now everything is a string, but JSON really shouldn't be. | |||
|
303 | // nbformat 4 will fix that. | |||
|
304 | $.map(OutputArea.output_types, function(key){ | |||
|
305 | if (json[key] !== undefined && typeof json[key] !== 'string') { | |||
|
306 | console.log("Invalid type for " + key, json[key]); | |||
|
307 | delete json[key]; | |||
|
308 | } | |||
|
309 | }); | |||
|
310 | return json; | |||
|
311 | }; | |||
|
312 | ||||
289 | OutputArea.prototype.append_output = function (json) { |
|
313 | OutputArea.prototype.append_output = function (json) { | |
290 | this.expand(); |
|
314 | this.expand(); | |
291 | // Clear the output if clear is queued. |
|
315 | // Clear the output if clear is queued. | |
@@ -294,6 +318,9 b' var IPython = (function (IPython) {' | |||||
294 | this.clear_output(false); |
|
318 | this.clear_output(false); | |
295 | needs_height_reset = true; |
|
319 | needs_height_reset = true; | |
296 | } |
|
320 | } | |
|
321 | ||||
|
322 | // validate output data types | |||
|
323 | json = this.validate_output(json); | |||
297 |
|
324 | |||
298 | if (json.output_type === 'pyout') { |
|
325 | if (json.output_type === 'pyout') { | |
299 | this.append_pyout(json); |
|
326 | this.append_pyout(json); |
General Comments 0
You need to be logged in to leave comments.
Login now