##// END OF EJS Templates
support display_pub metadata in js frontend
MinRK -
Show More
@@ -178,9 +178,11 b' var IPython = (function (IPython) {'
178 178 json.stream = content.name;
179 179 } else if (msg_type === "display_data") {
180 180 json = this.convert_mime_types(json, content.data);
181 json.metadata = this.convert_mime_types({}, content.metadata);
181 182 } else if (msg_type === "pyout") {
182 183 json.prompt_number = content.execution_count;
183 184 json = this.convert_mime_types(json, content.data);
185 json.metadata = this.convert_mime_types({}, content.metadata);
184 186 } else if (msg_type === "pyerr") {
185 187 json.ename = content.ename;
186 188 json.evalue = content.evalue;
@@ -273,7 +275,7 b' var IPython = (function (IPython) {'
273 275 }
274 276 s = s + '\n';
275 277 var toinsert = this.create_output_area();
276 this.append_text(s, toinsert);
278 this.append_text(s, {}, toinsert);
277 279 this.element.append(toinsert);
278 280 }
279 281 };
@@ -310,7 +312,7 b' var IPython = (function (IPython) {'
310 312
311 313 // If we got here, attach a new div
312 314 var toinsert = this.create_output_area();
313 this.append_text(text, toinsert, "output_stream "+subclass);
315 this.append_text(text, {}, toinsert, "output_stream "+subclass);
314 316 this.element.append(toinsert);
315 317 };
316 318
@@ -331,12 +333,16 b' var IPython = (function (IPython) {'
331 333 for(var type_i in OutputArea.display_order){
332 334 var type = OutputArea.display_order[type_i];
333 335 if(json[type] != undefined ){
336 var md = {};
337 if (json.metadata && json.metadata[type]) {
338 md = json.metadata[type];
339 };
334 340 if(type == 'javascript'){
335 341 if (dynamic) {
336 this.append_javascript(json.javascript, element, dynamic);
342 this.append_javascript(json.javascript, md, element, dynamic);
337 343 }
338 344 } else {
339 this['append_'+type](json[type], element);
345 this['append_'+type](json[type], md, element);
340 346 }
341 347 return;
342 348 }
@@ -344,14 +350,14 b' var IPython = (function (IPython) {'
344 350 };
345 351
346 352
347 OutputArea.prototype.append_html = function (html, element) {
353 OutputArea.prototype.append_html = function (html, md, element) {
348 354 var toinsert = $("<div/>").addClass("output_subarea output_html rendered_html");
349 355 toinsert.append(html);
350 356 element.append(toinsert);
351 357 };
352 358
353 359
354 OutputArea.prototype.append_javascript = function (js, container) {
360 OutputArea.prototype.append_javascript = function (js, md, container) {
355 361 // We just eval the JS code, element appears in the local scope.
356 362 var element = $("<div/>").addClass("output_subarea");
357 363 container.append(element);
@@ -375,7 +381,7 b' var IPython = (function (IPython) {'
375 381 };
376 382
377 383
378 OutputArea.prototype.append_text = function (data, element, extra_class) {
384 OutputArea.prototype.append_text = function (data, md, element, extra_class) {
379 385 var toinsert = $("<div/>").addClass("output_subarea output_text");
380 386 // escape ANSI & HTML specials in plaintext:
381 387 data = utils.fixConsole(data);
@@ -389,7 +395,7 b' var IPython = (function (IPython) {'
389 395 };
390 396
391 397
392 OutputArea.prototype.append_svg = function (svg, element) {
398 OutputArea.prototype.append_svg = function (svg, md, element) {
393 399 var toinsert = $("<div/>").addClass("output_subarea output_svg");
394 400 toinsert.append(svg);
395 401 element.append(toinsert);
@@ -423,25 +429,37 b' var IPython = (function (IPython) {'
423 429 };
424 430
425 431
426 OutputArea.prototype.append_png = function (png, element) {
432 OutputArea.prototype.append_png = function (png, md, element) {
427 433 var toinsert = $("<div/>").addClass("output_subarea output_png");
428 434 var img = $("<img/>").attr('src','data:image/png;base64,'+png);
435 if (md['height']) {
436 img.attr('height', md['height']);
437 }
438 if (md['width']) {
439 img.attr('width', md['width']);
440 }
429 441 this._dblclick_to_reset_size(img);
430 442 toinsert.append(img);
431 443 element.append(toinsert);
432 444 };
433 445
434 446
435 OutputArea.prototype.append_jpeg = function (jpeg, element) {
447 OutputArea.prototype.append_jpeg = function (jpeg, md, element) {
436 448 var toinsert = $("<div/>").addClass("output_subarea output_jpeg");
437 449 var img = $("<img/>").attr('src','data:image/jpeg;base64,'+jpeg);
450 if (md['height']) {
451 img.attr('height', md['height']);
452 }
453 if (md['width']) {
454 img.attr('width', md['width']);
455 }
438 456 this._dblclick_to_reset_size(img);
439 457 toinsert.append(img);
440 458 element.append(toinsert);
441 459 };
442 460
443 461
444 OutputArea.prototype.append_latex = function (latex, element) {
462 OutputArea.prototype.append_latex = function (latex, md, element) {
445 463 // This method cannot do the typesetting because the latex first has to
446 464 // be on the page.
447 465 var toinsert = $("<div/>").addClass("output_subarea output_latex");
General Comments 0
You need to be logged in to leave comments. Login now