From cb247590c7607ef544dfba10fb2eeacea37b6daf Mon Sep 17 00:00:00 2001 From: Tony Cebzanov Date: Mon, 13 Feb 2017 23:51:32 -0500 Subject: [PATCH 1/3] Support ANSI underline and inverse properties. * Parse underline and inverse in ANSI escape codes * Add CSS classes for same, using a subtle outline for inverse --- notebook/static/base/js/utils.js | 18 ++++++++++++++++++ notebook/static/notebook/less/ansicolors.less | 2 ++ 2 files changed, 20 insertions(+) diff --git a/notebook/static/base/js/utils.js b/notebook/static/base/js/utils.js index 93df51748c..58d30299cc 100644 --- a/notebook/static/base/js/utils.js +++ b/notebook/static/base/js/utils.js @@ -282,6 +282,8 @@ define([ var fg = []; var bg = []; var bold = false; + var underline = false; + var inverse = false; var match; var out = []; var numbers = []; @@ -330,6 +332,14 @@ define([ classes.push("ansi-bold"); } + if (underline) { + classes.push("ansi-underline"); + } + + if (inverse) { + classes.push("ansi-inverse"); + } + if (classes.length || styles.length) { out.push(" Date: Tue, 14 Feb 2017 00:04:01 -0500 Subject: [PATCH 2/3] Add unerline and inverse to ANSI test notebook. --- tools/tests/ANSI Test.ipynb | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tools/tests/ANSI Test.ipynb b/tools/tests/ANSI Test.ipynb index 98c91ffbbb..e637b101ee 100644 --- a/tools/tests/ANSI Test.ipynb +++ b/tools/tests/ANSI Test.ipynb @@ -30,6 +30,42 @@ "RESET = ESC + \"00m\"" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Bold, underline and inverse text" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "This is normal text\n", + "\n", + "\u001b[01mThis is bold text\n", + "\n", + "\u001b[04mThis is underlined text\n", + "\n", + "\u001b[07mThis is inverse text\n" + ] + } + ], + "source": [ + "print (\"This is normal text\")\n", + "print()\n", + "print (\"{ESC}01mThis is bold text\".format(**locals()))\n", + "print()\n", + "print (\"{ESC}04mThis is underlined text\".format(**locals()))\n", + "print()\n", + "print (\"{ESC}07mThis is inverse text\".format(**locals()))" + ] + }, { "cell_type": "markdown", "metadata": {}, From d3cd8583a27fe132a5304db6aa5fa0ffd47689db Mon Sep 17 00:00:00 2001 From: Tony Cebzanov Date: Tue, 14 Feb 2017 08:56:55 -0500 Subject: [PATCH 3/3] Fix ANSI bold/underline/inverse test to reset after each line. --- tools/tests/ANSI Test.ipynb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/tests/ANSI Test.ipynb b/tools/tests/ANSI Test.ipynb index e637b101ee..c8d193cfe2 100644 --- a/tools/tests/ANSI Test.ipynb +++ b/tools/tests/ANSI Test.ipynb @@ -48,22 +48,22 @@ "text": [ "This is normal text\n", "\n", - "\u001b[01mThis is bold text\n", + "\u001b[01mThis is bold text\u001b[00m\n", "\n", - "\u001b[04mThis is underlined text\n", + "\u001b[04mThis is underlined text\u001b[00m\n", "\n", - "\u001b[07mThis is inverse text\n" + "\u001b[07mThis is inverse text\u001b[00m\n" ] } ], "source": [ "print (\"This is normal text\")\n", "print()\n", - "print (\"{ESC}01mThis is bold text\".format(**locals()))\n", + "print (\"{ESC}01mThis is bold text{RESET}\".format(**locals()))\n", "print()\n", - "print (\"{ESC}04mThis is underlined text\".format(**locals()))\n", + "print (\"{ESC}04mThis is underlined text{RESET}\".format(**locals()))\n", "print()\n", - "print (\"{ESC}07mThis is inverse text\".format(**locals()))" + "print (\"{ESC}07mThis is inverse text{RESET}\".format(**locals()))" ] }, {