Open bolinfest opened 4 years ago
In my environment, Jupyter notebook/lab handles ANSI escape colors and show colorful texts in browsers.
What is shown in your Jupyter environment for console.log(55)
?
I am not using the stock Jupyter notebook/lab for my presentation layer.
I use https://www.npmjs.com/package/ansi-to-html to render ANSI output for errors, which works fine because you get the entire error at once. I do not believe it works well for streaming output, though. For example, in my original example, suppose you received the output in two chunks: "\u001b[33"
and "m55\u001b[39m\n"
. How would you ensure it is displayed correctly as you receive each chunk of the stream?
It's doable, but it's not simple. Output that is free of ANSI characters is much easier to deal with because you can just keep appending to the innerText
of the DOM element used to display it.
If I run
console.log(55)
, the Jupyter message I get back is a stdout stream with the contents"\u001b[33m55\u001b[39m\n"
because of the ANSI escapes for colorization. I was hoping to get"55\n"
just like I would if I didprint(55)
in a Python kernel.