ANSI colors regression compared to Notebook #3773
I've spent a considerable amount of work on the handling of ANSI colors in the Jupyter Notebook, mainly in https://github.com/jupyter/notebook/blob/master/notebook/static/base/js/utils.js.
It looks like when switching to JupyterLab, this was mostly for the bin.
At least my choice of colors has been taken in #2457, but some CSS names have been changed e.g. from
More importantly, there seems to be no support for bold fonts. The ANSI escape sequences for "bold" only switch to the "bright" (or rather "intense") color (which is good), but don't switch to a bold font.
ANSI "underline" and "inverse" don't work either. Granted, support for those was only added to the Notebook quite recently.
The extended colors don't seem to work either (I tried it on a local installation and on binder), which is I guess due to a myriad of CSS definitions like
Finally, 24-bit colors are not showing up. I don't know how this is supposed to work, the generated HTML looks like this:
<span class="ansi-truecolor-fg ansi-truecolor-bg" data-ansi-truecolor-fg="25, 0, 230" data-ansi-truecolor-bg="230, 0, 25">
All of the above works fine in the latest release of the Notebook.
So what about dumping ansi_up and just using the good old code from the Notebook instead?
Here are two test notebooks:
Note that the Notebook version currently used on binder doesn't support proper ANSI "inverse" yet (but the latest Notebook release does), nor does the latest
The text was updated successfully, but these errors were encountered:
@mgeier I don't think anyone working on lab has a strong usage of, nor opinions about ANSI colors. We would love to have your help (or at least advice) getting them in better shape in JupyterLab - especially as it looks like you have a lot of relevant experience. The regressions compared to the classic notebook in the ANSI colors are not deliberate - hopefully with a small bit of work, just temporary.
The test notebooks you have provided will be super helpful in bringing everything over.
I don't really have any opinion about ansi-up, versus the classic notebook's code.
Do you want to have a go at a PR, or do you think there are any decisions to make before you or someone dives into the code?
I don't know if I'm aware of all the options.
One option would be to try to fix ansi_up, but I think there is too much wrong with it for that to be feasible.
Another option would probably be to use xterm.js, since that's a dependency already.
We could try to find yet another package that's more correct than ansi_up but probably less complex than xterm.js?
Or we could use the old Notebook code.
Are there any other options that I missed?
However, if nobody else wants to do it, I can try to tackle it, but it will probably take a long time and I'll need a lot of help ...
Hi @mgeier, thanks for engaging on this subject! It is a shame to hear that
The reason I say xterm 3.0 is that they switched to canvas based drawing. I suspect that it would be overkill and take longer for the initial render when we don't need it, but it is worth trying as an experiment I think.
Yes @blink1073, trying xterm.js sounds like an interesting (and possibly doomed) experiment. Sadly, I don't have the abilities to do that.
There is another concern: copying text from the xterm.js area could be problematic, at least it is currently in the JupyterLab Terminal.
What about updating the JupyterLab Terminal to the latest xterm.js version?
AFAICT, "underline" and "inverse" don't work at all, and using "bold" doesn't switch to the "bright"/"intense" color (see #4230 (comment)).
The current Classic Notebook and
The result should look something like this:
Note that between
* WIP: Try to replace ansi_up with code from Classic Notebook Fixes #3773. * Add html escape and clean up lint * TST: Update ANSI tests * revert changes to staging * Move code to Private namespace * Rename main function: fixConsole() -> ansiSpan() * Use ES6-style string formatting and arrow function * Add return type annotations