diff --git a/notebook/static/base/js/utils.js b/notebook/static/base/js/utils.js
index 0c32d83e02e..d59a893c20a 100644
--- a/notebook/static/base/js/utils.js
+++ b/notebook/static/base/js/utils.js
@@ -238,6 +238,57 @@ define([
"ansi-white-intense",
];
+ function _pushColoredChunk(chunk, fg, bg, bold, underline, inverse, out) {
+ if (chunk) {
+ var classes = [];
+ var styles = [];
+
+ if (bold && typeof fg === "number" && 0 <= fg && fg < 8) {
+ fg += 8; // Bold text uses "intense" colors
+ }
+ if (inverse) {
+ if (fg.length === 0) { fg = [0, 0, 0]; }
+ if (bg.length === 0) { bg = [255, 255, 255]; }
+ [fg, bg] = [bg, fg];
+ }
+
+ if (typeof fg === "number") {
+ classes.push(_ANSI_COLORS[fg] + "-fg");
+ } else if (fg.length) {
+ styles.push("color: rgb(" + fg + ")");
+ }
+
+ if (typeof bg === "number") {
+ classes.push(_ANSI_COLORS[bg] + "-bg");
+ } else if (bg.length) {
+ styles.push("background-color: rgb(" + bg + ")");
+ }
+
+ if (bold) {
+ classes.push("ansi-bold");
+ }
+
+ if (underline) {
+ classes.push("ansi-underline");
+ }
+
+ if (classes.length || styles.length) {
+ out.push("");
+ out.push(chunk);
+ out.push("");
+ } else {
+ out.push(chunk);
+ }
+ }
+ }
+
function _getExtendedColors(numbers) {
var r, g, b;
var n = numbers.shift();
@@ -309,54 +360,7 @@ define([
// Ignored: Not a color code
}
var chunk = str.substring(start, match.index);
- if (chunk) {
- var classes = [];
- var styles = [];
-
- if (typeof fg === "number") {
- if (bold && fg < 8) {
- // Bold text uses "intense" colors
- classes.push(_ANSI_COLORS[fg + 8] + "-fg");
- } else {
- classes.push(_ANSI_COLORS[fg] + "-fg");
- }
- } else if (fg.length) {
- styles.push("color: rgb(" + fg + ")");
- }
-
- if (typeof bg === "number") {
- classes.push(_ANSI_COLORS[bg] + "-bg");
- } else if (bg.length) {
- styles.push("background-color: rgb(" + bg + ")");
- }
-
- if (bold) {
- classes.push("ansi-bold");
- }
-
- if (underline) {
- classes.push("ansi-underline");
- }
-
- if (inverse) {
- classes.push("ansi-inverse");
- }
-
- if (classes.length || styles.length) {
- out.push("");
- out.push(chunk);
- out.push("");
- } else {
- out.push(chunk);
- }
- }
+ _pushColoredChunk(chunk, fg, bg, bold, underline, inverse, out);
start = ansi_re.lastIndex;
while (numbers.length) {
diff --git a/notebook/static/notebook/less/ansicolors.less b/notebook/static/notebook/less/ansicolors.less
index 1e6efac513a..af7477ec433 100644
--- a/notebook/static/notebook/less/ansicolors.less
+++ b/notebook/static/notebook/less/ansicolors.less
@@ -22,11 +22,11 @@
.ansi-bold { font-weight: bold; }
.ansi-underline { text-decoration: underline; }
-.ansi-inverse { outline: 0.5px dotted; }
/* The following styles are deprecated an will be removed in a future version */
.ansibold {font-weight: bold;}
+.ansi-inverse { outline: 0.5px dotted; }
/* use dark versions for foreground, to improve visibility */
.ansiblack {color: black;}