Closed starpit closed 5 years ago
as rendered by ansi-to-html 0.6.10
as tendered by macOS Terminal; observe the rendering disparities: underline persist
(ignore the differences in color scheme, and the newline irregularity at the end; the latter is a bug on my side)
@starpit is there a way to get a dump of the raw escape sequences and text from npm, before being interpreted by the terminal. That would be useful for generating a failing test from.
hi @rburns thanks for the help. hopefully this works to preserve the control characters
to recreate this:
const a2h = new (require('ansi-to-html'))
const { spawn } = require('child_process')
let txt = ''
const child = spawn('npm', ['v'])
child.stdout.on('data', data => { txt += data.toString() })
child.on('close', () => { console.log(a2h.toHtml(txt)) })
you should observe that the <u>
and <b>
tags are opened but never closed; actually i think many tags are opened but not closed. perhaps this could be resolved by adopting the same fix as in #49, whereby ansi-to-html gives up entirely on closing tags, and instead focuses on emitting new tags to "reset" the current state.
@starpit, Thanks. I've come up with this https://github.com/rburns/ansi-to-html/pull/54 which I think addresses the immediate problem. It improves the tag which was introduced in #49. Would you be able to test that and let me know if it has the desired affect without introducing other issues?
I have another branch started with a more involved overhaul of the styling which leans on css in favor of closing tags. Would you be willing to do some testing of that as well, once I get it finished?
@starpit there are a more comprehensive changes to the styling tags here https://github.com/rburns/ansi-to-html/pull/55 one possible problem with that approach is that tags are no longer closed explicitly. they only get closed as a side-effect of the text ending. I'd be interested to see how/if it breaks with some real-world use case.
fixed in #54
try sending the output of
npm v
to ansi-to-html, and you should find that the underline attribute persists; see attached.The problem seems to be that the attribute stack is managed inconsistently. Some attributes are push/popped (e.g. underline) whereas others (e.g. bold see #49 ) are pushed but not popped. In addition to bold, foreground and background colors seem to be pushed but never popped --- even the reset escape code results in a tag push.