From e5ed972467fbfbf9d40aec108cdc227162635179 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Wed, 16 Sep 2015 13:46:18 -0700 Subject: [PATCH 1/2] Strip more ANSI escape sequence. `?` can be found in ANSI escape sequence. ( `[?25l` hide cursor, `[25k`show cursor) Closes #95 --- notebook/static/base/js/utils.js | 2 +- notebook/tests/base/utils.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/notebook/static/base/js/utils.js b/notebook/static/base/js/utils.js index b07c73e36..7c6f482c4 100644 --- a/notebook/static/base/js/utils.js +++ b/notebook/static/base/js/utils.js @@ -348,7 +348,7 @@ define([ // 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; + var ignored_re = /(?=(\033\[[?\d;=]*[a-ln-zA-Z]{1}))\1(?!m)/g; txt = txt.replace(ignored_re, ""); // color ansi codes diff --git a/notebook/tests/base/utils.js b/notebook/tests/base/utils.js index 624983ba2..3000f823a 100644 --- a/notebook/tests/base/utils.js +++ b/notebook/tests/base/utils.js @@ -5,6 +5,7 @@ casper.notebook_test(function () { "\033[0m[\033[33mwarn\033[0m] \033[0m https://some/url/to/a/file.ext\033[0m", "\033[0m[\033[31merror\033[0m] \033[0m\033[0m", "\033[0m[\033[31merror\033[0m] \033[0m\teven more text\033[0m", + "[?25hBuilding wheels for collected packages: scipy", "\033[0m[\033[31merror\033[0m] \033[0m\t\tand more more text\033[0m"].join("\n"); var output = [ @@ -13,6 +14,7 @@ casper.notebook_test(function () { "[warn] https://some/url/to/a/file.ext", "[error] ", "[error] \teven more text", + "Building wheels for collected packages: scipy", "[error] \t\tand more more text"].join("\n"); var result = this.evaluate(function (input) { From a9576ba96e37b26a935daa6cc31c85e21dac8ece Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Wed, 16 Sep 2015 14:51:31 -0700 Subject: [PATCH 2/2] forgot octal prefix --- notebook/tests/base/utils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notebook/tests/base/utils.js b/notebook/tests/base/utils.js index 3000f823a..3c20a1f87 100644 --- a/notebook/tests/base/utils.js +++ b/notebook/tests/base/utils.js @@ -1,11 +1,12 @@ casper.notebook_test(function () { + // Note, \033 is the octal notation of \u001b var input = [ "\033[0m[\033[0minfo\033[0m] \033[0mtext\033[0m", "\033[0m[\033[33mwarn\033[0m] \033[0m\tmore text\033[0m", "\033[0m[\033[33mwarn\033[0m] \033[0m https://some/url/to/a/file.ext\033[0m", "\033[0m[\033[31merror\033[0m] \033[0m\033[0m", "\033[0m[\033[31merror\033[0m] \033[0m\teven more text\033[0m", - "[?25hBuilding wheels for collected packages: scipy", + "\u001b[?25hBuilding wheels for collected packages: scipy", "\033[0m[\033[31merror\033[0m] \033[0m\t\tand more more text\033[0m"].join("\n"); var output = [