From 5f5ac70660bf25e9dd508b13058e501268036fdb Mon Sep 17 00:00:00 2001 From: Jack Feser Date: Thu, 4 Apr 2013 21:32:34 -0500 Subject: [PATCH] Strip non color related ANSI escape sequences from notebook output. This fixes issue #2385. --- IPython/frontend/html/notebook/static/js/utils.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/IPython/frontend/html/notebook/static/js/utils.js b/IPython/frontend/html/notebook/static/js/utils.js index 559f4ea2e..a2b364b82 100644 --- a/IPython/frontend/html/notebook/static/js/utils.js +++ b/IPython/frontend/html/notebook/static/js/utils.js @@ -174,6 +174,12 @@ IPython.utils = (function (IPython) { var cmds = []; var opener = ""; var closer = ""; + + // Strip all ANSI codes that are not color related. Matches + // all ANSI codes that do not end with "m". + var ignored_re = /(?=(\033\[[\d;=]*[a-ln-zA-Z]{1}))\1(?!m)/g; + txt = txt.replace(ignored_re, ""); + while (re.test(txt)) { var cmds = txt.match(re)[1].split(";"); closer = opened?"":"";