From 43ed0483a8ba5075e925f5d1ff3483fcce01af1b Mon Sep 17 00:00:00 2001 From: Rob Burns Date: Sat, 20 Oct 2018 14:32:55 +0700 Subject: [PATCH] render faint text using css brightness filter --- src/ansi_to_html.js | 1 + test/ansi_to_html.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ansi_to_html.js b/src/ansi_to_html.js index 48708db..69b8a2c 100644 --- a/src/ansi_to_html.js +++ b/src/ansi_to_html.js @@ -123,6 +123,7 @@ function handleDisplay(stack, code, options) { '-1': () => '
', 0: () => stack.length && resetStyles(stack), 1: () => pushTag(stack, 'b'), + 2: () => pushStyle(stack, 'filter:brightness(0.7)'), 3: () => pushTag(stack, 'i'), 4: () => pushTag(stack, 'u'), 8: () => pushStyle(stack, 'display:none'), diff --git a/test/ansi_to_html.js b/test/ansi_to_html.js index 8da91fd..7bb19d0 100644 --- a/test/ansi_to_html.js +++ b/test/ansi_to_html.js @@ -99,6 +99,13 @@ describe('ansi to html', function () { return test(text, result, done); }); + it('renders faint text', function(done) { + const text = 'faint: \x1b[2mstuff'; + const result = 'faint: stuff'; + + return test(text, result, done); + }); + it('handles resets', function (done) { const text = '\x1b[1mthis is bold\x1b[0m, but this isn\'t'; const result = 'this is bold, but this isn\'t'; @@ -287,7 +294,7 @@ describe('ansi to html', function () { return test(text, result, done); }); - + it('renders overline', function (done) { const text = '\x1b[53mHello World'; const result = 'Hello World';