Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render faint text using css brightness filter #44

Merged
merged 1 commit into from Oct 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ansi_to_html.js
Expand Up @@ -123,6 +123,7 @@ function handleDisplay(stack, code, options) {
'-1': () => '<br/>',
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'),
Expand Down
9 changes: 8 additions & 1 deletion test/ansi_to_html.js
Expand Up @@ -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: <span style="filter:brightness(0.7)">stuff</span>';

return test(text, result, done);
});

it('handles resets', function (done) {
const text = '\x1b[1mthis is bold\x1b[0m, but this isn\'t';
const result = '<b>this is bold</b>, but this isn\'t';
Expand Down Expand Up @@ -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 = '<span style="text-decoration:overline">Hello World</span>';
Expand Down