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

inverse color is ignored #59

Open
dylang opened this issue Jul 3, 2019 · 3 comments
Open

inverse color is ignored #59

dylang opened this issue Jul 3, 2019 · 3 comments

Comments

@dylang
Copy link

dylang commented Jul 3, 2019

chalk.inverse('hello')
> '\u001b[7mhello\u001b[27m'

new ansiToHTML().toHtml('\u001b[7mhello\u001b[27m')
> 'hello'

I think swapping fg and bg would be fine for this.

This can be seen when using ansiToHtml with the output from tsc (typescript's compiler) - which uses inverse for the "gutter" which includes the line numbers.

ANSI
Screen Shot 2019-07-01 at 3 44 03 PM

HTML
Screen Shot 2019-07-01 at 3 41 21 PM

@rburns
Copy link
Owner

rburns commented Jul 5, 2019

yeah, that sounds reasonable. Thanks for the example with screenshots.

@MagicLegend
Copy link

I'd be interested in fixing this issue; but what would there need to be changed? @rburns could you point me in the right direction?

@rburns
Copy link
Owner

rburns commented Apr 24, 2020

probably, start with a test as I've made here https://github.com/rburns/ansi-to-html/compare/inverse-color. the first, I think is roughly correct. It tests setting inverse colors. and an empty one, which would test clearing those values. the latter empty test might not be necessary, or may look something like these reset to default color tests https://github.com/rburns/ansi-to-html/blob/inverse-color/test/ansi_to_html.js#L192-L204 but handling a different escape code.

the test string is taken from the original post. I removed the trailing escape code. I'm not certain of it's functionality. it doesn't appear yet, in any of the tests.

implementation would start here https://github.com/rburns/ansi-to-html/blob/inverse-color/src/ansi_to_html.js#L152 adding a case for the inverse escape code, which calls pushForegroundColor() and pushBackgroundColor() appropriately. trying to get that test to pass, by adjusting it, or other related code. and then doing some research and seeing if there are escape codes not yet implemented which need to take care to reverse the operation.

It's also worth pointing out that either of these branches #57
and #55 may have some impact on this issue.

let me know if you run into any complications

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants