-
Notifications
You must be signed in to change notification settings - Fork 82
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
Can't specify both foreground and background text color #153
Comments
@itaych Care to turn this matrix into a test in this project? |
@dblock I wouldn't know how to do that myself (Github newbie, unfamiliar with the innards of this project, haven't touched Java since last century). I will be happy to give you any information you need though, here or by email (same username at gmail). |
@dblock I think I've understood the problem. The first line ("green text purple background" twice) looks like this in the HTML generated by ansicolor: |
@itaych What web browser are you using? I wonder if some browsers are ok with nested spans like that and others don't like it.
Yeah, changing this wouldn't be trivial. It would probably be possible to do something like buffer color-related tags just in case the next tag is also a color-related tag and then combine them before emitting them, but it would take some experimentation. |
@dwnusbaum I was using Firefox under Linux to test, and I believe it looked the same under Chrome too. But here's where the rabbit hole gets deeper: I've just tried pasting the code with the nested spans from my previous message into a blank .html file (wrapped in html and body tags), loaded the file in Firefox and Chrome and it works - both text segments are green on purple background. So there's no need to change the code, rather understand why the result looks bad in the context of a full Jenkins console output web page but just fine when isolated. |
I think I'm getting close. TL;DR: I believe there is no need to change the plugin - the issue can be easily solved with some CSS changes. Consider this HTML: This is basically a Jenkins console output window with all text and code irrelevant to reproducing the issue removed. The style segment is from the file jenkins-material-theme.css (part of the Jenkins install). What happens here is that every new 'span' inside the console-output is created with the specified console-output text and background color; in case of nesting this causes the color from the outer element to be lost. I've found that this can be prevented in three ways: Any of these solutions is sufficient to solve this issue but (especially regarding 1 and 2) I'm not sure what undesirable side effects they may have, nor do I know where to implement them. (Should we change the jenkins-material-theme.css? Are there additional themes that would all need to be changed?) |
@dblock - You added "needs more info" - what more info do you need (and how can I help)? You added "bug?" - do you think this isn't a bug? |
@itaych I wasn't sure where you were getting |
@dwnusbaum You are correct, we are indeed using the Material Theme, and without it the bug no longer appears. Theme author @afonsof - please take a look at this thread. What I'm uncertain about is whether the problem is specific to this theme or is common to several themes that perhaps share a common base. In any case I now agree that this is not an issue with ansicolor. Thank you. |
@itaych Thanks for your detailed investigation into finding the root cause of the bug! |
Under Jenkins 2.150.2, AnsiColor 0.6.2, it appears that when specifying both foreground and background color for text, only the latter of the two will take effect.
For example:
\e[45;32m Text1 \e[m \e[32;45m Text2 \e[m
Both text1 and text2 should have green text and a purple background, and that indeed is the result in Gnome Terminal. But in Jenkins, text1 will be green on unchanged background and text2 will be white text on purple background.
Here's an example stress test file: colorlog.txt
Here's what it looks like under Gnome Terminal:
![image1](https://user-images.githubusercontent.com/24361059/53729357-ba5cf880-3e7d-11e9-9560-8c21bed1b62c.png)
And here it is under AnsiColor:
![screenshot from 2019-03-04 13-01-20](https://user-images.githubusercontent.com/24361059/53729374-c2b53380-3e7d-11e9-9b4a-162aa08c74d0.png)
Thanks!
The text was updated successfully, but these errors were encountered: