rburns / ansi-to-html

Convert ansi escaped text streams to html.
MIT License
357 stars 48 forks source link

Support for `Reset all attributes` sequence #81

Closed abitrolly closed 4 years ago

abitrolly commented 4 years ago

Are there any reasons why reset all attributes ESC[0m code is not supported?

image

https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters

To reset colors to their defaults, use ESC[39;49m (not supported on some terminals), or reset all attributes with ESC[0m.

https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit

rburns commented 4 years ago

there are some tests here https://github.com/rburns/ansi-to-html/blob/master/test/ansi_to_html.js#L115 which indicate that the reset code is supported. do you have an example of a situation that isn't working? perhaps a complex case of this variety https://github.com/rburns/ansi-to-html/blob/master/test/ansi_to_html.js#L122 which fails.

abitrolly commented 4 years ago

Unfortunately, I didn't record the test case and I can't get back to it. The converter still has more serious problem with output https://travis-ci.community/t/ansi-logs-missing-colors-and-formatting-problems/9489/3

rburns commented 4 years ago

that appears to reference a different package https://www.npmjs.com/package/ansiparse https://github.com/mmalecki/ansiparse

abitrolly commented 4 years ago

@rburns my bad. I guess I was trying to print https://api.travis-ci.com/v3/job/366719641/log.txt with ansi-to-html. Unfortunately, I can not test anything right now, because bundle.run is down https://github.com/Rich-Harris/packd/issues/136 and ansi-to-html does not ship as ES6 module https://github.com/rollup/rollup/wiki/pkg.module which my scripts could use directly.

abitrolly commented 4 years ago

Maybe I was confused by black background by default. In any case it seems to work with the following snippet.

image

https://observablehq.com/@abitrolly/ansi-text-viewer