##// END OF EJS Templates
coalesce stream output in the notebook...
MinRK -
Show More
@@ -280,12 +280,15 b' define(['
280 280 needs_height_reset = true;
281 281 }
282 282
283 var record_output = true;
284
283 285 if (json.output_type === 'execute_result') {
284 286 this.append_execute_result(json);
285 287 } else if (json.output_type === 'error') {
286 288 this.append_error(json);
287 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 294 // We must release the animation fixed height in a callback since Gecko
@@ -306,7 +309,9 b' define(['
306 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 462 // latest output was in the same stream,
458 463 // so append directly into its pre tag
459 464 // escape ANSI & HTML specials:
465 last.text = utils.fixCarriageReturn(last.text + json.text);
460 466 var pre = this.element.find('div.'+subclass).last().find('pre');
461 var html = utils.fixCarriageReturn(
462 pre.html() + utils.fixConsole(text));
467 var html = utils.fixConsole(last.text);
463 468 // The only user content injected with this HTML call is
464 469 // escaped by the fixConsole() method.
465 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 477 if (!text.replace("\r", "")) {
471 478 // text is nothing (empty string, \r, etc.)
472 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 484 // If we got here, attach a new div
@@ -480,6 +488,7 b' define(['
480 488 append_text.apply(this, [text, {}, toinsert]).addClass("output_stream " + subclass);
481 489 }
482 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