diff --git a/IPython/html/static/base/js/utils.js b/IPython/html/static/base/js/utils.js
index aa85d17..4a83d56 100644
--- a/IPython/html/static/base/js/utils.js
+++ b/IPython/html/static/base/js/utils.js
@@ -284,27 +284,36 @@ define([
function ansispan(str) {
// ansispan function adapted from github.com/mmalecki/ansispan (MIT License)
// regular ansi escapes (using the table above)
+ var is_open = false
return str.replace(/\033\[(0?[01]|22|39)?([;\d]+)?m/g, function(match, prefix, pattern) {
if (!pattern) {
// [(01|22|39|)m close spans
- return "";
- }
- // consume sequence of color escapes
- var numbers = pattern.match(/\d+/g);
- var attrs = {};
- while (numbers.length > 0) {
- _process_numbers(attrs, numbers);
- }
-
- var span = "";
+ } else {
+ return "";
+ }
+ } else {
+ is_open = true;
+
+ // consume sequence of color escapes
+ var numbers = pattern.match(/\d+/g);
+ var attrs = {};
+ while (numbers.length > 0) {
+ _process_numbers(attrs, numbers);
+ }
+
+ var span = "";
}
- return span + ">";
});
};
-
+
// Transform ANSI color escape codes into HTML tags with css
// classes listed in the above ansi_colormap object. The actual color used
// are set in the css file.