Merge pull request #3136 from jfeser/8b94eddb4d15ce6f0c98675116d4609bdaaf99d9

Strip useless ANSI escape codes in notebook

ANSI color escape codes get handled specially by the notebook, but other kinds of codes just get printed out. Strip these codes out of the notebook output.

closes #2385
This commit is contained in:
Min RK 2013-04-06 12:14:51 -07:00
commit a4b1bea069

View File

@ -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?"</span>":"";