From e8be6bbe50797d303d6332c7e28b0d36e7603e2b Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Thu, 26 Apr 2012 10:00:16 -0400 Subject: [PATCH] Fix the "test for nothing was streamed" so it doesn't add empty elements -- but only when there wasn't already something there. --- IPython/frontend/html/notebook/static/js/codecell.js | 12 +++++++----- IPython/frontend/html/notebook/static/js/utils.js | 1 - 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/IPython/frontend/html/notebook/static/js/codecell.js b/IPython/frontend/html/notebook/static/js/codecell.js index b133923a8..673e02da6 100644 --- a/IPython/frontend/html/notebook/static/js/codecell.js +++ b/IPython/frontend/html/notebook/static/js/codecell.js @@ -623,12 +623,8 @@ var IPython = (function (IPython) { if (json.stream == undefined){ json.stream = 'stdout'; } + var text = utils.fixConsole(json.text); - if (!text){ - // fixConsole gives nothing (empty string, \r, etc.) - // so don't append any elements, which might add undesirable space - return; - } var subclass = "output_"+json.stream; if (this.outputs.length > 0){ // have at least one output to consider @@ -644,6 +640,12 @@ var IPython = (function (IPython) { } } + if (!text.replace("\r", "")) { + // text is nothing (empty string, \r, etc.) + // so don't append any elements, which might add undesirable space + return; + } + // If we got here, attach a new div var toinsert = this.create_output_area(); this.append_text(text, toinsert, "output_stream "+subclass); diff --git a/IPython/frontend/html/notebook/static/js/utils.js b/IPython/frontend/html/notebook/static/js/utils.js index cc28fbf59..1374dd0b4 100644 --- a/IPython/frontend/html/notebook/static/js/utils.js +++ b/IPython/frontend/html/notebook/static/js/utils.js @@ -57,7 +57,6 @@ IPython.utils = (function (IPython) { var cmds = []; var opener = ""; var closer = ""; - // \r does nothing, so shouldn't be included while (re.test(txt)) { var cmds = txt.match(re)[1].split(";"); closer = opened?"":"";