Wrong color representation of some valid/standard CSS code (@-rules)
-
Notepad++ v7.8.5 is representing CSS @-rules with wrong colors.
For my project it is about the following @-rules:@charset
@font-face
@keyframes
@media- Independent of what would be the correct representation, @media is shown differently from the other three. So, there is something inconsistent.
- The content of @keyframes has wrong color representation, at least the start condition. The end condition seems correctly represented.
See the attached screenshots “css1.png” and “css2.png”.
I tried to add those keywords into my own “langs.xml” (language “css”, “instre1” or “instre2”, with or without “@”), but does not seem to have any effect. May be a new “instre” or “type” is needed for @-rules (just a guess)…
Environment:
Notepad++ v7.8.5 (64-bit)
Build time : Mar 4 2020 - 11:08:34
Path : C:\Program Files\Notepad++\notepad++.exe
Admin mode : OFF
Local Conf mode : OFF
OS Name : Windows 10 Home (64-bit)
OS Version : 1909
OS Build : 18363.778
Plugins : DSpellCheck.dll mimeTools.dll NppConverter.dll NppExport.dll
-
Interestingly, mine seems to be the opposite –
@media
shows up as a single color (black), whereas@keyframes
and (not shown)@charset
and@font-face
all show up with black@
but blue text:
It may be that your theme has outdated definitions for the CSS Lexer. I am using the default
stylers.xml
rather than a dark theme.The default
stylers.xml
is the only theme that’s generally kept up-to-date with respect to the lexers; the other themes were bundled into the main Notepad++ distribution years ago, but haven’t always been actively maintained by the developers, that I can tell. They will require someone (possibly not on the core development team) be willing to submit PRs and convincing the main development team to incorporate those PRs. There has been another conversation recently that some here are trying to think of ways to automatically update the other themes, whether that gets incorporated into the distributed themes, or whether you have to run it locally if you care about the themes is something that’s not yet determined. -
Hi @PeterJones , I am using the “Bespin” theme. I do not know how Notepad++ internally works, but I would expect that it identifies all keywords of HTML5, CSS3 and Javascript (the languages I am working with) and handle them them according to internal rules. The theme, which is just a color/style mapping of identified keywords in a certain context, should be irrelevant. As these languages are developing continuously, the identification of keywords should be up-to-date in Notepad++. Notepad++ is a great tool, but I noticed also other keywords in HTML, CSS and Javascript colored/styled wrongly. If you are in the position to get Notepad++ enhanced in this respect, please do so. That would be great!
Thanks, Hans -
I am using the “Bespin” theme.
The theme, which is just a color/style mapping of identified keywords in a certain context, should be irrelevant.If the theme were set up correctly, then it would be irrelevant. But maybe the theme is out of date.
Think of the theme as a mapping from the named settings in Notepad++ to the numbered array in the lexer (which is part of another separately-maintained codebase, known as Scintilla).
Assume, for example, that in the “old days”, the CSS lexer expected “SETTING A” to be mapped to ID=1 and “SETTING B” to be mapped to ID=2. Then assume the “Bespin” theme was created. Then assume Scintilla changed the CSS mapping to expect “SETTING A” to be mapped to ID=3 and “SETTING B” to be mapped to ID=4. The default theme in Notepad++ was then updated, but no one updated the “Bespin” theme. So you tell the Bespin theme “I want these colors for SETTING A and SETTING B”, and the theme maps those to ID 1 and 2, and the lexer doesn’t see them because it’s looking for 3 and 4. Hence, the theme is not irrelevant to the conversation. (Note, I am not saying this is for-certain the case for the Bespin theme and CSS lexer; I am just saying it’s not out of the realm of possibility; I use the default theme, and rarely edit standalone CSS.)Thus, because it might very well be the theme, for debugging purposes, please try the default theme.
If you are in the position to get Notepad++ enhanced in this respect
This is a forum for the Community of Notepad++ users. Some here have contributed to the codebase, but the primary developer uses the forum mostly for announcements. And this is especially not a 1-on-1 support desk, where you can expect that I am now committed to solve your problem for you – I voluntarily read and answer in this forum, to help other Notepad++ make good use of the tool, but I am not part of the “in crowd” or a paid employee, and you cannot assume that I will always be available.
Feature requests and bug reports do not go in the Forum – but really, the forum is a good first-line of support, to help educate users before feature requests are made: maybe there is already a way to accomplish the goal in an alternate manner.
I noticed also other keywords in HTML, CSS and Javascript colored/styled wrongly
If it’s colored or styled wrongly in the default styler, then show us where you think it’s wrong, and there’s probably a bug (or a misunderstanding of what the correct behavior is); otherwise, the theme is likely to blame. As I’ve said, the developers don’t regularly update the themes that are bundled with Notepad++.