##// END OF EJS Templates
revert PR #1659...
MinRK -
Show More
@@ -623,8 +623,11 b' var IPython = (function (IPython) {'
623 623 if (json.stream == undefined){
624 624 json.stream = 'stdout';
625 625 }
626
627 var text = utils.fixConsole(json.text);
626 if (!utils.fixConsole(json.text)){
627 // fixConsole gives nothing (empty string, \r, etc.)
628 // so don't append any elements, which might add undesirable space
629 return;
630 }
628 631 var subclass = "output_"+json.stream;
629 632 if (this.outputs.length > 0){
630 633 // have at least one output to consider
@@ -633,22 +636,15 b' var IPython = (function (IPython) {'
633 636 // latest output was in the same stream,
634 637 // so append directly into its pre tag
635 638 // escape ANSI & HTML specials:
636 pre = this.element.find('div.'+subclass).last().find('pre');
637 text = utils.fixCarriageReturn(pre.text() + text);
638 pre.text(text);
639 var text = utils.fixConsole(json.text);
640 this.element.find('div.'+subclass).last().find('pre').append(text);
639 641 return;
640 642 }
641 643 }
642
643 if (!text.replace("\r", "")) {
644 // text is nothing (empty string, \r, etc.)
645 // so don't append any elements, which might add undesirable space
646 return;
647 }
648
644
649 645 // If we got here, attach a new div
650 646 var toinsert = this.create_output_area();
651 this.append_text(text, toinsert, "output_stream "+subclass);
647 this.append_text(json.text, toinsert, "output_stream "+subclass);
652 648 this.element.find('div.output').append(toinsert);
653 649 };
654 650
@@ -706,7 +702,6 b' var IPython = (function (IPython) {'
706 702 var toinsert = $("<div/>").addClass("box_flex1 output_subarea output_text");
707 703 // escape ANSI & HTML specials in plaintext:
708 704 data = utils.fixConsole(data);
709 data = utils.fixCarriageReturn(data);
710 705 if (extra_class){
711 706 toinsert.addClass(extra_class);
712 707 }
@@ -89,9 +89,9 b' var IPython = (function (IPython) {'
89 89
90 90 Pager.prototype.append_text = function (text) {
91 91 var toinsert = $("<div/>").addClass("output_area output_stream");
92 toinsert.append($('<pre/>').html(utils.fixCarriageReturn(utils.fixConsole(text))));
92 toinsert.append($('<pre/>').html(utils.fixConsole(text)));
93 93 this.pager_element.append(toinsert);
94 };
94 };
95 95
96 96
97 97 IPython.Pager = Pager;
@@ -47,7 +47,7 b' IPython.utils = (function (IPython) {'
47 47 "37":"ansigrey", "01":"ansibold"
48 48 };
49 49
50 // Transform ANSI color escape codes into HTML <span> tags with css
50 // Transform ANI color escape codes into HTML <span> tags with css
51 51 // classes listed in the above ansi_colormap object. The actual color used
52 52 // are set in the css file.
53 53 function fixConsole(txt) {
@@ -57,6 +57,8 b' IPython.utils = (function (IPython) {'
57 57 var cmds = [];
58 58 var opener = "";
59 59 var closer = "";
60 // \r does nothing, so shouldn't be included
61 txt = txt.replace('\r', '');
60 62 while (re.test(txt)) {
61 63 var cmds = txt.match(re)[1].split(";");
62 64 closer = opened?"</span>":"";
@@ -72,16 +74,6 b' IPython.utils = (function (IPython) {'
72 74 return txt;
73 75 }
74 76
75 // Remove chunks that should be overridden by the effect of
76 // carriage return characters
77 function fixCarriageReturn(txt) {
78 tmp = txt;
79 do {
80 txt = tmp;
81 tmp = txt.replace(/^.*\r/gm, '');
82 } while (tmp.length < txt.length);
83 return txt;
84 }
85 77
86 78 grow = function(element) {
87 79 // Grow the cell by hand. This is used upon reloading from JSON, when the
@@ -103,8 +95,7 b' IPython.utils = (function (IPython) {'
103 95 return {
104 96 uuid : uuid,
105 97 fixConsole : fixConsole,
106 grow : grow,
107 fixCarriageReturn : fixCarriageReturn
98 grow : grow
108 99 };
109 100
110 101 }(IPython));
General Comments 0
You need to be logged in to leave comments. Login now