-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Re-factor ANSI color handling #1230
Conversation
When I'm running the tests, I'm getting this (the same happens at Travis CI):
Does that mean that ES6 is not supported? |
@mgeier ES6 isn't used in the notebook js yet, so you have to use ES5. |
@minrk OK, will do. What are the plans for ES6 support? |
The implementation is based on Python code from nbconvert.filters.ansi2html(). Among other things, this fixes jupyter#988.
We are adding it in new projects in various places (JupyterLab, ipywidgets, etc.). I'm not sure if we will add ES6 support to the old notebook js, as it is planned to be replaced by the totally rewritten frontend code in JupyterLab, which is mostly using TypeScript and ES6. |
OK, thanks, that sounds reasonable. I've re-based my initial commit (7bee6c5). Then I've removed the ES6 stuff (245287a). Finally, I've updated the tests and added a new test case for overlapping formatting, which wasn't supported before (9d05258). Now Travis CI doesn't complain anymore, hooray! I would love to hear some feedback about the new code! What about the colors? Does everybody like them? Any suggestions for improvements? |
if (numbers.length < 2) { | ||
console.log("Not enough fields for VT100 color", numbers); | ||
// Ignored: Invalid color specification | ||
numbers.length = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to set length = 0 if we are returning here, plus length should be treated as read-only in general.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually have to clear numbers
here, because there might already be some entries from previous loop iterations.
Would you prefer if I used
numbers = [];
Or something entirely different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just saw that there is an error because I'm not returning an Array in this case!
Would it be adequate to do this:
return [];
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... or should I rather use break;
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! |
Thanks for merging! |
Thanks @mgeier! |
Thank you for this, looking forward to the new release. |
This is based on a PR I made for
nbconvert
: jupyter/nbconvert#225.It also contains the "upgrade" to 16 ANSI colors from a future PR, see jupyter/nbconvert#245 and jupyter/nbconvert#259.
I've not yet updated the tests because I'd like to get some general feedback before.
WARNINGS: