##// END OF EJS Templates
coalesce stream output in the notebook...
MinRK -
Show More
@@ -280,12 +280,15 b' define(['
280 needs_height_reset = true;
280 needs_height_reset = true;
281 }
281 }
282
282
283 var record_output = true;
284
283 if (json.output_type === 'execute_result') {
285 if (json.output_type === 'execute_result') {
284 this.append_execute_result(json);
286 this.append_execute_result(json);
285 } else if (json.output_type === 'error') {
287 } else if (json.output_type === 'error') {
286 this.append_error(json);
288 this.append_error(json);
287 } else if (json.output_type === 'stream') {
289 } else if (json.output_type === 'stream') {
288 this.append_stream(json);
290 // append_stream might have merged the output with earlier stream output
291 record_output = this.append_stream(json);
289 }
292 }
290
293
291 // We must release the animation fixed height in a callback since Gecko
294 // We must release the animation fixed height in a callback since Gecko
@@ -306,7 +309,9 b' define(['
306 handle_appended();
309 handle_appended();
307 }
310 }
308
311
309 this.outputs.push(json);
312 if (record_output) {
313 this.outputs.push(json);
314 }
310 };
315 };
311
316
312
317
@@ -457,20 +462,23 b' define(['
457 // latest output was in the same stream,
462 // latest output was in the same stream,
458 // so append directly into its pre tag
463 // so append directly into its pre tag
459 // escape ANSI & HTML specials:
464 // escape ANSI & HTML specials:
465 last.text = utils.fixCarriageReturn(last.text + json.text);
460 var pre = this.element.find('div.'+subclass).last().find('pre');
466 var pre = this.element.find('div.'+subclass).last().find('pre');
461 var html = utils.fixCarriageReturn(
467 var html = utils.fixConsole(last.text);
462 pre.html() + utils.fixConsole(text));
463 // The only user content injected with this HTML call is
468 // The only user content injected with this HTML call is
464 // escaped by the fixConsole() method.
469 // escaped by the fixConsole() method.
465 pre.html(html);
470 pre.html(html);
466 return;
471 // return false signals that we merged this output with the previous one,
472 // and the new output shouldn't be recorded.
473 return false;
467 }
474 }
468 }
475 }
469
476
470 if (!text.replace("\r", "")) {
477 if (!text.replace("\r", "")) {
471 // text is nothing (empty string, \r, etc.)
478 // text is nothing (empty string, \r, etc.)
472 // so don't append any elements, which might add undesirable space
479 // so don't append any elements, which might add undesirable space
473 return;
480 // return true to indicate the output should be recorded.
481 return true;
474 }
482 }
475
483
476 // If we got here, attach a new div
484 // If we got here, attach a new div
@@ -480,6 +488,7 b' define(['
480 append_text.apply(this, [text, {}, toinsert]).addClass("output_stream " + subclass);
488 append_text.apply(this, [text, {}, toinsert]).addClass("output_stream " + subclass);
481 }
489 }
482 this._safe_append(toinsert);
490 this._safe_append(toinsert);
491 return true;
483 };
492 };
484
493
485
494
General Comments 0
You need to be logged in to leave comments. Login now